ColdFusion 和 .Net 会话

ColdFusion and .Net sessions

Web 应用程序通常有一个 client-side 和 server-side,而在我的特定场景中,我们有 client-side 和两个 server-side 技术使用 Web 服务来执行操作和提出要求。

虽然与根本问题无关,但进行此设置的原因仅仅是因为我们的 desktop-based 应用程序使用 .Net 而我们的 Web 应用程序使用 ColdFusion 并且我们已经正在慢慢地将服务器进程过渡到 .Net,使用 Web 服务作为执行这些操作的手段,因此无疑会在不久的将来更容易地切换到完整的 .Net 解决方案。

问题

问题是当我从 ColdFusion 调用 .Net Web 服务时,.Net 似乎没有保留超出 HTTP 请求的 session。

但是,如果我使用 Ajax 和 jQuery 调用同一个 Web 服务,则 session 将保留在单个 HTTP 请求之外。 (在我所有的页面上)

Web 服务在 Cold Fusion 的 Application.cfc 组件的 OnApplicationStart 函数中注册。 (注意:SoapHeader 实现 ws-security

<cfscript>
    objSoapHeader = XmlParse("<wsse:Security mustUnderstand=""true"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""><wsse:UsernameToken><wsse:Username>MY_USERNAME</wsse:Username><wsse:Password>MY_PASSWORD</wsse:Password></wsse:UsernameToken></wsse:Security>");
    Application.UserWebService = CreateObject("webservice","MY_URL/UserService.asmx?WSDL");
    addSOAPRequestHeader(Application.UserWebService,"","",objSoapHeader,true);
</cfscript>

当从 jQuery 调用相同的 Web 服务时,header 和 body 的结构如下:

var strSoapData = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Header><LanguageHeader xmlns='http://tempuri.org/'><Locale>en-CA</Locale></LanguageHeader></soap:Header><soap:Body>" + strData + "</soap:Body></soap:Envelope>";

为了在 .Net 中处理 ws-security,将以下代码放在 web.config 文件中:

<webServices>
    <soapExtensionImporterTypes>
        <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </soapExtensionImporterTypes>
    <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</webServices>

问题

经过数小时的研究和反复试验,我什至可以采取下一步行动来查明根本问题,即为什么我的 session 在调用 Web 服务时在 .Net 中丢失冷聚变?

编辑

经过更多的研究,我相信 Cold Fusion 没有保留 ASP.NET_SessionId cookie,也许是所有的 cookie。我将尝试 cookie-less 方法并更新我的发现。

解决方案就像在网络服务上启用 cookie 一样简单。

Application.UserWebService.setMaintainSession(true);