C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » WCF/Webservices »

Bindings


Posted Date: 31 Dec 2008    Resource Type: Articles    Category: WCF/Webservices
Author: Gollapudi Ramya KrishnaMember Level: Gold    
Rating: 1 out of 5Points: 7



What is a binding?
?? A binding is a simple way to specify three important things
?? A transport: HTTP, TCP, MSMQ, etc
?? An encoding: XML 1.0, MTOM, or binary XML
?? A suite of protocols: security, reliable messaging, etc
?? You define bindings by choosing from these options
?? WCF provides built-in bindings that fill common needs
?? Bindings are used by the runtime to build channel stack
?? Bindings translate into WSDL + WS-Policy when shared

Built-in binding configurations
?? WCF provides built-in binding classes to simplify things
?? Provide configurations that meet the most common needs
?? Based on today's best practices and real-world scenarios
?? The built-in bindings will get you up and running quickly
?? You can then configure them to fit your precise needs

Built-in binding comparison

The table is shown in the attached document.

Configuring the built-in bindings

• The built-in bindings can be configured in code or config

o Simply instantiate binding class and set properties
...
// Uses the built-in BasicHttpBinding
BasicHttpBinding b = new BasicHttpBinding();

b.Security.Mode = BasicHttpSecurityMode.Transport;

// Enables transport security
b.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Basic;
host.AddServiceEndpoint(
typeof(IEchoService), b, "svc");

Configuring the built-in bindings




address="https://localhost:8082/echo/svc"
binding="basicHttpBinding"
bi di fi i " idi fi i "
bindingConfiguration="MyBindingConfiguration"
contract="ServiceLibrary.IEchoService"/>
...






transport clientCredentialT pe "Basic" /









Defining a custom binding
?? In WCF, a binding is simply a collection of binding elements
?? CustomBinding makes defining a custom binding easy
?? You add binding elements to its Elements collection
?? BindingElement is the base class for all binding elements
?? Found in the System.ServiceModel.Channels namespace
?? Each binding element maps to a node in the channel stack
?? The order of the binding elements is significant
?? Determines how the channel stack is built

Defining custom bindings
• ?? Custom bindings can be defined via CustomBinding class

o Can also define in configuration via element
CustomBinding myBinding = new CustomBinding();
myBinding.Name = "MyBasicHttpBinding";
... // add binding elements here

...


bi di " i tt i di "




Order of binding elements
Binding elements must be organized in the following order:
1. Transaction Flow
2. Reliable Session
3. Security (message)
4. Composite duplex
5. Encoding
6. Security (transport)
7. Transport

5 & 7 are required


Attachments

  • Bindings Comparison (24658-31729-Binding Comparison.doc)


  • Responses

    Author: ChandraShekar Thota    26 Jan 2009Member Level: Diamond   Points : 2
    Good one

    Chandrashekar Thota(Editor, MVP)


    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    WCF Bindings  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: WEB Service Part 1
    Previous Resource: Hosting WCF and ASP.Net Compatability Mode
    Return to Discussion Resource Index
    Post New Resource
    Category: WCF/Webservices


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use