0

我正在使用以下配置使我的服务具有会话性,但是对于每个请求,wcf 服务都会使用新的会话 ID 响应我。为什么会这样,我需要让它为该客户端会话,以便每个请求都应该有相同的会话 ID

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttp">
          <readerQuotas maxStringContentLength="10240" />
          <reliableSession enabled="true" />          
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>                  
      <service name="wcfservice.serviceclass" behaviorConfiguration="MyFileServiceBehavior">

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:51/"/>
            <add baseAddress="net.tcp://localhost:52/"/>
          </baseAddresses>          
        </host>
        <endpoint address="pqr" binding="wsHttpBinding" bindingConfiguration="wsHttp"
          name="b" contract="wcfservice.Iservice" />
        <endpoint address="pqr" binding="netTcpBinding" 
          name="c" contract="wcfservice.Iservice" />      
      </service>
    </services>   
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyFileServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />              
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>
4

1 回答 1

0

默认情况下,当通道打开时会启动一个会话,您可以在此WCF 中的会话中阅读有关它的更多信息

因为 IsInitiating 参数的默认值为 true,您的每个调用都会启动一个新会话。在此处阅读有关它的更多信息IsInitiatingIsInitiating

所以在你的运营合同中

[OperationContract(
    IsInitiating=false,
    IsTerminating=false
  )]
  public void MethodOne()
  {
    return;
  }
于 2014-11-22T05:18:35.607 回答