[Xml-compile] Custom SOAP11 header

Mark Overmeer mark at overmeer.net
Mon Nov 1 15:33:11 GMT 2010


* Kaare Rasmussen (kaare at jasonic.dk) [101101 15:53]:
> I have to access a service with authentication. Authentication is performed 
> using a custom SOAP header. The header is named AuthHeader and contain two 
> elements, UserName and Password.

Do you have a schema for it? 

> The documentation leads me to believe I should be able to do something like 
> this:
>    my $authHeader = {UserName => 'user', Password => 'password' };
> 
> But XML::Compile::SOAP11 expects something else. Can I somehow tell 
> compileClient to use a customer SOAP header, is it compileMessage for each 
> call, or what am I missing?

Nothing happens without a clear definition or a hook.

One way to get it to work is hooking SOAP-ENV:Envelope or
SOAP:-ENV:Header, with an "after" callback which adds the fields
to the XML "by hand".

The cleanest way is demonstration by XML::Compile::SOAP::WSA.
soap11OperationInit() is called when an operation is defined. You
can add headers at that moment. Still a schema is needed (but
probably quite small)  ::WSA is considerable more difficult than
you need.

You may also extend/wrap the client or transporter. Hard to maintain
hacks...

You may also modify your WSDL to list these header fields. Of course,
the only correct solution, but often not feasable.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list