3

我创建了一个非常简单的 WCF 服务,托管在 Windows 服务上,紧跟 MSDN 上的示例:http: //msdn.microsoft.com/en-us/library/ff649818.aspx

如果我在第一次呼叫后超过 10 分钟对我的服务进行第二次呼叫,我将收到不活动超时错误。我了解这是 WCF 客户端的默认设置。

但是,当我改变我的 app.config 从

 <reliableSession ordered="true" inactivityTimeout="00:10:00"
                   enabled="false" />

 <reliableSession ordered="true" inactivityTimeout="infinite"
                    enabled="true" />

当我尝试拨打电话时出现此错误:

由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action 'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。

这就是我的 WCF 配置文件在 Windows 服务上的样子。

  <system.serviceModel>
<services>
  <service name="Asis.IBSS.Milestone.WCFService.ServiceImplementation.VideoService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="Asis.IBSS.Milestone.WCFService.ServiceContract.IVideoService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8555/MilestoneService"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我的问题是,如何将 inactivityTimeout 设置为 inifinte,并规避我遇到的错误?

4

1 回答 1

4

我认为您还需要将绑定上的 receiveTimeout 设置为无限。这两个属性,receiveTimeout 和 inactivityTimeout 相互之间有一些依赖关系,如果你将 inactivityTimeout 设置为比 receiveTimeout 更高的值,你可能会得到一些错误。

例如:

        <bindings>
        <wsFederationHttpBinding>
    <binding name="someServiceFederatedBinding" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
        </wsFederationHttpBinding>
    </bindings>

并将 bindingConfiguration="someServiceFederatedBinding" 放入您的服务中。

于 2012-08-14T07:00:41.513 回答