0

我有一项服务,其中包含两个要与 tcp 绑定一起使用的合同。服务配置文件是这样的:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="ServiceDocumentos" transferMode="Streamed"
                 maxBufferSize="67108864"
                      maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
                   closeTimeout="00:00:10"
                       openTimeout="00:00:10" receiveTimeout="00:20:00"
                       sendTimeout="00:01:00" maxConnections="100"/>
        <binding name="ServiceCore" transferMode="Buffered"
                 maxBufferSize="67108864"
                      maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
                   closeTimeout="00:00:10"
                       openTimeout="00:00:10" receiveTimeout="00:20:00"
                       sendTimeout="00:01:00" maxConnections="100"/>
      </netTcpBinding>

      <basicHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom" transferMode="Streamed"  />
        <binding name="ServiceCore" messageEncoding="Mtom" transferMode="Buffered" />
      </basicHttpBinding>

      <wsDualHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom"/>
        <binding name="ServiceCore" messageEncoding="Mtom"/>
      </wsDualHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="CMMSService" name="GTS.CMMS.Service.Service">
        <endpoint binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
                 name="ServiceDocumentos" contract="GTS.CMMS.Service.IServiceDocumentos"
         address="ServiceDocumentos/">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address ="net.tcp://localhost:6000/CMMSService/ServiceCore/"
                 binding="netTcpBinding" bindingConfiguration="ServiceCore"
                 name="ServiceCore" contract="GTS.CMMS.Service.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
                 listenUriMode="Explicit">
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8500/CMMSService" />
            <add baseAddress="net.tcp://localhost:8501/CMMSService" />
          </baseAddresses>
        </host>


      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CMMSService">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

客户端配置文件为:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="ServiceDocumentos" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="3670016" maxBufferPoolSize="524288" maxReceivedMessageSize="3670016"
         transferMode="Streamed">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
        <binding name="ServiceCore" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
         transferMode="Buffered">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </netTcpBinding>

      <basicHttpBinding>
        <binding name="ServiceDocumentos" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="3670016" maxBufferPoolSize="524288" maxReceivedMessageSize="3670016"
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
        <binding name="ServiceCore" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
             realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

      <wsDualHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom"/>
        <binding name="ServiceCore" messageEncoding="Mtom"/>
      </wsDualHttpBinding>
    </bindings>

    <client>
      <!--<endpoint address="net.tcp://localhost:8501/CMMSService/ServiceDocumentos/"
       binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
       contract="IServiceDocumentos" name="ServiceDocumentos" />
      <endpoint address="net.tcp://localhost:8501/CMMSService/ServiceCore/"
       binding="netTcpBinding" bindingConfiguration="ServiceCore"
       contract="IService" name="ServiceCore" />-->

      <endpoint address="net.tcp://localhost:8501/CMMSService/ServiceDocumentos/"
       binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
       contract="IServiceDocumentos" name="ServiceDocumentos" />
      <endpoint address="net.tcp://localhost:6000/CMMSService/ServiceCore/"
       binding="netTcpBinding" bindingConfiguration="ServiceCore"
       contract="IService" name="ServiceCore" />
    </client>
  </system.serviceModel>

我正在使用不同的绑定进行测试。例如,如果对于一个合同,IServiceDocumentos 我使用 tcp,而对于另一个合同,我使用 wsDualHttpBinding 的主合同,一切正常。我可以使用这两个合同。

如果我对这两个合约使用 tcp,那么我会收到错误 tcp 10061。

我尝试为每个合同使用单独的完整地址,因为我猜问题可能是使用相同的端口,但问题仍然存在。但是,如果我为每个端点使用一个完整的单独地址,那么如果我使用不同的绑定就可以了。

另外我尝试启动服务 tcp 端口共享(Windows XP 中的服务),但问题没有解决。

我尝试禁用防火墙,但这并不能解决问题。

谢谢。

编辑:

当我运行服务时,我使用以下命令:

netstat -ona || find "6000"

我得到以下信息:

TCP 0.0.0.0:6000 0.0.0.0 监听 2690

所以我认为 por 已打开并正在聆听。

4

1 回答 1

2

我认为您以错误的方式定义了服务端点的收件人。只要启用端口共享,就不必为每个 tcp 地址使用不同的端口。这是通过使用任何 .NET 3.0 安装上可用的 Net.TCP 端口共享服务来实现的。默认情况下,该服务未启用,因此您必须自己启用它。有关如何启用 Net.TCP 端口共享服务,请查看以下链接:http: //msdn.microsoft.com/en-us/library/ms733925.aspx

于 2012-06-28T11:11:44.700 回答