.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Code Snippets >> WCF >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

WCF step by step

Posted By:Vinodh       Posted Date: September 20, 2011    Points: 40    Category: WCF    URL: http://www.dotnetspark.com  

This code snippet explains WCF for beginers in a simple way

Step by step procedure to create WCF:

A.Creating the service (Server side)

Step 1: Open Visual Studio 2010 and create project ,choose  "Windows Service  Application", and give a name to your project say MyService.

Step 2: Open IService.cs  , in that you can see [ServiceContract] where your intetface name is declared and [OperationContract] here you function contract should be defined here (note: delete the default functions if they are not needed), initialize you addData function here

Step 3: Open Service1.svc.cs and add the code for the addData function, ( note: delete the default functions if they are not needed)


Step 4: Declare your endpoint in web.config file add the below code which is in  bold and Italics.



Step 5:Save the project and run it


B. Creating the client to consume the service (Client side):

Step 1: Open another Visual studio 2010 , create a new ASP.net web application.right click the project and go to 'Add Service reference' ,copy and paste the service  url and press OK

Step 2: Open Default.aspx , create a simple button and lable controls

Step 3: Double click the button and add this following code


Ste 4: Build and run the project ,now your client has comsumed the services!!




Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend