.Net | Sitecore

– Abhishek D V

MexHttpBinding v/s WSDL

6 Comments

Lets discuss about how the metadata is exchanged with client in WCF.

There are two ways to exchange metadata with client.

1> MexHttpBinding

2> WSDL

1> Enabling MexHttpBinding:

We can have the metadata exchanged through mexHttpBinding by adding endpoint in our config file like:

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

2> Enabling WSDL

In the Service Behaviors set httpGetEnabled="true"

  1. <serviceMetadata httpGetEnabled="false"/>

If both are added default will be WSDL

Example:

Lets assume we have simple service with IService as contract and web.config of service model looks like this

  1. <system.serviceModel>
  2.       <services>
  3.         <service name="WcfService.Service" behaviorConfiguration="WcfService1.Service1Behavior">
  4.           <endpoint address="" binding="basicHttpBinding" contract="WcfService.IService">
  5.             <identity>
  6.               <dns value="localhost"/>
  7.             </identity>
  8.           </endpoint>
  9.           <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  10.         </service>
  11.       </services>
  12.       <behaviors>
  13.         <serviceBehaviors>
  14.           <behavior name="WcfService1.Service1Behavior">
  15.             <serviceMetadata httpGetEnabled="true"/>
  16.             <serviceDebug includeExceptionDetailInFaults="false"/>
  17.           </behavior>
  18.         </serviceBehaviors>
  19.       </behaviors>
  20.     </system.serviceModel>

Since we have enabled both ( mex and wsdl ) preference will be always given to WSDL

On browsing the service:

2013-05-24_1227

Now we can see metadata is exchanged through WSDL when we add reference of this service to any project.

Disabling WSDL

By simply setting httpGetEnabled=false in Service behavior we can disable WSDl

On browsing service after disabling WSDL

2013-05-24_1231

Now we can see that metadata is exchanged with MexHttpBinding.

6 thoughts on “MexHttpBinding v/s WSDL

  1. Nice Work Dude…

  2. Odilla, aadru neevu bardiddira andre channage erutte bidi, 🙂

  3. Nice & Informative….When should we use mexhttpbinding and any specific code changes required while consuming the service at client side ?

  4. Wov Excellent

  5. Nice man ….thanks

Leave a comment