Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Mex End Points for Multiple Bindings

Tags:

c#

wcf

mex

I'm building a WCF service that will expose BasicHttp and NetTcp bindings. I've also added two corresponding Mex endpoints, i.e.

<service name="WCFTest.CalculatorService" behaviorConfiguration="WCFTest.CalculatorBehavior">
  <host>
    <baseAddresses>
      <add baseAddress = "http://localhost:8000/WCFTest/CalculatorService/" />
      <add baseAddress = "net.tcp://localhost:9000/WCFTest/CalculatorService/" />
    </baseAddresses>
  </host>

  <endpoint address ="basicHttpEP" binding="basicHttpBinding" contract="WCFTest.ICalculatorService"/>
  <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

  <endpoint address ="netTcpEP" binding="netTcpBinding" contract="WCFTest.ICalculatorService"/>
  <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>        
</service>

Do I really need to add a NetTcp Mex endpoint as well as an BasicHttp Mex endpoint? Will clients not just always use the Http mex endpoint for meta data disocvery regardless of whether they're going to communicate using tcp or not?

Thanks

like image 347
ng5000 Avatar asked Apr 02 '09 11:04

ng5000


People also ask

Can WCF service have multiple endpoints?

Sometimes in our mind the question arise; can we implement multiple service contract in WCF service? And the answer is, Yes we can. Service class implement multiple service interfaces, and then expose each service using a different endpoint.

How do you create multiple endpoints in WCF?

The first endpoint is defined at the base address using a basicHttpBinding binding, which does not have security enabled. The second endpoint is defined at {baseaddress}/secure using a wsHttpBinding binding, which is secure by default, using WS-Security with Windows authentication.

What is Mex endpoint in WCF?

MEX endpoints are special endpoints that allow clients to receive the service's metadata by using SOAP messages instead of only http get requests(ie httpGetEnabled="true").

How many types of endpoints are there in WCF?

All communication with a Windows Communication Foundation (WCF) service occurs through the endpoints of the service. Endpoints provide clients access to the functionality offered by a WCF service. Each endpoint consists of four properties: An address that indicates where the endpoint can be found.


2 Answers

Yes, you can use just the HTTP mex endpoint. I think the assumption is that your client can communicate over HTTP.

like image 188
Adam Fyles Avatar answered Sep 18 '22 04:09

Adam Fyles


No, the assumption in your code is that the communication channel can either http or net tcp.

If you don't declare both that means you are restricting the service / client to communicate over only one binding.

like image 28
Manju P Avatar answered Sep 19 '22 04:09

Manju P