1

I have a third-party Java web service listening at three SOAP 1.1 WSDL endpoints. One of the endpoints is used to initiate the session and perform some high-level tasks, and the other endpoints are for subject-specific tasks reusing that initial authentication.

I'm building a C# WCF application to talk to the service, and I'd like to share the session cookie among the three client objects.

What's the VS2010 'best practices' way of sharing this cookie?

If this article is still the best answer, I can go with it, but I would appreciate some additional feedback, especially if .NET 4 introduced a simplification that I'm not finding on-line. http://megakemp.wordpress.com/2009/02/06/managing-shared-cookies-in-wcf/

I can pretty easily create the first client and retain the session (new BasicHttpBinding myBinding; myBinding.AllowCookies = true), but I couldn't find an elegant way of saving off the cookie from the Connect response and reusing for the two auxiliary clients.

Any insights are appreciated.

I should note that I'm aware of CookieContainer and using Add Web Reference instead of Add Service Reference. That method is labeled as 'legacy' in most posts I've read, and I'd prefer to stay current...or as current as possible when working with SOAP 1.1.

4

1 回答 1

0

提到的文章仍然有效。您必须使用 OperationContextScope 并访问消息属性来获取协议特定的数据。这种复杂性是基于这样一个事实,即 WCF 体系结构独立于协议,而 ASMX 体系结构依赖于 HTTP 协议。

确实 ASMX (WebReference) 是遗留技术,但它仍然存在于 .NET 框架中,所以如果您知道在没有任何高级 WS-* 标准的情况下您将不再需要基本的 SOAP 消息传递,您仍然可以使用它并制作您的生活有点简单。一旦你需要更多的东西,你仍然可以重构你的代码并使用 WCF 和提到的代码来处理 cookie。

于 2011-08-21T11:09:15.510 回答