Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a service have multiple endpoints?

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

like image 576
Esteban Araya Avatar asked Sep 05 '08 16:09

Esteban Araya


2 Answers

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.

like image 67
Dylan Avatar answered Oct 23 '22 04:10

Dylan


A service may have multiple endpoints within a single host, but every endpoint must have a unique combination of address, binding and contract. For an IIS-hosted service (that is, 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 the MSDN article Multiple Endpoints.

like image 41
Mark Cidade Avatar answered Oct 23 '22 04:10

Mark Cidade