tags:

views:

1195

answers:

2

I'm trying to publish a wcf service using nettcpbinding. I want to publish metadata, using ?wsdl. I added the following line to the config file:

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

but I can't see the wsdl in my browser. what did I do wrong? Thanks.

Edit: Here is the relevant part of my config file:

<system.serviceModel>
   <services>
<service name="wcfcheck.service1" behaviorConfiguration="wcfcheck.Service1Behavior">
       <endpoint address="" binding="netTcpBinding" contract="wcfcheck.Iservice1"/>
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
   </services>
<behaviors>
<serviceBehaviors>
  <behavior name="wcfcheck.Service1Behavior">
    <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
    <serviceDebug includeExceptionDetailInFaults="true"/>
  </behavior>
</serviceBehaviors>

I might not be accessing the right URL. I tried both http://localhost:51159/Service1.svc?wsdl and http://localhost:51159/Service1.svc/mex?wsdl, and without the '?wsdl'.

+3  A: 

You need to use the <serviceMetadata> element.

    <behaviors>
      <serviceBehaviors>
      <behavior name="metadataSupport">
        <!-- Enables the IMetadataExchange endpoint in services that -->
        <!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
        <!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
        <!-- Service metadata for retrieval by HTTP/GET at the address -->
        <!-- "http://localhost:8080/SampleService?wsdl" -->
        <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
John Saunders
+4  A: 

You need to publish service metadata via http for wsdl.

<behaviors>
  <serviceBehaviors>
    <behavior name = "MetadataBehavior">
      <serviceMetadata httpGetEnabled = "true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

You will also need to specify an http address where the service metadata in wsdl will be available from.

<host>
  <baseAddresses>
    <add baseAddress="net.tcp://localhost:8001" />
    <add baseAddress="http://localhost:8000/Service1" />
  </baseAddresses>
</host>

Then if you go to http://localhost:8000/Service1?wsld, you should see the wsdl for your service.

Mehmet Aras