Sending cookies to an XML web service?

Discussion in 'ASP .Net Web Services' started by Darren, Sep 5, 2003.

  1. Darren

    Darren Guest

    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.
    Darren, Sep 5, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    670
  2. Digital Puer
    Replies:
    1
    Views:
    835
    Dag Sunde
    Jun 1, 2006
  3. _Who
    Replies:
    7
    Views:
    2,630
  4. Hidura
    Replies:
    6
    Views:
    1,082
    John Nagle
    Dec 22, 2010
  5. Jon

    sending an xml file over a web service

    Jon, Nov 17, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    635
    John Saunders
    Nov 18, 2006
Loading...

Share This Page