Loading ...
Sorry, an error occurred while loading the content.

Passing parameters in header

Expand Messages
  • adrian@cheerful.com
    Hi, I am wondering if it is possible to pass and receive parameters in the header section of the soap envelope using Soap::lite? If so, can someone post an
    Message 1 of 2 , May 29 3:16 PM
    • 0 Attachment
      Hi,


      I am wondering if it is possible to pass and receive parameters in
      the header section of the soap envelope using Soap::lite? If so, can
      someone post an example? Thanks,

      Adrian
    • Paul Kulchenko
      Hi, Adrian! ... If you use SOAP::Header instead of SOAP::Data and pass it as a parameter it ll be inserted as a header. Exactly the same can be done on server
      Message 2 of 2 , May 29 4:23 PM
      • 0 Attachment
        Hi, Adrian!

        --- adrian@... wrote:
        > I am wondering if it is possible to pass and receive parameters in
        > the header section of the soap envelope using Soap::lite? If so,
        If you use SOAP::Header instead of SOAP::Data and pass it as a
        parameter it'll be inserted as a header. Exactly the same can be done
        on server side when return values.

        > can someone post an example? Thanks,
        Extract from SOAP/Test.pm

        print "Header manipulation test(s)...\n";

        # send and return headers
        $a = $s->addheader(2, SOAP::Header->name(my => 123));
        ok(ref $a->header && $a->header->{my} eq '123123');
        ok($a->headers eq '123123');

        print "mustUnderstand test(s)...\n";
        $s->echo(SOAP::Header->name(somethingelse => 123)
        ->mustUnderstand(1));
        ok($s->call->faultstring =~ /Header has mustUnderstand attribute/);

        $s->echo(SOAP::Header->name(somethingelse => 123)
        ->mustUnderstand(1)
        ->actor('http://notme/'));
        ok(!defined $s->call->fault);

        To get access to headers on client or server side you can use
        header() or headers() methods of SOAP::SOM object (as in the first
        example). More information is in documentation for SOAP::SOM.

        Example how to access/return headers on server side (from
        examples/My/Parameters.pm):

        sub addheader {
        my $self = shift;
        my $param1 = shift;
        my $header = pop->headerof(SOAP::SOM::headers);
        return $param1, $header->value($header->value x 2);
        }

        hope it helps. Let me know if you still have any questions.

        Best wishes, Paul.

        __________________________________________________
        Do You Yahoo!?
        Yahoo! Auctions - buy the things you want at great prices
        http://auctions.yahoo.com/
      Your message has been successfully submitted and would be delivered to recipients shortly.