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

Re: [soaplite] Header Authentication - Not Found?

Expand Messages
  • Byrne Reese
    This looks to me like a classic problem of how SOAP::Lite handles complex types... You seem to have understood how to handle these issues within the Body, now
    Message 1 of 2 , Nov 13, 2004
    • 0 Attachment
      This looks to me like a classic problem of how SOAP::Lite handles
      complex types... You seem to have understood how to handle these issues
      within the Body, now you just need to do the same in Header:

      my @params = (
      SOAP::Header->name("Authentication" => \SOAP::Data->value(
      SOAP::Data->name("Access" => 'testAcc'),
      SOAP::Data->name("Username" => 'testUser'),
      SOAP::Data->name("Password" => '****'),
      ))->attr({xmlns => $method_uri}),
      SOAP::Data->name("code" => \SOAP::Data->value(
      SOAP::Data->name("string" => @data)->type("string")
      ))
      ) ;

      tyndyll wrote:

      > Hi All
      >
      > (and apologies in advance if this is a double post)
      >
      > I am trying to write a SOAP client which requires authentication on
      > the server. The code i have so far is
      >
      > *********************************
      >
      > use SOAP::Lite +trace;
      >
      > my @data = qq(an, array, of, strings );
      >
      > my ($server, $endpoint, $soapaction, $method, $method_uri);
      >
      > $server = 'http://www.soapserver.com'; <http://www.soapserver.com%27;>
      > $endpoint = $server.'/path/to/endPoint.asmx';
      > $soapaction = 'urn:schema-soap-server/location';
      > $method = 'Method';
      > $method_uri = 'urn:schema-soap-server/location';
      >
      >
      > my $soap = SOAP::Lite->new(
      > uri => $soapaction,
      > proxy => $endpoint,
      > on_action => sub {join '', @_},
      > readable => 1,
      > encoding => undef
      > );
      >
      >
      > $method = SOAP::Data->name($method)->attr({xmlns => $method_uri});
      >
      > my @params = ( SOAP::Header->name("Authentication" => {
      > "Access" => 'testAcc',
      > "Username" => 'testUser',
      > "Password" => '****',
      > })->attr({xmlns => $method_uri}),
      > SOAP::Data->name("code"=>\SOAP::Data->value(
      > SOAP::Data->name("string" =>
      >
      > @data)->type("string")))) ;
      >
      > my $result = $soap->call($method => @params);
      >
      > ***********************************
      >
      > I am getting the error message
      >
      > "Server did not find required Authentication SOAP header in the message."
      >
      > When I look at the serialized XML i can see a name space namesp1 and
      > in the header
      >
      > <Authentication xmlns="urn:schema-soap-server/location"
      > xsi:type="namesp1:SOAPStruct">
      >
      > I do not have this namespace in the body. Is this the problem, and if
      > so how can I resolve it? Using LWP with the namesp1 removed *seems* to
      > work fine, but I would prefer to use SOAP::Lite for deserializing the
      > reply..
      >
      > Can anyone help please?
      >
      > Thanks
      >
      > Tyndyll
    Your message has been successfully submitted and would be delivered to recipients shortly.