net.tcp绑定的元数据问题 [英] net.tcp binding metadata problem

查看:444
本文介绍了net.tcp绑定的元数据问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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 configuratio但是当我尝试添加服务引用

Here is my WCF configuratio but when i try to add service reference to

net.tcp://127.0.0.1:8731/IMSSDirectoryService

我得到一个错误:

I get an error:

元数据包含了一个参考无法得到解决:的net.tcp://本地主机:8731 / IMSSDirectoryService。

Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8731/IMSSDirectoryService'.

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

If the service is defined in the current solution, try building the solution and adding the service reference again. Please help me to understand my problem.

推荐答案

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

You have two identical base addresses defined:

<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不知道哪个服务你的意思。

That is the cause of your problems - when connecting to net.tcp://127.0.0.1:8731/, WCF doesn't know which service you mean.

该基址必须在它的架构UNIQUE(如HTTP,等的net.tcp。)

The base address must be UNIQUE within its "schema" (e.g. http, net.tcp etc.)

马克·

编辑:如果您希望能够检索使用浏览器和导航到一个URL来得到它的元数据,你需要激活&LT; serviceMetadata httpGetEnabled =真/&GT ; 在服务的行为选择。否则,你将只能得到在使用超过一个的net.tcp SOAP调用你的元数据 - 如:使用WcfTestClient.exe应用程序,它是在你的Visual Studio 9 / Common7 / IDE文件夹。

if you want to be able to retrieve your metadata using the browser and navigating to a URL to get it, you'll need to activate the <serviceMetadata httpGetEnabled="True"/> in your service behavior option. Otherwise, you'll only be able to get at your metadata using a SOAP call over net.tcp - e.g. using the "WcfTestClient.exe" app which is in your Visual Studio 9/Common7/IDE folder.

编辑2:您已经定义了一些额外的绑定和行为的墨西哥,但因为没有你的MEX终结点实际上是引用任何这些设置,他们没有被使用

EDIT 2: you have defined a number of extra bindings and behaviors for MEX, but since none of your mex endpoints is actually referencing any of those settings, they're not being used.

这篇关于net.tcp绑定的元数据问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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