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

Re: SOAP::Header

Expand Messages
  • teden
    Embedding a SOAP::Header is relatively simple using the call interface. My call looks like this: my $invoke = SOAP::Data- name( MI:invoke )- attr( { xmlns:MI
    Message 1 of 2 , Feb 16, 2006
      Embedding a SOAP::Header is relatively simple using the call
      interface. My call looks like this:

      my $invoke = SOAP::Data->name("MI:invoke")->attr( { "xmlns:MI" =>
      "..." } );

      my $LocalContext = ...blah-blah...

      my $lpres = SOAP::Lite
      ->outputxml( "1" )
      ->proxy( "

      http://x.y.com",

      timeout => 600 )
      ->uri( "MI:..." )
      ->call( $invoke
      => SOAP::Data->type( "xml" )->value( $parm )
      => SOAP::Header->name( "LocalContext" => $LocalContext )->type( "xml" )
      );

      Thom Eden


      --- In soaplite@yahoogroups.com, "klefevre.geo" <klefevre.geo@...> wrote:
      >
      > I've successfully used SOAP::Lite with services that take credentials
      > embedded in the URL and that don't need credentials. I now need to
      > communicate with a service that requires credentials to be in the
      > header of the SOAP message.
      >
      > I'm creating a custom header using the statement SOAP::Header->type
      > ('xml' => $headerXML);. I can dump the returned object and see that
      > the hash looks proper.
      >
      > My problem is that I can't figure out how to get SOAP::Lite to
      > recognize this header (I've turned on debugging so I can see the SOAP
      > transaction that is passed to the server.
      >
      > I thought that simply creating a header would include it in the
      > internal object so that it would be included, but apparently not.
      >
      > Any suggestions or pointers would be greatly appreciated.
      >
      > Here's the code I'm using:
      > *********************************************************************
      > no strict;
      > $VERSION = 1.00;
      >
      >
      > use SOAP::Lite +trace => [qw(all)];
      >
      > use strict;
      > use Data::Dumper;
      >
      > _takeReading();
      >
      > # Perform a reading of the monitored object.
      > sub _takeReading()
      > {
      > my $URL = 'http://ohio.cardinal.verisignepctest.com:443/e-
      > pedigree/E-PedigreeService';
      >
      > my $soap = SOAP::Lite->new();
      > $soap->uri('http://ohio.cardinal.verisignepctest.com/');
      > $soap->proxy($URL, keep_alive => 1, timeout => 30);
      >
      > my $operation = 'getPedPoolById';
      >
      > my $som;
      >
      > my $request = '<m0:getPedPoolByIdReq
      > xmlns:m0="urn:verisign:specification:e-
      > pedigree:service:xml:schema:1"><m0:pedPoolId>60</m0:pedPoolId></m0:get
      > PedPoolByIdReq>';
      >
      >
      > my $headerXML = '<m:AuthInfo
      > xmlns:m="urn:verigign:specification:e-
      > pedigree:authentication:xml:schema:1">';
      > $headerXML .= '<m:UserToken>';
      > $headerXML .= '<m:UserName>superuser</m:UserName>';
      > $headerXML .= '<m:Password>cardinalui123</m:Password>';
      > $headerXML .= '</m:UserToken>';
      > $headerXML .= '</m:AuthInfo>';
      > my $header = SOAP::Header->type('xml' => $headerXML);
      > print Dumper($header);
      >
      >
      >
      > eval { $som = $soap->$operation($request) };
      >
      > if ($@)
      > {
      > die "Untrapped error in SOAP operation ($operation):
      > $@";
      > }
      > elsif ($som->fault)
      > {
      > die "SOAP operation ($operation) failed. Fault code
      > (" .
      > $som->faultcode . ") Fault String(" . $som-
      > >faultstring . ")";
      > }
      >
      > my $body;
      >
      > if (!$som->match(SOAP::SOM::envelope))
      > {
      > die "Invalid SOAP response";
      > }
      >
      > $body = $som->valueof('Body');
      > print Dumper($body);
      >
      > # Should be a single key.
      > my $element = "";
      > foreach my $key (keys %$body)
      > {
      > $element = $key;
      > last;
      > }
      >
      > my $responseContent = $$body{"$element"};
      >
      > print "SOAP response content: $responseContent\n";
      >
      > }
      >
      > ********************************************************************
      >
      > Here's the SOAP message that's passed to the server:
      > <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      > xmlns:xsi="http://www.w
      > 3.org/1999/XMLSchema-instance" xmlns:SOAP-
      > ENC="http://schemas.xmlsoap.org/soap/e
      > ncoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > xmlns:xsd="
      > http://www.w3.org/1999/XMLSchema" SOAP-
      > ENV:encodingStyle="http://schemas.xmlsoap
      > .org/soap/encoding/"><SOAP-ENV:Body><namesp1:getPedPoolById
      > xmlns:namesp1="https
      > ://ohio.cardinal.verisignepctest.com/"><c-gensym3
      > xsi:type="xsd:string"><m0:g
      > etPedPoolByIdReq xmlns:m0="urn:verisign:specification:e-
      > pedigree:service:xml:sch
      > ema:1"><m0:pedPoolId>60</m0:pedPoolId></m0:getPedPoolByIdReq>
      > </c-gensym
      > 3></namesp1:getPedPoolById></SOAP-ENV:Body></SOAP-ENV:Envelope>
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.