Binding C# Help

A binding describes now a ,service wants to communicate. With binding, you can specify the following features:

  1. Transport protocol
  2. Security
  3. Encoding format
  4. Transaction flow
  5. Reliability
  6. Shape change
  7. Transport upgrade

A binding is composed of multiple binding elements that describe all binding requirements. You can create a custom binding or use one of the predefined bindings that are shown in the following table


Depending on the binding, different features are supported. The bindings starting with WS are platform independent, supporting Web services specifications. Bindings that start with the name Net use binary formatting for high-performance communication between .NET applications. Other features are support of sessions, reliable sessions,transactions, and duplex communication; the following table lists the bindings supporting these features.

Along with defining the binding, the service must define an endpoint. The endpoint is dependent on the contract, the address of the service, and the binding. In the following code sample, a ServiceHost object is irtstantiated, and the address http://localhost :8080/RoomReservation, a WsHttpBinding instance, and  the contract are added to an endpoint of the service:

In addition to defining the binding programmatically, you can define it with the application configuration file. The configuration for WCF is placed inside the element <system serviceModel>. The <service> element defines the services offered. Similarly, as you’ve seen in the code, the service needs an endpoint, and the endpoint contains address, binding, and contract information. The default binding configuration of wsHttpBinding is modified with the binding Configuration XML attribute that references the binding configuration wsHttpConfigl. This is the binding configuration you can find inside the <bindings> section, which is used to change the wsHttpBinding configuration to enable reliable Session.

Posted on October 31, 2015 in Windows Communication Foundation

Share the Story

Back to Top
Share This