当我调用服务GetSessionId()时,会话id将获得空值。请帮我解决这个问题。
public Response<string> GetSessionId()
{
Response<string> respn = new Response<string>();
respn.Succeeded = false;
try
{
_sessionId = OperationContext.Current.SessionId;
respn.ReturnData = _sessionId;
respn.Succeeded = true;
}
catch (Exception ex)
{
respn.Succeeded = false;
respn.ErrorMsg = ex.Message;
}
return respn;
}在Web.Config文件中,如果我设置为mode="Message“和clientCredentialType="Windows”,在这种情况下,它将得到会话id.But,我不能使用任何安全性。
<wsHttpBinding>
<binding name="SOAPService_EndpointBinding"
maxReceivedMessageSize="2147483647"
openTimeout="00:02:00"
closeTimeout="00:02:00"
sendTimeout="24:00:00"
receiveTimeout="24:00:00">
<security mode="None">
<message clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>发布于 2016-06-08 04:50:57
解决办法如下,
契约接口中的,将SessionMode属性设置为必需的
ServiceContract(SessionMode = SessionMode.Required)
在配置文件中启用了reliableSession
<wsHttpBinding>
<binding name="SOAPService_EndpointBinding"
maxReceivedMessageSize="2147483647"
openTimeout="00:02:00"
closeTimeout="00:02:00"
sendTimeout="24:00:00"
receiveTimeout="24:00:00">
<security mode="None">
<message clientCredentialType="None"/>
</security>
<reliableSession enabled="true"/>
</binding>
</wsHttpBinding>发布于 2016-06-07 09:26:44
您正在使用的绑定是什么?会话支持以下绑定
https://stackoverflow.com/questions/37653299
复制相似问题