Question

I have to extend an established web application which is using SOAP::WSDL to communicate with external SOAP servers. To get use of a new SOAP method I have to extend the application to handle cookies over the user session in the web application.

I like to use HTTP::CookieJar::LWP as cookie jar for LWP::UserAgent but I don't find any hints on how to replace the non(-persistent)-cookie-aware LWP from SOAP::WSDL with my own one which loads/stores SOAP cookies from/into the web application session. How to replace LWP handle from SOAP::WSDL?

Was it helpful?

Solution

I don't think you need to change the complete LWP. I don't even think you can, as SOAP::WSDL's client is a SOAP::Transport::HTTP::Client that comes with SOAP::Lite. This in turn is a subclass of LWP::UserAgent and inherits its methods, but it also adds more stuff which you need.

So what you need to do is set the client's cookie jar to the one you want. The interface of the client is still the one from LWP::UserAgent, so your HTTP::CookieJar::LWP should be fine.

You can get to the client with the $interface->get_transport() method. Once you have that, you can use LWP::UserAgent's $ua->cookie_jar( $cookie_jar_obj ) method.

$interface->get_transport->cookie_jar(HTTP::CookieJar::LWP->new);

I believe that's all you need to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top