WCF Service Binding
Before we learn the ABC of WCF, we need to know how a WCF service is made accessible to the clients.
A WCF service allows communication through an Endpoint. And the endpoint is the only point of communication of the WCF service that enables message exchange with the client as shown in Fig 1.
A WCF service allows communication through an Endpoint. And the endpoint is the only point of communication of the WCF service that enables message exchange with the client as shown in Fig 1.
And this Endpoint needs to set the ABC attributes of the WCF service as shown in Fig 2.
Fig. 2
Thus in the WCF world, ABC is an abbreviation of Address, Binding and Contract attributes of an Endpoint.
An example of the Endpoint
Let us quickly run through an example of an endpoint setting in the web.config file at the service side.
Thus in the WCF world, ABC is an abbreviation of Address, Binding and Contract attributes of an Endpoint.
An example of the Endpoint
Let us quickly run through an example of an endpoint setting in the web.config file at the service side.
<!-- Endpoint settings in WCF service -->
<endpoint address="http://localhost:8731/EmployeeWCFService.ServiceImplementation.Manager/" binding="basicHttpBinding"
contract="EmployeeWCFService.ServiceContract.IEmployee" />
For the purpose of this article, we are going to emphasize on the Binding part of the WCF communication mechanism.
So, what is the Binding?
The Binding is an attribute of an endpoint and it lets you configure transport protocol, encoding and security requirements as shown in Fig 3
Types of Binding
One of the design goals of WCF is to unify the way distributed systems are developed prior to release of .Net Framework 3.0. WCF offers a single development framework for all scenarios where distributed solutions were implemented using different technologies such as ASMX web services, .Net Remoting, COM+, etc. WCF achieves this by configuring binding attributes of an endpoint. WCF lets you choose HTTP or TCP transport protocol, encoding, etc. just by tweaking the value of binding attribute for an endpoint.
To cater to different transport protocols, WCF lets you select HTTP, TCP and MSMQ binding types. For the purpose of this article, we are going to concentrate on HTTP and TCP binding with a concise explanation and simple example settings.
basicHttpBinding
This type of binding exists in new .Net world only to support backward compatibility with ASMX based clients (WS-Basic Profile 1.1). Basic http binding sends SOAP 1.1 messages and is used when there is a requirement for the WCF services to communicate with non WCF based systems. Thus, providing an endpoint with basicHttpBinding makes interoperating with other basic implementations of web services a great choice.
Note: All other bindings except basicHttpBinding support WS* specifications including security, reliable messaging and transaction support, where appropriate.
How to setup the basicHttpBinding?
Let us examine how to setup binding for an endpoint in the web.config file.
Step 1: Choose basicHttpBinding as a value in the binding attribute of an endpoint.
<endpoint
address="http://localhost:8731/EmployeeWCFService.ServiceImplementation.Manager/"
binding="basicHttpBinding"
bindingConfiguration="basicBinding"
contract=" EmployeeWCFService.ServiceContract.IEmployee">
Step 2: This step is optional and is only required if the binding's default properties need to be modified, as shown in the example below. In this case, name the binding same as bindingConfiguration attribute in the endpoint section. address="http://localhost:8731/EmployeeWCFService.ServiceImplementation.Manager/"
binding="basicHttpBinding"
bindingConfiguration="basicBinding"
contract=" EmployeeWCFService.ServiceContract.IEmployee">
<bindings>|
<basicHttpBinding>
<binding name="basicBinding"
textEncoding="utf-8"
openTimeout="00:03:00"
closeTimeout="00:03:00"
/>
<basicHttpBinding>
<binding name="basicBinding"
textEncoding="utf-8"
openTimeout="00:03:00"
closeTimeout="00:03:00"
/>
</basicHttpBinding>
</bindings>
</bindings>
Note: All other types of binding are setup in the same way.
wsHttpBinding
This binding sends SOAP 1.2 messages and implements WS* specifications to support enterprise requirements of security, reliability, ordered delivery and transaction management.
netTcpBinding
This binding sends SOAP 1.2 messages, provides binary encoding and optimized communication between WCF services and WCF clients on Windows network. This binding is the fastest binding amongst all WCF binding options between different nodes in the TCP network. Unlike http bindings, the TCP binding does not offer interoperability but is highly optimized for .Net 3.0 and above clients. Thus, in .Net version 3.0 and above, providing an endpoint with netTcpBinding is an easy option to development of distributed systems and can replace COM+ and .Net Remoting model.
netNamedPipeBinding
This binding is used to provide secure and reliable Named Pipe based communication between WCF services and WCF client on the same machine. It is the ideal choice for communication between processes on the same machine.
netPeerTcpBinding
This type of binding exists to cater peer-to-peer computing using WCF services.
For more information on PNRP visit Microsoft page Peer Name Resolution Protocol
wsHttpBinding
This binding sends SOAP 1.2 messages and implements WS* specifications to support enterprise requirements of security, reliability, ordered delivery and transaction management.
netTcpBinding
This binding sends SOAP 1.2 messages, provides binary encoding and optimized communication between WCF services and WCF clients on Windows network. This binding is the fastest binding amongst all WCF binding options between different nodes in the TCP network. Unlike http bindings, the TCP binding does not offer interoperability but is highly optimized for .Net 3.0 and above clients. Thus, in .Net version 3.0 and above, providing an endpoint with netTcpBinding is an easy option to development of distributed systems and can replace COM+ and .Net Remoting model.
netNamedPipeBinding
This binding is used to provide secure and reliable Named Pipe based communication between WCF services and WCF client on the same machine. It is the ideal choice for communication between processes on the same machine.
netPeerTcpBinding
This type of binding exists to cater peer-to-peer computing using WCF services.
For more information on PNRP visit Microsoft page Peer Name Resolution Protocol
Subscribe to:
Post Comments (Atom)
Labels
- Abstraction in Object Oriented Programming (OOPS) Concept (1)
- Access ChildControls in Gridview using Javascript (1)
- Add a WCF Service Reference to the Client (1)
- ASP.Net GridView Highlight Row onmouseover (1)
- ASP.NET View State And ViewStateEncryptionModes Overview (1)
- Calling Javascript From Any Part Of Code Behind Page By Registering The Script (1)
- Check And UnCheck CheckBoxes In Gridview using javascript (1)
- contact your server administrator. (1)
- DataControlField class (1)
- DataKeys ID (Identity Column) in Child Controls events in GridView (1)
- DataList Paging With PagedDataSource (1)
- Declaring Session in Asp.Net (1)
- Difference between Struct and Class (1)
- Displaying Images In GridView From DataBase (1)
- Dynamic Sitemaps in ASP.NET (1)
- Err: You must install Office SharePoint Server 2007 – Please read Microsoft Knowledge Base article: 962935 with the most recent service pack (1)
- GridView Class (1)
- Gridview Inside GridView (1)
- Gridview Paging using C# (1)
- Gridview Sorting Using C# (1)
- GridView.RowDataBound EventEvent (1)
- GridViewRow (1)
- Inserting Images To Database And Display in GridView (1)
- Microsoft Office Sharepoint Server 2007 on Windows Server 2008 – This Program is blocked due to compatibility issues (1)
- ModalPopUp Using CSS and Div To Reduce the Weight On WebPage (1)
- Session State in Asp.Net OverView (1)
- SharePoint 2010 – The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information (1)
- Tooltip GridView Header (1)
- Tree View Menu Control (1)
- WCF Service (12)
- What is Encapsulation in OOPS? (1)
Topics
- Abstraction in Object Oriented Programming (OOPS) Concept (1)
- Access ChildControls in Gridview using Javascript (1)
- Add a WCF Service Reference to the Client (1)
- ASP.Net GridView Highlight Row onmouseover (1)
- ASP.NET View State And ViewStateEncryptionModes Overview (1)
- Calling Javascript From Any Part Of Code Behind Page By Registering The Script (1)
- Check And UnCheck CheckBoxes In Gridview using javascript (1)
- contact your server administrator. (1)
- DataControlField class (1)
- DataKeys ID (Identity Column) in Child Controls events in GridView (1)
- DataList Paging With PagedDataSource (1)
- Declaring Session in Asp.Net (1)
- Difference between Struct and Class (1)
- Displaying Images In GridView From DataBase (1)
- Dynamic Sitemaps in ASP.NET (1)
- Err: You must install Office SharePoint Server 2007 – Please read Microsoft Knowledge Base article: 962935 with the most recent service pack (1)
- GridView Class (1)
- Gridview Inside GridView (1)
- Gridview Paging using C# (1)
- Gridview Sorting Using C# (1)
- GridView.RowDataBound EventEvent (1)
- GridViewRow (1)
- Inserting Images To Database And Display in GridView (1)
- Microsoft Office Sharepoint Server 2007 on Windows Server 2008 – This Program is blocked due to compatibility issues (1)
- ModalPopUp Using CSS and Div To Reduce the Weight On WebPage (1)
- Session State in Asp.Net OverView (1)
- SharePoint 2010 – The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information (1)
- Tooltip GridView Header (1)
- Tree View Menu Control (1)
- WCF Service (12)
- What is Encapsulation in OOPS? (1)
0 Responses to “WCF Service Binding”
Post a Comment