2014-10-31 79 views
0

我正在使用以下配置來使我的服務有效,但對於每個請求wcf服務正在用新的會話ID響應我。爲什麼會這樣,我需要讓sessionful對於客戶端,以便爲每個請求應該有默認情況下,當通道被打開,你可以閱讀更多關於它在這裏發起會話相同的會話ID爲什麼在wsHttpBinding中每次都創建新會話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> 
+0

你有'SessionMode = SessionMode.Required'您ServiceContractAttribute的? – 2014-11-16 01:37:09

+0

它是sessionmode.allowed – funsukvangdu 2014-11-16 14:16:40

+0

將會話模式設置爲必需,因此在發生錯誤時拋出異常,修復所有內容後,可以將其更改爲允許。在您的問題中添加以下信息,調用您的服務的客戶端示例代碼,以及網絡配置,任何物理負載平衡機制,防火牆(基於硬件和軟件的模型)以及代理服務器。 – 2014-11-21 07:31:27

回答

0

Sessions in WCF

由於IsInitiating參數的默認值爲true,因此每次調用都會啓動一個新會話。瞭解更多關於在這裏IsInitiatingIsInitiating

所以在您的業務合同

[OperationContract(
    IsInitiating=false, 
    IsTerminating=false 
)] 
    public void MethodOne() 
    { 
    return; 
    } 
相關問題