WCF NetTcpBinding with mex

前端 未结 3 1882
醉梦人生
醉梦人生 2020-12-03 14:22

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:



        
相关标签:
3条回答
  • 2020-12-03 14:47

    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.

    0 讨论(0)
  • 2020-12-03 14:58

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

    0 讨论(0)
  • 2020-12-03 15:04

    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>
    
    0 讨论(0)
提交回复
热议问题