WCF NetTcpBinding 与 mex [英] WCF NetTcpBinding with mex

查看:34
本文介绍了WCF NetTcpBinding 与 mex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 nettcpbinding 发布 wcf 服务.我想使用 ?wsdl 发布元数据.我在配置文件中添加了以下行:

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"/>

但是我在浏览器中看不到 wsdl.我做错了什么?谢谢.

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

这是我的配置文件的相关部分:

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>

我可能没有访问正确的 URL.我尝试了 http://localhost:51159/Service1.svc?wsdlhttp://localhost:51159/Service1.svc/mex?wsdl,并且没有'?wsdl'.

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'.

推荐答案

您需要使用 元素.

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

这篇关于WCF NetTcpBinding 与 mex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆