WCF stands for Windows Communication Foundation with the code name “Indigo”. It is Application User Interface used to create distributed applications using .NET Framework.System.ServiceModel name space is required to utilize WCF Concepts.
WCF application is a service that is collection of end points in order to communicate with client or service applications. System.Runtime.Serialization name space is required to serialize the data.
WCF Terminology
Addresses The location of service in the form of URI .These are the expose points of services.
Bindings How they communicate with the protocol For ex: The type of network protocol used in WCF.
Contracts the methods exposed by WCF defines the contract.
Service Contract
This attribute that is applied to interfaces in WCF service.
Operation Contract
This is the contract that is applied to methods that are implementing WCF interface.
Channel If client and server wanted to interact with each other . They need to go through the channel that has input message at one end and the other end as results message.
Intermediaries
Intermediaries as the name suggests these are programs that act as "middle-man”. They are commonly invisible to the client and services.ex: a firewall ,gateway
Creating WCF Service
Open VS2008 or VS2010 and Create a New Project->WCF->WCF Service Library Project as shown below.

You have the Service.cs and IService.cs in WCF Project
IService.cs is the WCF interface and Service is where exactly you will implement the interface. You already had methods as GetDataUsingDataContract(), GetData() as methods.
Let us implement one method called GetEmpID()in WCF Service.cs that gets the GUID .
We need to add an operational contract and define a method in IService interface in order the service to create or use this method Operational Contract is a must.
[OperationContract]
string GetEmpID(string empId);
Append this line of code in the IService that implements Service class
public string GetEmpID(string EmpId)
{
EmpId = Guid.NewGuid().ToString();
return EmpId;
}
Running WCF Service using Visual Studio 2008
Press f5

Visual Studio itslef creates WCF Test client for theservice where we can test the demo service working or not.

Press invoke button

You can also examine the XML File that contains soap headers in the with xml tabs
And also config file in the config section.

WCF application is a service that is collection of end points in order to communicate with client or service applications. System.Runtime.Serialization name space is required to serialize the data.
WCF Terminology
Addresses The location of service in the form of URI .These are the expose points of services.
Bindings How they communicate with the protocol For ex: The type of network protocol used in WCF.
Contracts the methods exposed by WCF defines the contract.
Service Contract
This attribute that is applied to interfaces in WCF service.
Operation Contract
This is the contract that is applied to methods that are implementing WCF interface.
Channel If client and server wanted to interact with each other . They need to go through the channel that has input message at one end and the other end as results message.
Intermediaries
Intermediaries as the name suggests these are programs that act as "middle-man”. They are commonly invisible to the client and services.ex: a firewall ,gateway
Open VS2008 or VS2010 and Create a New Project->WCF->WCF Service Library Project as shown below.
You have the Service.cs and IService.cs in WCF Project
IService.cs is the WCF interface and Service is where exactly you will implement the interface. You already had methods as GetDataUsingDataContract(), GetData() as methods.
Let us implement one method called GetEmpID()in WCF Service.cs that gets the GUID .
We need to add an operational contract and define a method in IService interface in order the service to create or use this method Operational Contract is a must.
[OperationContract]
string GetEmpID(string empId);
Append this line of code in the IService that implements Service class
public string GetEmpID(string EmpId)
{
EmpId = Guid.NewGuid().ToString();
return EmpId;
}
Running WCF Service using Visual Studio 2008
Press f5
Visual Studio itslef creates WCF Test client for theservice where we can test the demo service working or not.
Press invoke button
You can also examine the XML File that contains soap headers in the with xml tabs
And also config file in the config section.
No comments:
Post a Comment