Thursday 23 February 2012

Step by step process to develop a simple WCF service

WCF is one of the best programming models supplied by Microsoft for building more secure, reliable, interoperable system for building, configuring and deploying network-distributed services. WCF being a unified programming model that has features of a Web Service, features of Remoting, and MSMQ and others.
In this first article we will discuss Step by step on how we to create a simple WCF service.
1. Start visual studio and select a WCF service application template, Name the project as WcfService1, choose a location to save this project.
2. Remove all the predefined generated code from IService1 file and type as shown in the figure to create a Greeting method. 


3. Now open the Service1.svc.cs file and implement the interface method.

4. Check the web.config file for the changes, comments are seft explanatory.

5.Build and run the service.

6. The WCF Service is ready and now we need to create a client application to test our service.

7. Add a new console application project to the solution name it as SampleClient
8. Now right click on the references and click on ServiceReference, Specify the address to locate the service and Set the namespace Click Ok.

9. Create an object of the proxy client class and call the Greeting method as shown.

10. Check the app.config file for configuration changes
11. Build and execute the application
Thats it ... its done.

Conclusion

You all saw how simple it is to create a simple WCF and test it using a console client application. In my next article I will explain you how to test the WCF service without creating any client application.

No comments:

Post a Comment