16
votes

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
what are you defining in terms of base addresses? I see nothing in your config... you only have address="mex" for the MEX endpoint - but that's not a complete addressmarc_s
You need to either have a http:// base address where the MEX can be found, or you need to actually specify a "httpGetUrl" in your <serviceMetadata> tag.marc_s
Whatever I write as baseaddress, or in httpGetUrl, doesn't seem to work. for example: localhost:51159/mex or localhost:51159/service1.svc or localhost:51159/service1.svc/mex or adding the ?wsdl nothing works. please help!Clangon

3 Answers

13
votes

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>
12
votes

You need to publish service metadata via http for wsdl. Add the following tag to the <system.serviceModel> tag of your config file

<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. Add this to the <service> node of your config file :

<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?wsdl, you should see the wsdl for your service.

1
votes

You can try mexTcp binding and make sure your base address starts with net.tcp://.....