views:

2601

answers:

3

We have a service that has some settings that are support only over net.tcp. What's the best way to add another endpoint? Do I need to create an entire new host?

+2  A: 

A service may have multiple endpoints within a single host but every endpoint must have a unique combination of address/binding/contract. For an IIS-hosted service (i.e., an .SVC file), just set the address of the endpoint to a relative URI and make sure that your Visual Studio or wsdl.exe generated client specifies the endpoint's name in its constructor.

See also this MSDN artcile.

Mark Cidade
A: 

You will need to create an entire new host if you are currently using IIS as your host - IIS only supports HTTP and not TCP bindings. If however you are using WAS or a windows service, then you'll be able to get away with simply creating a new net.tcp endpoint.

Bermo
I think II7 does support non-HTTP bindings (i.e. TCP).
Piotr Owsiak
+1  A: 

You can have multiple endpoints defined either on the server, or the client.

To do it on the client, you just need to edit your app.config file with a new endpoint with a different name, then define when you create your new client.

For example if you have an endpoint in your client app like:

<endpoint address="https://yourdomain.com/WCF/YourService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IYourService"
      contract="MessagingService.IYourService"  
      name="BasicHttpBinding_IYourService" />

Which you call by:

YourServiceClient client = new YourServiceClient();

You can add a new endpoint with a new name:

<endpoint address="https://yourotherdomain.com/WCF/YourService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IYourService"
      contract="MessagingService.IYourService"  
      name="BasicHttpBinding_IYourService_ENDPOINT2" />

Which you can call with:

YourServiceClient client = new YourServiceClient("BasicHttpBinding_IYourService_ENDPOINT2");

I just changed the domain above, but if you made a new binding configuration section, you could just change the "bindingConfiguration" value.

Dylan