[Fedora-suds-list] Cookie Question

Jeff Ortel jortel at redhat.com
Mon Jan 5 20:45:39 UTC 2009


Marc,

Hmm.... I'm not sure what to tell you.  I'll forward to the list and 
hope that someone that has experience using cookielib can help.

Anyone?

Jeff

Marc Belmont wrote:
> Hi, I am still trying to figure out how the cookies are working, here is 
> the code I use:
> 
> from suds.client import Client, SoapClient
> url = "http://demo.gostai.com/WSDL001HHDIZMAKS787F2AHGHFD2DFF/rcweb.wsdl"
> client = Client(url)
> client.service.userAuthenticate("marcbelmont at gmail.com 
> <mailto:marcbelmont at gmail.com>", "testpass")
> print client.options.transport.cookiejar
> 
> The cookie jar is empty.
> 
> With the php code, I have cookies.
> 
> $address = 
> "http://demo.gostai.com/WSDL001HHDIZMAKS787F2AHGHFD2DFF/rcweb.wsdl";
> $client = new SoapClient($address);
> $client->userAuthenticate(array('login'    => "marcbelmont at gmail.com 
> <mailto:marcbelmont at gmail.com>",
>                 'password'    => "testpass"));
> print_r($client->_cookies);
> 
> Happy new year! Marc
> 
> On Fri, Dec 19, 2008 at 10:58 AM, Marc Belmont <contact at marcbelmont.com 
> <mailto:contact at marcbelmont.com>> wrote:
> 
>     Thanks for the code, I will test my stuff more and I will let you
>     know if I manage to make it work.
> 
>     Bye, Marc
> 
> 
>     On Thu, Dec 18, 2008 at 5:03 PM, Jeff Ortel <jortel at redhat.com
>     <mailto:jortel at redhat.com>> wrote:
> 
>         Marc,
> 
>         Glad to help.
> 
>         Cookies should be working but it hasn't been tested in several
>         releases.  I don't have a server that uses cookies so it's hard
>         for me to regression test this.
> 
>         The cookiejar is adding cookies to the urllib2 request and
>         extracting cookies from the urllib2 response as follows:
> 
>            def send(self, request):
>                result = None
>                url = request.url
>                msg = str(request.message)
>                headers = request.headers
>                log.debug('sending to (%s)\nmessage:\n%s', url, msg)
>                try:
>                    u2request = u2.Request(url, msg, headers)
>                    self.__addcookies(u2request)
>                    self.__setproxy(url, u2request)
>                    fp = self.__open(u2request)
>                    self.__getcookies(fp, u2request)
>                    result = fp.read()
>                except u2.HTTPError, e:
>                    if e.code in (202,204):
>                        result = None
>                    else:
>                        raise TransportError(e.msg, e.code, e.fp)
>                return result
> 
>            def __addcookies(self, u2request):
>                self.cookiejar.add_cookie_header(u2request)
> 
>            def __getcookies(self, fp, u2request):
>                self.cookiejar.extract_cookies(fp, u2request)
> 
>         When you walk through this with the debugger, do you not see the
>         cookies you're expecting?
> 
>         What makes you think it's not working?
> 
>         Regards,
> 
>         Jeff
> 
>         Marc Belmont wrote:
> 
>             Hi, thanks for the quick update. The cookiejar is always
>             empty. Has this feature been tested ?
> 
>             Thanks, Marc
> 
>             On Thu, Dec 18, 2008 at 3:03 PM, Jeff Ortel
>             <jortel at redhat.com <mailto:jortel at redhat.com>
>             <mailto:jortel at redhat.com <mailto:jortel at redhat.com>>> wrote:
> 
>                Hey Marc,
> 
>                Thanks for your interest in suds.
> 
>                I'm assuming you're using 0.3.3
> 
>                The best way to do this is to get the (cookielib) cookie
>             jar from
>                the transport.  You should be able to do something like this:
> 
>                 >
>                 > client = Client(url)
>                 > cj = client.options.transport.cookiejar
>                 >
> 
>                Now that you have the cookie jar, you can do what you
>             want with the
>                cookies.
> 
>                Hope this helps,
> 
>                Jeff
> 
> 
>                Marc Belmont wrote:
> 
>                    Hi,
> 
>                    Is it possible to get the cookie returned by a soap
>             call. Example :
>                    client = Client(url)
>                    res = client.service.mymethod()
>                    res.getcookies() # that's what I'm trying to do
> 
>                    I also need to set the cookie before a soap call and
>             I don't
>                    know how to do that.
> 
>                    Have a nice day. Bye
> 
> 
> 
> 




More information about the fedora-suds-list mailing list