Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do i need both mex endpoint and httpGetEnable?

Tags:

I was wondering why do i need to declare this:

 <serviceMetadata httpGetEnabled="true" /> 

and also this

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 

If i use only the first one - it is working via browser. so why do i need the second one ?

Can you give me example please for the situation which i'll have to use the latter ?

like image 358
Royi Namir Avatar asked Sep 02 '11 15:09

Royi Namir


People also ask

What is a MEX endpoint?

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"). You can create MEX endpoint that can be accessed through http, https, tcp, and even named pipes.

What is WCF mex endpoint?

The Metadata Exchange Endpoint (MEX) is a special endpoint in WCF that exposes metadata used to describe a service, then the mex endpoint is exposed at another relative address ended with \mex. For exmaple: http://localhost:8000/ServiceModelSamples/service/mex.

What is Mex binding in WCF?

What is mexHttpBinding in WCF? To generate a proxy, we need service metadata and mexHttpBinding returns service metadata. If we look into our configuration file, the service will have an endpoint with mexHttpBinding as follows: <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>


2 Answers

You need to

  • enable the service to publish metadata at all (that's the serviceMetadata behavior) - but you don't need the httpGetEnabled - that's optional

  • have a place (endpoint) where an inquiring client can go grab that service metadata - that's the MEX endpoint. This is for a machine-readable format of the metadata - one that Visual Studio or svcutil can use to create a client. It's not intended for human consumption

like image 162
marc_s Avatar answered Jan 18 '23 23:01

marc_s


This seems to be useful in the following situation...

<system.serviceModel>     <services>         <service name="WCFService.Service" behaviorConfiguration="ServiceBehavior">             <host>                 <baseAddresses>                     <add baseAddress="net.tcp://localhost:8080/WCFService"/>                 </baseAddresses>             </host>              <!-- Net.Tcp EndPoints-->             <endpoint address=""               binding="netTcpBinding"               contract="WCFService.IService" />              <endpoint address="mex"               binding="mexTcpBinding"               contract="IMetadataExchange" />             </service>         </services>         <behaviors>             <serviceBehaviors>                 <behavior name="ServiceBehavior">                     <serviceMetadata httpGetEnabled="false" />                 </behavior>             </serviceBehaviors>         </behaviors> </system.serviceModel> 

There are no HTTP endpoints defined and you can get to your service in the following ways...

 - Browser: http://localhost/WCFService/Service.svc      - svcutil.exe net.tcp://localhost:8080/WCFService/Service.svc/mex 

If you comment out the MEX endpoint then neither will work.

You wonder why the meta data can still be seen in the browser as

a) I don't have a HTTP endpoint and b) I have specifically set ...

<serviceMetadata httpGetEnabled="false" /> 

The reason for this is that in the advanced settings for the website I had the following defined for Enabled Protocols under Advanced Settings...

http,net.tcp

If you remove http then the metadata cannot be seen in the browser. It would seem that it is in this scenario, a net.tcp enabled only website, that you need the mex endpoint.

like image 40
Remotec Avatar answered Jan 19 '23 00:01

Remotec