我有一个服务有两个合同,我想用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中的服务)加注星标,但问题仍未解决。
我尝试禁用防火墙,但这不能解决问题。
感谢。
编辑:
我运行服务时使用follwing命令:
netstat -ona || find "6000"
我收到以下信息:
TCP 0.0.0.0:6000 0.0.0.0 LISTENING 2690
所以我认为por是开放和倾听的。
答案 0 :(得分:2)
我认为您已经以错误的方式定义了服务端点的收件人。 只要启用端口共享,就不必为每个tcp地址使用不同的端口。 这是通过使用Net.TCP端口共享服务实现的,该服务可在任何.NET 3.0安装中使用。默认情况下,该服务未启用,因此您必须自己启用它。与如何启用Net.TCP POrt共享服务相关,请检查以下链接:http://msdn.microsoft.com/en-us/library/ms733925.aspx。