WCF service with two binding types for two different clients

How can I open a WCF service so that one client using wsHttp bindings and another client using netTcp bindings can use the service?

+3
source share
2 answers

In short, you can do this simply through configuration!

Have you seen this tutorial? Check it out .

This is a great tutorial with screen shots of the entire basic process of setting up a trial service with multiple endpoints using the Microsoft Configuration Configuration Editor .

0
source

All the configuration information — when you define your service, you just go and define two endpoints — one for wsHttpBinding and one for netTcpBinding . It is so simple!

 <system.serviceModel> <services> <service name="YourNamespace.MyService"> <endpoint address="ws" binding="wsHttpBinding" contract="YourNamespace.IMyService" /> <endpoint address="net.tcp://localhost:8787/MyService" binding="netTcpBinding" contract="YourNamespace.IMyService" /> <host> <baseAddresses> <add baseAddress="http://localhost:8282/" /> </baseAddresses> </host> </service> </services> </system.serviceModel> 

Now you have a service that exposes two endpoints:

  • using wsHttpBinding at http://localhost:8282/ws
  • using netTcpBinding at tcp://localhost:8787/MyService

Both endpoints are for the same service, for the same service contract, for example. offer the same functionality and service methods.

Each service endpoint in a WCF must define a WCF ABC:

  • [A] ddress - where can a service be reached / called?
  • [B] inding - how can a service be called (protocol, settings, security, etc.)?
  • [C] ontract - what does the service offer at this address, what methods are exposed?
+12
source

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


All Articles