How to expose one WCF service with several service modes?

I have a WCF service that must meet the following requirement:

  • Endpoint1: it should use netTCP binding with Windows authentication.
  • Endpoint2: it should use netTCP binding with username and password verification.

I was able to perform both of these steps individually, creating two service behaviors: one for Windows authentication and one for username and password, but in this way I have to set 2 services instead of 1 for the above functions. I am looking for a way by which I could expose only one service and another configuration of endpoints, I can fulfill this requirement.

Useful code snippet and configuration.

+4
source share
1 answer

This is one of the scripts supported by WCF, one interface open as two different endpoints.

They will have two different addresses, but will point to the same code.

<service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior"> <!-- This endpoint is exposed at the base address provided by host: http://localhost/servicemodelsamples/service.svc --> <endpoint address="" binding="basicHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" /> <!-- secure endpoint exposed at {base address}/secure: http://localhost/servicemodelsamples/service.svc/secure --> <endpoint address="secure" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" /> ... </service> 

See: http://msdn.microsoft.com/en-us/library/ms751515.aspx

+2
source

Source: https://habr.com/ru/post/1433236/


All Articles