[Xml-compile] Basic authorisation
rahed
raherh at gmail.com
Mon Dec 9 14:03:43 GMT 2013
Kieron Johnson <ao7one at gmail.com> writes:
> Thanks Mark. I couldn't see that in the docs though it's quite clearly
> documented! Did noticed the docs say to use "hook =>" but it looks
> like it
> should be "transport_hook =>"
>
> I achieved what I wanted with below code. Very straightforward thanks.
>
> # Compile request method from WSDL
>
> # Hook in sub for Authorization header
>
> my $call = $wsdl->compileClient( $method, transport_hook =>
> \&transport_hook );
For basic authorization I use:
$authoriz = 'Basic'.encode_base64('user:password');
$ua = LWP::UserAgent->new(timeout => 'mytout');
$ua = default_header(Authorization => $authoriz);
$trans = XML::Compile::Transport::SOAPHTTP->new(address =>
'myaddress',user_agent => $ua);
or
$authoriz = 'Basic'.encode_base64('user:password');
$trans = XML::Compile::Transport::SOAPHTTP->new(address => 'myaddress');
$ua = $trans->userAgent();
$ua->default_header(Authorization => $authoriz);
--
Radek
More information about the Xml-compile
mailing list