Setting Cookies/SOAP Headers???
Can anyone give me an example of how I can go about getting/setting
HTTP cookies from a SOAP::Lite call to a service? Creating/getting
SOAP headers from an envelope would be useful. Any example code for
this? I've been through the perldoc as well as several online
references, but just can't seem to get the syntax right.
Any help will be much appreciated.
- Hi, Brian!
--- Brian Skrab <bgs@...> wrote:
> Can anyone give me an example of how I can go aboutI don't have ready-to-use example in my hands, but something like
> HTTP cookies from a SOAP::Lite call to a service?
this should work:
my $cookies = HTTP::Cookies->new(ignore_discard => 1);
# you may also add 'file' if you want to keep them between sessions
my $soap = SOAP::Lite
Cookie will be taken from response and provided for request. You may
always add another cookie (or extract what you need after response)
with HTTP::Cookies interface.
You may also do it in one line:
my $soap = SOAP::Lite
cookie_jar => HTTP::Cookies->new(ignore_discard => 1));
Actually proxy will accept ANY parameters that LWP::UserAgent has.
See PROXY SETTINGS (in HTTP.pm) for example of this interface. You
may get access to it thru $soap->transport object which represents
Transport side (depending on real transport). Same thing is true for
other protocols. Protocol/module specific parameters could be passed
as additional parameters for proxy or accessed with $soap->transport.
Thus you have access to almost all features of underlying modules.
> Creating/gettingYou may set headers with SOAP::Trace interface:
> SOAP headers from an envelope would be useful. Any example
use SOAP::Lite +trace =>
transport => \&sub_that_will_get_both_request_and_response;
If you want to update only request or response you may check with ref
or UNIVERSAL::isa($_ => 'HTTP::Request'). See SOAP::Trace section
in doc for information. Request will be passed BEFORE and response
AFTER processing, and since objects are passed by ref, all changes
will be effective.
However this interface has some disadvantages (it's global, so it'll
be effective for all you objects), so quite possible it'll be
replaced by OO interface. Still under design. Hope it helps.
Best wishes, Paul.
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/