【问题标题】:ColdFusion and .Net sessionsColdFusion 和 .Net 会话
【发布时间】:2016-09-15 15:14:27
【问题描述】:

Web 应用程序通常具有客户端和服务器端,而在我的特定场景中,我们有客户端和两种使用 Web 服务执行操作和发出请求的服务器端技术。

虽然与根本问题无关,但这种设置的原因仅仅是因为我们基于桌面的应用程序使用 .Net,而我们的 Web 应用程序使用 ColdFusion,并且我们一直在缓慢地转换服务器进程到 .Net,使用 Web 服务作为执行这些操作的一种手段,从而无疑在不久的将来更容易切换到完整的 .Net 解决方案。

问题

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

但是,如果我使用 Ajax 和 jQuery 调用相同的 Web 服务,会话将在单个 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>

问题

经过数小时的研究和反复试验,我什至可以采取什么下一步措施来查明在从 Cold Fusion 调用 Web 服务时为什么我的会话在 .Net 中丢失的根本问题?

编辑

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

【问题讨论】:

    标签: .net web-services soap coldfusion ws-security


    【解决方案1】:

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

    Application.UserWebService.setMaintainSession(true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多