【问题标题】:net.tcp binding metadata problemnet.tcp 绑定元数据问题
【发布时间】:2009-05-25 12:19:07
【问题描述】:
<system.serviceModel>
    <services>
      <service name="SUR.Core.Service.Implementation.SURDirectoryService" behaviorConfiguration="DefaultServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://127.0.0.1:8731/ISURDirectoryService"/>
          </baseAddresses>
        </host>
        <endpoint address=""  binding="netTcpBinding" bindingConfiguration="DefaultDirectoryServiceBindConfig" contract="SUR.Core.Service.Facade.ISURDirectoryService"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
      <service name="MSS.Core.Service.Implementation.MSSDirectoryService" behaviorConfiguration="DefaultServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://127.0.0.1:8731/IMSSDirectoryService"   />
            <add baseAddress="http://127.0.0.1:8732/IMSSDirectoryService"   />
          </baseAddresses>
        </host>
        <endpoint address=""  binding="netTcpBinding" bindingConfiguration="DefaultDirectoryServiceBindConfig" contract="MSS.Core.Service.Facade.IMSSDirectoryService"/>
        <endpoint address="Person" binding="basicHttpBinding" bindingConfiguration="StreamedServicesBinding" contract="MSS.Core.Service.Facade.IMSSPersonService"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <customBinding>
        <binding name="MetadataExchangeTcpBinding">
          <tcpTransport portSharingEnabled="True" />
        </binding>
      </customBinding>
      <netTcpBinding>
        <binding name="DefaultDirectoryServiceBindConfig" maxReceivedMessageSize="1048576"
             closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00">
          <security mode="None"></security>
        </binding>
        <binding name="mexBinding" portSharingEnabled="true">
          <security mode="None"/>
        </binding>
      </netTcpBinding>
      <basicHttpBinding>
        <binding name="StreamedServicesBinding" transferMode="StreamedResponse" maxReceivedMessageSize="10067108864"
                 closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" maxBufferSize="500" >
          <security mode="None"></security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultServiceBehavior">
          <serviceMetadata />
          <dataContractSerializer maxItemsInObjectGraph="6553600" />
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <!--<serviceMetadata httpGetEnabled="True"/>-->
          <serviceThrottling maxConcurrentCalls="30" maxConcurrentSessions="30" maxConcurrentInstances="30"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

这是我的 WCF 配置,但是当我尝试添加服务引用时

net.tcp://127.0.0.1:8731/IMSSDirectoryService

我收到一个错误:

元数据包含无法解析的引用:'net.tcp://localhost:8731/IMSSDirectoryService'。

如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。请帮助我理解我的问题。

【问题讨论】:

  • 我认为问题出在 mex 投标中,服务器无法获取元数据。我应该为 mex 设置安全性为 none 吗?我试图这样做,但我收到了另一个错误消息......

标签: .net net.tcp wcf


【解决方案1】:

您定义了两个相同的基地址:

<service name="SUR.Core.Service.Implementation.SURDirectoryService" 
         behaviorConfiguration="DefaultServiceBehavior">
  <host>
    <baseAddresses>
      <add baseAddress="net.tcp://127.0.0.1:8731/ISURDirectoryService"/>
    </baseAddresses>


<service name="MSS.Core.Service.Implementation.MSSDirectoryService" 
         behaviorConfiguration="DefaultServiceBehavior">
   <host>
     <baseAddresses>
       <add baseAddress="net.tcp://127.0.0.1:8731/IMSSDirectoryService"   />

这就是您的问题的原因 - 当连接到 net.tcp://127.0.0.1:8731/ 时,WCF 不知道您指的是哪个服务。

基地址在其“架构”中必须是唯一的(例如 http、net.tcp 等)

马克

编辑:如果您希望能够使用浏览器检索元数据并导航到 URL 以获取它,则需要在服务行为选项中激活 &lt;serviceMetadata httpGetEnabled="True"/&gt;。否则,您将只能通过 net.tcp 使用 SOAP 调用来获取元数据 - 例如使用 Visual Studio 9/Common7/IDE 文件夹中的“WcfTestClient.exe”应用程序。

编辑 2:您已经为 MEX 定义了许多额外的绑定和行为,但是由于您的任何 mex 端点实际上都没有引用任何这些设置,因此它们没有被使用。

【讨论】:

  • 我更改了 ISURDirectoryService 的端口它没有帮助,我收到相同的错误消息
  • 您是如何尝试获取元数据的?使用一些 SOAP 调用,还是在浏览器中尝试?
  • 浏览器返回床位请求,svcutil 工具为 SUR 生成代理,但在生成 MSS 时出现错误,接收方无法处理带有 Action 'schemas.xmlsoap.org/ws/2 004/09/transfer/Get' 的消息,由于 EndpointDispatcher 的 ContractFilter 不匹配。这可能是因为合约 m ismatch(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全性 m ismatch。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
  • OK - 为了让浏览器能够看到您的元数据(这将是验证一切正常的好方法),请按照我的指示启用 serviceMetadata httpGetEnabled 设置。至于 MSS 服务的错​​误 - 这听起来不像是配置问题。您需要检查您的 SOAP 操作和您的合同——其中有些不一致。能否发布 MSS 服务的服务合同定义?
  • MSS服务合约很大,会不会有问题?我评论了wcfclienttest正常打开服务的所有功能,然后我开始打开cmets,还有一点,即使是简单的合同方法也取消注释会导致错误
【解决方案2】:

我解决了这个问题,我只是将 MSS 服务的 mex 绑定更改为 http。非常感谢 marc_s 你的回复帮助我理解了这个问题!

【讨论】:

  • 我遇到了同样的问题。我不想使用 mexhttpBinding。我想使用 mexTcpBinding。添加服务参考对话框抛出帖子中指出的错误,有什么线索吗?
猜你喜欢
  • 1970-01-01
  • 2011-01-27
  • 2011-01-17
  • 2011-05-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多