[Xml-compile] Custom SOAP11 header

Mark Overmeer mark at overmeer.net
Mon Nov 1 16:01:30 GMT 2010


* Mark Overmeer (mark at overmeer.net) [101101 16:33]:
> * 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.

I have just started XML::Compile::SOAP::FAQ, because your question
is quite common. This is the text for this subject:

=head3 add header fields

Although WSDLs offer a nice way to define header-fields explicitly, quite
a number of applications require fields which are not described. Also
some W3C standards play this game.  See M<XML::Compile::SOAP::WSA>
for a complex example. A simple example follows here.

  use warnings;
  use strict;

  package XML::Compile::SOAP::MYEXT;
  use base 'XML::Compile::SOAP::Extension';

  use Log::Report;
  use XML::Compile::SOAP::Util      qw/WSDL11/;
  use XML::Compile::Util            qw/pack_type/;

  my $my_ns = 'http://..../';
  my $my_schema_fie = 'aaa.xsd';

  sub wsdl11Init($@)
  {   my ($self, $wsdl, $args) = @_;
      $wsdl->prefixes(myprefix => $my_ns);
      $wsdl->importDefinitions($my_schema_file);
      $self;
  }

  sub soap11Operation$$)
  {   my ($self, $op, $args) = @_;
      # towards the server
      $op->addHeader(INPUT
        => "myprefix_$fieldname" => "{$my_ns}$fieldtype");

      # in server answers
      $op->addHeader(OUTPUT => ...);
  }

With C<soap11ClientWrapper()> and C<soap11HandlerWrapper()>
you can influence the client respectively server processing, for
instance to fill-in default values.
-- 
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