WCF REST Service Template 40 (CS) sample with data access - wcf

I am exploring the online template in Visual Studio 2010: WCF REST Service Template 40
Does anyone know of a great sample to learn from? Or at least point me the right direction...
I am trying to create a service of looking up a EmployeeID from a database to return some serialized employee profile data.
Basically, I wish to know what goes where (via the newer way, WCF 4.0, RESTful, Json).
-ConnectionString
-QueryString
-etc
Hoping the Url will look something like this:
http://localhost:55123/EmployeeService/EmployeeLookup/{EmployeeID}
My next task of course would be to consume the service in some webpage.

I just went through this 10 part sample this weekend (it's supposed to be 12, but they never posted the last 2). It uses a database to retrieve task and user info, and might give you a feel for what you're trying to do.
I found it very useful and informative, and I've been doing SOAP WCF (3.5) for the last year+.
Introducing WCF WebHttp Services in .NET 4
The 10 parts posted so far are:
1. Getting Started with WCF WebHttp Services in .NET 4
2. Clients and the Automatic Help Page in WCF WebHttp Services
3. Updating State in WCF WebHttp Services
4. Automatic and Explicit Format Selection in WCF WebHttp Services
5. Error Handling in WCF WebHttp Services with WebFaultException
6. Using Routes to Compose WCF WebHttp Services
7. Integrating ASP.NET Output Caching with WCF WebHttp Services
8. Returning Custom Formats from WCF WebHttp Services
9. Creating Views in WCF WebHttp Services with T4
10. Conditional GET and ETag Support in WCF WebHttp Services
The first 4 will probably be of the most interest to you based on the question, but all 10 are valuable and informative.

Related

Calling ServiceStack Service from WCF

I work in a company that is only using WCF and i am trying to introduce service stack. Now i understand we are better off using the service stackclients that wcf clients but for some of our stuff and to keep people happy that will not always be possible. Can anyone provide a basic example of a ServiceStack service that can be added as a client into a VS2012 project using the add service reference inside visual studio as you normally do for a WCF service? Basically is there a way to make ServiceStack seem like a WCF service to people that don't know about ServiceStack?
If i can show this i think i can convince my company to make the switch but if not it will be difficult as everything else is WCF based. We are already using the ServiceStack clients to hook into other online websites so it seems a good time to try to convince them to move to the service stack services and clients as long as they feel they can fall back to the WCF client if needed.
Provided you adhere to the SOAP guidelines and limitations in ServiceStack you should be able to add a Service Reference by pointing the client to the ServiceStack wsdl at /soap12, e.g:
http://servicestackbaseurl/soap12
You can also find a link to the soap 1.1/1.2 wsdl (and XSDs) on ServiceStack's /metadata page.

WCF - Advice Required

I am starting a new webservice project which will be consumed by multiple consumer applications done in different technology like ASP, ASP.Net and PHP. I am planning to develop this service as a WCF service. I am new to WCF and I understand WCF is like umbrella tech which has all the features for developing a distributed SOA applications.
I would like to get your advice on whether my choice of opting WCF service over classic asmx service is correct. The consumer applications are existing application done different technologies as I said before. This service is a simple service that creates and updates user information in a centralized DB.
If my decision of choosing WCF is correct, then please let me know if there are any specific things I need to consider so that the existing application can consume my WCF service without any hiccups. In other words, I can provide a asmx service for this which they can consume directly without any issues (and currently they are consuming some of our asmx service. Since the current requirement is new I want it to be done with WCF). Likewise, the consumer should be able to consume my service like they consume asmx service.
I am asking this question because WCF provides additional features like security, etc. and hence the consumers should also follow the practice to communicate with the service.
Any advice is highly appreciated.
You probably want to use BasicHttpBinding in your WCF service and, although I'm not a PHP developer, I understand that PHP 5 has a SOAP library that can be used to create a service proxy based on the WSDL document exposed by the WCF service, assuming metadata exchange is enabled.

Integrating WF4.0 with Silverlight 4.0

I am new to both Silverlight and WF (both 4.0 version), i was wondering if we can integrate WF4.0 with Silverlight 4.0 in such a way that, when we click on some button in sliverlight UI the workflow should be executed and the output from the final activity of the workflow is displayed in the Silverlight screen. If it can be done then please provide me with some link or any tutorial where i can learn about this and start implementing.
Thanks in advance.
In WF 4.0 you can have workflows started (or progressed) by WCF endpoints. Therefore, if you can call the WCF endpoint from your Silverlight application you should be able to do this quite easily. Lots of information on Microsoft's WF Developer Centre.
Assuming you are using Visual Studio 2010, you can get up and running with a very simple Silverlight -> WF example very quickly...
Create a new project (and new solution) from the 'WCF Workflow Service Application' template. The project will be named DeclarativeServiceLibraryX. This should give you a very simple WorkflowService definition using SequentialService that simply receives the request from a client (with a single integer argument) and sends a response (with the same value). This project is created as a web project so includes a Web.config.
Create a new Silverlight 4 application. You will be asked if you want to host the Silverlight app in the existing web project (created in step #1). Probably a good idea to say yes.
In the Silverlight application, select 'Add Service Reference...', then 'Discover/ Services in Solution'. Service1.xamlx will appear as an option, select it and click Ok.
VS will then generate a WCF service reference client. You could then add a TextBox & Button to capture some data, create the client and send the service call across the wire to the WCF Workflow Service. This Workflow Service could then be modified as necessary (or use these steps to add a WCF Workflow Service to your own web project).
One area that might be challenging is modifying the WCF service bindings to be compatible with Silverlight; perhaps create a Silverlight-compatible WCF service in your server-side project first, then create a WF WCF endpoint and look at the generated code & config to see how to put things together.
The MSDN Endpoint blog is also a useful resource for learning more about WF and WCF (especially with the new style lightweight REST-style 'WCF Web HTTP' bindings, which might be more suitable for consumption by a Silverlight client.
I am assuming that you don't want to host the workflow inside the Silverlight app itself, as WF is a full .Net framework component rather than being Silverlight compatible. I'm sure you could write your own lightweight workflow framework that runs inside Silverlight, but given workflow is generally a multi-user, server-side concern this probably wouldn't be very useful concern.
I found an example with WPF here for these samples. Hope they will help you a bit or at least give a general look at this topic.
Workflow Foundation is not included in the Silverlight 4.0 runtime and thus cannot be used within a Silverlight app. So Silx answer do not relate at all to Silverlight. And James Websters answer is the only solution to make use of WF from Silverlight.
You cant use WF with silverlight.... the only way is , You can call WCF service to access WF as explained by James Webster.

using wcf or odata for data entry in wp7

Does anyone have a simple data entry example which involves WCF (Odata ) and WP7?
Thanks
Here are two good places to start:
Introduction to WCF Data service and
ODATA
OData and WCF Data
Services
Once you have the service itself running, you would access it in the WP7 application the same way you access any other WCF service.
Note that there is a OData Client Library for Windows Phone 7. You might also want to read this article for some additional info.

Exposing meta data for a WCF 4.0 Rest Template Service

Probably missing something very basic. I created a WCF 4.0 Rest Service. It works no problems when I'm hitting the url from a browser and I'm getting back what I want.
But now I want to use that service from a client mvc application (it will also be used by other non .net platforms which is why it's a rest service in the first place).
Problem is how do I get a service reference to it so I can start to use it in my c# code? With the new minimal WCF .net 4 config approach and no interface for the service contract, I don't know how to specify a mex endpoint. Ultimately I don't want a mex endpoint in production, just during development. I would love to be able to specify that all my services (around 10 in one application) have endpoints with one tiny piece of config that vs2010 .config transformations just rips out when I publish.
Stop. REST service doesn't use metadata. Metadata (Mex endpoint) are only for SOAP services because WSDL 1.1 (the only version supported by WCF) is able to describe only SOAP service. WADL or WSDL 2.0 is able to describe REST service but non of them is currently supported by WCF.
REST service is consumed by using WebRequest directly or by building ChannelFactory on top of shared contracts. Both methods are described here. Other method is to use HttpClient from REST Starter kit (former API). The problem with Starter kit is that it has never reached RTM (it was replaced by WCF 4). Instead of metadata endpoint WCF 4 REST service offers help page where all operation are described. When using WCF 4 REST template the help page should be already turned on - just add /help sufix to address of your service. Here is another article about building REST clients.