Last post May 29, 2013 04:58 AM by Illeris
May 28, 2013 05:33 AM|ssjGanesh|LINK
Hi, I have created a simple website using WCF service, and i created a method in
Service.cs and called that in a webform(default.cs).
and then i run that application it working... But my doubt is while i reading about WCf through net they says U have to call that method in
IService.cs file also...I did not call the method written inside Service.cs in IService.cs but its working... So what is the purpose of IService.cs File in WCF service.?
This is how i done that...
public string SampleMethod(string Name)
return "First WCF Sample Program " + Name;
protected void Page_Load(object sender, EventArgs e)
Service obj = new Service();
lblMsg.Text= obj.SampleMethod("By Ganesh");
May 28, 2013 05:47 AM|softvishu|LINK
To understand that first read why contracts/interfaces needed? what's the use of that. you will get your answer. That's true it will work without that also. But read what i told.
May 28, 2013 05:50 AM|sukumarraju|LINK
So what is the purpose of IService.cs File in WCF service.?
As the name indicates IService.cs is an Interface that consists all service methods and is a service contract.
Service.cs inherits and implements the methods that are defined in IService.cs.
Client interacts with WCF service through the contract i.e., IService.cs to access methods.
When the method is NOT declared in the IService.cs it won't be accessible from client.
May 29, 2013 04:58 AM|Illeris|LINK
What you have done is creating a WCF service. This contains a service interface (IService.cs) and an implementation class (Service.cs). Next to that, a SVC file that exposes the IService to the outside world, using the configuration settings in the web.config
In your code sample, you directly create a new Service class. This works, but you are not useing WCF, but directly addressing the service class. You are not "consuming the WCF service" :-)
Please check these articles on how to do so correctly: