使用nettcp绑定访问WCF时出现问题

时间:2012-04-09 03:53:57

标签: wcf nettcpbinding

我使用NetTCP绑定创建了WCF。安全模式设置为“无”

当我在与主机相同的机器上测试此服务时,我没有任何问题。我能够访问这些操作。 (我使用wcfTestclient测试过。)

但是在另一台机器上,我可以毫无问题地添加服务,但是当我调用一个操作时,我收到以下错误:

  

服务器堆栈跟踪:at   System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()   在System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan   System.ServiceModel.Channels.ServiceChannel.Call(String。)   action,Boolean oneway,ProxyOperationRuntime操作,Object [] ins,   对象[]出局,TimeSpan超时)at   System.ServiceModel.Channels.ServiceChannel.Call(String action,   Boolean oneway,ProxyOperationRuntime操作,Object [] ins,   对象[]出局)   System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage   methodCall,ProxyOperationRuntime operation)at   System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天   消息)

     

在[0]处重新抛出异常:at   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即时聊天   reqMsg,IMessage retMsg)at   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&安培;   msgData,Int32类型)at   SampleNetTcpClient.CalcService.ICalculatorService.Addition(Int32 a,   Int32 b)at   SampleNetTcpClient.CalcService.CalculatorServiceClient.Addition(的Int32   a,Int32 b)在D:\ Visual Studio中   2008 \项目\ SampleNetTcpClient \ SampleNetTcpClient \服务   参考文献\ CalcService \ Reference.cs:第53行

编辑:添加了配置文件

服务器配置

 <services>
  <service name="CalculatorNetTcp.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://10.1.3.199:8001/CalculatorNetTcp" />
      </baseAddresses>
    </host>
    <endpoint address=""
           binding="netTcpBinding"
           bindingConfiguration="BindingConfiguration"
           contract="CalculatorNetTcp.ICalculatorService" />

    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />

  </service>
</services>
<bindings>
  <netTcpBinding>
    <binding name="BindingConfiguration" receiveTimeout="10:00:00"
      sendTimeout="10:00:00" maxBufferSize="65536" maxReceivedMessageSize="65536"
      transferMode="Streamed">
      <readerQuotas maxDepth="65536" maxStringContentLength="65536"
        maxArrayLength="65536" maxBytesPerRead="97108864" maxNameTableCharCount="65536" />
      <security mode="None">
        **<transport protectionLevel="None"/>
      </security>
      </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpGetEnabled="False"/>
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>**

以下是客户端上的配置

 <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_ICalculatorService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                  <security mode="None">
                    <transport protectionLevel="None"/>
                  </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://10.1.3.199:8001/CalculatorNetTcp"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ICalculatorService"
                contract="CalcService.ICalculatorService" name="NetTcpBinding_ICalculatorService">               
            </endpoint>
        </client>
    </system.serviceModel>

0 个答案:

没有答案