[ServiceContract] below this your interface name is declared. There after you'll see [OperationContract] your function contract should be define here. The implementation of the function will be define in "MyService.svc.cs" As provided in the picture.Step 3: Open "MyService.svc.cs" and write code here. As i have written code for my "addfunction". You can write your code inside your function. The picture is shown below.
Step 4: This is most important step. In this we are declaring the end point. Inside the
Step 5: Save the project and run it. This will Display like this. Copy the address from explorer address bar.
Step 1: Open a web application in another VS2008 and right click on solution name and then go to "Add Service Reference" one window will open paste the previously copied link to the address bar and press GO. Then the service will appear in service section then press OK. The service reference will appear in solution explorer as below.
Step2: Now add one button on the default page, then double click on button you'll be in code behind section. Here create the object of the service which appeared in the solution explorer. Something like this.
protected void Button1_Click(object sender, EventArgs e)
{
ServiceReference1.MyServiceClient cls = new wcfProxycall.ServiceReference1.MyServiceClient();
cls.Open();
Response.Write( cls.addData(5, 4));
cls.Close();
}
Hope this article may helped you to understand and build a simple addition programme in WCF.








