【问题标题】:How to add service reference in visual studio with nettcpbinding hosted in IIS?如何使用 IIS 中托管的 nettcpbinding 在 Visual Studio 中添加服务引用?
【发布时间】:2015-08-04 10:04:11
【问题描述】:

我已经在 IIS 中配置了 wcf 服务。 我的 web.config 是

<services>
<service name="DNExpWCFService.Service1"        
behaviorConfiguration="DNExpWCFServiceBehaviour">
<endpoint name="WSGetEmployee" address="/WSGetEmployee"                       
binding="wsHttpBinding" contract="DNExpWCFService.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"></endpoint>
</service>
</services>

现在,当我使用 http://localhost:8333/Service1.svc 添加服务引用时,它工作正常。但是对于 nettcpbinding 我无法添加服务引用。我尝试使用 net.tcp://localhost:8444/Service1.svc。但它也失败了。如何使用 nettcpbinding 添加服务引用?

【问题讨论】:

    标签: c# asp.net wcf iis nettcpbinding


    【解决方案1】:

    要添加服务引用,使用 mex (IMetadataExchange) 端点。 尝试使用 binding="mexTcpBinding"

    添加 mex 端点

    【讨论】:

    • 真的很有帮助。还有一个疑问。为什么我们要添加这一行。它的目的是什么?
    • 与具有 mexHttpBinding 配置的端点相同:添加特殊端点,它将提供返回服务描述(又名 wsdl)的方法,用于为您的服务生成代理类。因此,添加引用实际上是生成这些代理类和适当的客户端来访问您的服务。将传输更改为 TCP 后,您的服务仍然是 SOAP 服务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 2014-11-21
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    相关资源
    最近更新 更多