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 );



...

...


# Transport hook for complieClient to add to http headers

# for the basic http authentication

#

# HTTP basic authentication encodes the username and password

# with Base64. The encoded source string is in the format:

#

# "username:password"

#

# With the below HTTP header being required:

#

# "Authorization: Basic [encoded password]"

#

sub transport_hook($$)

{

    my ($request, $trace) = @_;

    my $content = $request->content;



    my $user = 'myuserid' ;

    my $password = 'mypassword';



    # Encode userid and password

    my $authorization = 'Basic '.encode_base64( "$user:$password" );



    print "Authorization: $authorization";



    # Modify http header to include basic authorisation

    #

    $request->header(Authorization => $authorization );



    my $ua = $trace->{user_agent};

    my $response = $ua->request($request);



    # ... check the response headers

    $response->header('Authorization');



    # ... use the response content

    my $received = $response->decoded_content || $response->content;



    $response;

}


On Wed, Dec 4, 2013 at 12:24 PM, Mark Overmeer <[email protected]>wrote:

> * Kieron Johnson ([email protected]) [131204 11:49]:
> > I'm struggling to see how to perform basic authorisation on a Soap call
> > with xml compile. I've looked at WSS thinking basic authentication was
> the
> > same thing and it seems it isn't.
>
> SOAP has its own way of point-to-point basic authentication, see
> XML::Compile::WSS::BasicAuth.  That info is inside the XML message.
> SOAP is not limited to HTTP...
>
> To play with HTTP headers, you need to use the transport_hook.
> Read the DETAILS in XML::Compile::Transport
> --
> Regards,
>                MarkOv
>
> ------------------------------------------------------------------------
>        Mark Overmeer MSc                                MARKOV Solutions
>        [email protected]                          [email protected]
> http://Mark.Overmeer.net                   http://solutions.overmeer.net
>
>
_______________________________________________
Xml-compile mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile

Reply via email to