How to Publish Service Metadata for Your Clients

- J.D. Meier, Carlos Farre, Jason Taylor, Prashant Bansode, Steve Gregersen, Madhu Sundararajan, Rob Boucher

To publish service metadata for your clients:
  1. If your service uses HTTP binding you will need to enable metadata via http get or https get. HTTP get will be required if you are not using transport security. HTTPS get will be required if you are using transport security. The trade off with this configuration is that clients will be able to browse your service metadata with browser.
<serviceMetadata httpsGetEnabled="true" />
<serviceMetadata httpGetEnabled="true"  />
  1. If your service uses HTTP binding you can use a mex endpoint without enabling http get or https get. In this case Browsers will not be able to browse metadata while the clients will be able to create proxies using the mex endpoint. The tradeoff with this configuration is that mexendpoints are not possible if IIS does not have anonymous authentication enabled.
<system.serviceModel>
    <services>
      <service behaviorConfiguration="" name="Service">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
          name="WsBinding" contract="IService" />
*        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""*
*          name="mexendpoint" contract="IMetadataExchange" />*
      </service>
    </services>
   …. 
  </system.serviceModel>
  1. If your service uses HTTP binding you can use a custom endpoint that implements IMetadataExchange without enabling http get or https get. In this case Browsers will not be able to browse metadata while will be able to create proxies using the mex endpoint. Additionally you will be able to use the mex endpoint with any authentication scheme
<services>
    <service behaviorConfiguration="returnFaults" name="MyService">
      <endpoint binding="wsHttpBinding" bindingConfiguration=""
        name="wsHttpEndpoint" contract="IService" />
      <endpoint address="mex" binding="wsHttpMexBinding" 
        bindingConfiguration=""
        name="mexEndpoint" contract="IMetadataExchange" />
    </service>
  </services>
…
  1. If your service does not use HTTP binding, you will need to configure a service metadata and create a mex endpoint
<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BehaviorConfiguration">
          <serviceDebug includeExceptionDetailInFaults="true" />
          *<serviceMetadata />*
        </behavior>
      </serviceBehaviors>
    </behaviors>
    ….
    <services>
      <service behaviorConfiguration="BehaviorConfiguration" name="WCFServicecHost.MyService">
        *<endpoint address="Mex" binding="mexTcpBinding" bindingConfiguration=""*
*          name="MexEndpoint" contract="IMetadataExchange" />*
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="BindingConfiguration"
          name="TcpBinding" contract="WCFServicecHost.IMyService" /> 
      </service>
    </services>
 </system.serviceModel>
 

Additional Resources

Last edited Jun 13, 2008 at 8:17 PM by prashantbansode, version 1

Comments

No comments yet.