WCF Examples


WCF Projects

WCF Project

WCF Endpoints
Previous Home Next

In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the fusion of Address, Contract and Binding. WCF formalizes this relationship in the form of an endpoint.

Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service


Administrative Endpoint Configuration

Configuring an endpoint administratively requires placing the endpoints in the hosting process' config file. For example, given this service definition:

namespace endname
   interface IMyContract
   class MyService : IMyContract


<service name="MyNamespace.MyService">
<endpoint address="http://localhost:8000/MyService/"
          binding="wsHttpBinding" contract="MyNamespace.IMyContract"/>

Multiple endpoints on the same service:

<endpoint address="http://localhost:8000/MyService/"
          binding="wsHttpBinding" contract="IMyContract"/>
<endpoint address="net.tcp://localhost:8001/MyService/"
          binding="netTcpBinding" contract="IMyContract"/>
<endpoint address="net.tcp://localhost:8002/MyService/"
          binding="netTcpBinding" contract="IMyOtherContract"/>

Service-side binding configuration:

<service name = "MyService">
<endpoint address  = "net.tcp://localhost:8000/MyService/"
          bindingConfiguration = "TransactionalTCP" 
	  binding  = "netTcpBinding" contract = "IMyContract"/>
<endpoint address  = "net.tcp://localhost:8001/MyService/"
          bindingConfiguration = "TransactionalTCP"
	  binding  = "netTcpBinding" contract = "IMyOtherContract"/>
<binding name = "TransactionalTCP" transactionFlow = "true"/>

Service-side programmatic endpoint configuration:

ServiceHost host = new ServiceHost(typeof(MyService));
Binding wsBinding  = new WSHttpBinding( );
Binding tcpBinding = new NetTcpBinding( );
host.Open( );

AddServiceEndpoint( ) It adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Comment / Feedback: