【问题标题】:Multiple WCF service endpoints in IIS breaks wcftestclientIIS 中的多个 WCF 服务端点中断 wcftestclient
【发布时间】:2012-01-25 12:34:24
【问题描述】:

我正在尝试通过 IIS 中的 http 和 net.tcp 绑定公开 WCF 服务。 当我只指定 net.tcp 绑定或只指定 http 绑定时,一切似乎都按预期工作,但是当我添加 wcftestclient 程序和所有其他服务代理生成器时都失败了:

错误:无法从 net.tcp://host/application/service.svc 获取元数据 ... 元数据交换错误 URI:net.tcp://host/application/service.svc 元数据包含无法解析的引用:“net.tcp://host/application/service.svc”。 > 在 net.tcp://host/application/service.svc 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。

我的 web.config 如下所示:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>      
      <service behaviorConfiguration="ServiceBehavior" name="MyServiceBehavior">
        <endpoint address="mex-http"      binding="mexHttpBinding"   name="mex-http" contract="IMetadataExchange" />
        <endpoint address="service-http"  binding="basicHttpBinding" name="db-http"  contract="IMyService" />
        <endpoint address="mex-tcp"       binding="mexTcpBinding"    name="mex-http" contract="IMetadataExchange" />
        <endpoint address="service-tcp"   binding="netTcpBinding"    name="db-http"  contract="IMyService" />
      </service>      
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

所以,如果我删除 mex-http 和 db-http 端点,一切都很好。如果我不这样做,则可以通过 http 访问该服务,但不能通过 tcp 访问该服务。如果我删除 tcp 端点,当然 http 端点仍然可用。有什么想法吗?

编辑: 根据 Marc 的建议,我将相关的 net.tcp 端点更改为阅读

<endpoint name="mex-http" address="net.tcp://localhost/myservice/MyService.svc/mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint name="db-http"  address="net.tcp://localhost/myservice/MyService.svc"     binding="netTcpBinding" contract="IMyService" />

按预期工作!

【问题讨论】:

    标签: wcf iis web-config nettcpbinding


    【解决方案1】:

    你检查了吗

    您是否已完成这些步骤以使 net.tcp 在 IIS / WAS 中可用?

    假设您有 - 我相信在 WAS 中托管 net.tcp WCF 服务需要您在 net.tcp 端点上定义 net.tcp 基地址和/或完整地址 - 因为这些东西不是由 IIS 定义的虚拟目录。

    那就试试吧:

    <services>      
       <service behaviorConfiguration="ServiceBehavior" name="MyServiceBehavior">
           ...(your http stuff here)....
           <endpoint name="mex-http" 
               address="net.tcp://YourServer:7171/NetTcpService/mex"       
               binding="mexTcpBinding"    
               contract="IMetadataExchange" />
           <endpoint name="db-http"  
               address="net.tcp://YourServer:7171/NetTcpService/MyService"       
               binding="netTcpBinding"    
               contract="IMyService" />
      </service>      
    </services>
    

    或:

    <services>      
       <service behaviorConfiguration="ServiceBehavior" name="MyServiceBehavior">
          <host>
             <baseAddresses>
                <add baseAddress="net.tcp://YourServer:7171/NetTcpService"/>
             </baseAddresses>
           </host>
           ...(your http stuff here)....
           <endpoint name="mex-http" 
               address="mex"
               binding="mexTcpBinding"    
               contract="IMetadataExchange" />
           <endpoint name="db-http"  
               address="MyService"
               binding="netTcpBinding"    
               contract="IMyService" />
      </service>      
    </services>
    

    【讨论】:

    • 感谢您的回答。是的,net.tcp 可用(没有实际工作的 basicHttpBinding)。我相信在 IIS 中托管时,web.config 中的 &lt;host&gt; 添加会被忽略,遗憾的是,指定完整端点地址的建议似乎根本没有任何区别。
    • 你说得对,IIS 需要完全指定 net.tcp 端点地址。它应该指向相应的.svc
    • @FrankRazenberg:好的;感谢您的提醒。我自己从来没有在 IIS/WAS 中托管过 net.tcp,所以将来要记住这一点 - 谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多