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

Re: [soaplite] How do I add a namespace to the soap header

Expand Messages
  • Graham Irvine
    ... something like this will do it. my $soap = SOAP::Lite- proxy($proxy); $soap- serializer- soapversion( 1.2 ); $soap- serializer- namespaces({
    Message 1 of 5 , Oct 15, 2007
      oldfic4 wrote:
      > How do get soaplite to add the xmlns:intf ns to get the soap envelope
      > to look as below?
      >
      > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      > xmlns:intf="http://session.webservices.thefirm.uk">
      >
      > Thanks
      >
      >
      >
      >

      something like this will do it.

      my $soap = SOAP::Lite->proxy($proxy);
      $soap->serializer->soapversion("1.2");
      $soap->serializer->namespaces({
      "http://schemas.xmlsoap.org/soap/envelope/"=>"soap",

      "http://www.w3.org/2001/XMLSchema"=>"xsd",
      "http://www.w3.org/2001/XMLSchema-instance"=>"xsi",
      "http://session.webservices.thefirm.uk"=>"intf"});


      You might have to pass an attribute to your soap method too
      depending on how strict the doc literal server is.

      something like

      my $soapmethod=SOAP::Data->name($method)
      ->attr({xmlns => $namespace});
    • chris
      Thank you Graham - that worked perfectly. From: soaplite@yahoogroups.com [mailto:soaplite@yahoogroups.com] On Behalf Of Graham Irvine Sent: 15 October 2007
      Message 2 of 5 , Oct 17, 2007

        Thank you Graham - that worked perfectly.

         

        From: soaplite@yahoogroups.com [mailto:soaplite@yahoogroups.com] On Behalf Of Graham Irvine
        Sent: 15 October 2007 23:22
        To: oldfic4
        Cc: soaplite@yahoogroups.com
        Subject: Re: [soaplite] How do I add a namespace to the soap header

         

        oldfic4 wrote:

        > How do get soaplite to add the xmlns:intf ns to get the soap envelope
        > to look as below?
        >
        > <soap:Envelope xmlns:soap="
        href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        > xmlns:intf="http://session.webservices.thefirm.uk">
        >
        > Thanks
        >
        >
        >
        >

        something like this will do it.

        my $soap = SOAP::Lite->proxy($proxy);
        $soap->serializer->soapversion("1.2");
        $soap->serializer->namespaces({
        "http://schemas.xmlsoap.org/soap/envelope/"=>"soap",

        "http://www.w3.org/2001/XMLSchema"=>"xsd",
        "http://www.w3.org/2001/XMLSchema-instance"=>"xsi",
        "http://session.webservices.thefirm.uk"=>"intf"});

        You might have to pass an attribute to your soap method too
        depending on how strict the doc literal server is.

        something like

        my $soapmethod=SOAP::Data->name($method)
        ->attr({xmlns => $namespace});

      • Paul Gallagher
        Hi Chris. Yes, overridding the serializer is the trick. Example: #!/usr/bin/perl -w use strict; #NB: SOAP::serializer- register_ns requires 0.65 use SOAP::Lite
        Message 3 of 5 , Oct 17, 2007
          Hi Chris. Yes, overridding the serializer is the trick. Example:

          #!/usr/bin/perl -w
          use strict;

          #NB: SOAP::serializer->register_ns requires 0.65
          use SOAP::Lite 0.65 +trace => 'debug';

          my $soap = SOAP::Lite
          ->proxy( 'http://localhost/blah/DummyService' );

          my $serializer = $soap->serializer();
          $serializer->register_ns( 'http://session.webservices.thefirm.uk', 'intf' );

          my $som = $soap->test();

          ===> generates request:

          <?xml version="1.0" encoding="UTF-8"?>
          <soap:Envelope xmlns:intf="http://session.webservices.thefirm.uk"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
          <soap:Body><test xsi:nil="true" /></soap:Body></soap:Envelope>


          On 10/15/07, oldfic4 <chris@...> wrote:
          > How do get soaplite to add the xmlns:intf ns to get the soap envelope
          > to look as below?
          >
          > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
          > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          > xmlns:intf="http://session.webservices.thefirm.uk">
          >
          > Thanks
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.