Sending cookies to an XML web service?

D

Darren

I have a Win32 C# .NET client, accessing a web service (that I wrote),
which in turn accesses another (3rd party) web service.

Client -> My Web Service -> 3rd party web service

The 3rd party web service requires a particular cookie, so I want to
create it in the client and pass it on through, but I'm seeing weird
behaviour.

Client code:

Uri aUri = new Uri("http://someserver);
Cookie aCookie = new Cookie( "MyCookie", "abc123".Text, "/",
aUri.Authority);
wrapper.CookieContainer = new CookieContainer();
wrapper.CookieContainer.Add(aCookie);

At this point, the CookieContainer has 1 cookie as shown in the
debugger.

Inside the web service, though, when I walk the cookie collection I
see the same cookie, twice!

foreach ( string aCookie in
System.Web.HttpContext.Current.Request.Cookies)
-> 2 iterations with same cookie name

I also tried iterating using the correct cookie object but got casting
exceptions:

foreach(System.Web.HttpCookie aCookie in
System.Web.HttpContext.Current.Request.Cookies)

Am I doing the right thing, using a System.Net.Cookie on the client
side, then retrieving said cookie with System.Web.HttpCookie? Even
after reading the explanations I'm still hazy on the distinction
between these two types of cookies.

Any idea what's going on? I'm using Visual Studio 2003 and .NET
Framework 1.1, client and server both running local under Win XP, SP1.
Thanks for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top