[Xml-compile] XML::Compile::SOAP::Daemon access to SOAP Header content

Lars Thegler lars at thegler.dk
Wed Sep 15 13:06:49 GMT 2010


On Wed, Sep 15, 2010 at 10:01 AM, Mark Overmeer <mark at overmeer.net> wrote:
> * Lars Thegler (lars at thegler.dk) [100915 07:24]:
>> I'm writing a SOAP service based on XML::Compile::SOAP::Daemon and a
>> WSDL specification [1], which has some authentication information in a
>> SOAP Header element.
>>
>> I'm setting up callbacks with $deamon->operationsFromWSDL($wsdl,
>> callbacks => ...); but the callback is only receiving the SOAP Body
>> content.
>>
>> How can I access the content received in the SOAP Header?
>
> The SOAP messages are decoded into a HASH. Each body element can be
> found back under the part-name as used in the WSDL. This also counts
> for header elements which are defined in the WSDL... However... often
> header elements are added without being described in the WSDL... and
> those are simply ignored (unless the mustUnderstand flag is set)

The authentication message sent in the SOAP Header _is_ defined in the
WSDL. And the client is setting mustUnderstand="1".

> For WS-addressing, you can simply load the XML::Compile::SOAP::WSA
> module, and it will add knowledge about those headers. The same
> concept can be used to support other XML standards. There are a lot
> of those standards. Which one do you need?

I don't think there is a standard for this. It's a simple custom
authentication, just sending a username/password pair inside the SOAP
Header. A bit like HTTP Basic authentication, but without the
challenge:

<SOAP-ENV:Header>
  <s:AuthenticationInfo xmlns:s="urn:RTCBT" SOAP-ENV:mustUnderstand="1">
    <s:username>nnn</s:username>
    <s:password>ppp</s:password>
  </s:AuthenticationInfo>
</SOAP-ENV:Header>

> Another approach could be to change the SOAP decoding a little, to
> return the header element under its name as XML::LibXML node when it
> is not understood... probably a simple change in XML::Compile::SOAP.
> Something like
>
>  sub _reader_hook($$)
>  {   my ($self, $type, $do) = @_;
>  ...
>  -          else
>  -          {   trace __x"node {type} ignored, expect from {has}",
>  -                  type => $type, has => [sort keys %trans];
>  -          }
>  +          else
>  +          {   $h{$type} = $child;
>  +          }

Ok, but how can I access this information from inside the callback handler?

>               MarkOv

/Lars



More information about the Xml-compile mailing list