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

SOAP::LITE ?base64? encoding data in SOAP BODY

Expand Messages
  • oldfic4
    Someone please preserve my sanity! I m attempting to consume a .net web service via a perl client using SOAP::LITE. Within the SOAP BODY I m sending an element
    Message 1 of 2 , Jan 18, 2005
    • 0 Attachment
      Someone please preserve my sanity! I'm attempting to consume a .net
      web service via a perl client using SOAP::LITE. Within the SOAP BODY
      I'm sending an element that contains an XML formatted message as
      follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <Acknowledgements xmlns="portal-acknowledgments-schema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="portal-acknowledgments-schema
      portal_conveyancer_acknowledgement.xsd">
      <Accept>
      <PortalId>999</PortalId>
      <Reason>passed conflict checks</Reason>
      <ConveyancerId>1xxx</ConveyancerId>
      </Accept>
      </Acknowledgements>

      This is unintelligible to the .net server as url type encoding
      appears to have been added by the call. It reads to the .net service
      as:

      <?xml version="1.0" encoding="UTF-8"?> <Acknowledgements
      xmlns="portal-acknowledgments-schema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="portal-acknowledgments-
      schema portal_conveyancer_acknowledgement.xsd">
      <Accept>
      <PortalId>809</PortalId>

      How to I get it to do all the good SOAP wrapping but just send what
      I want it to send.
      The code looks like this with the xml message above contained in the
      variable $data:

      use SOAP::Lite ( +trace => "all", maptype => {} );

      my $data;
      open(FILE,"accept.xml") || die "cannot open file";
      $data = <FILE>;
      close(FILE);

      my $soap = SOAP::Lite
      -> uri('http://www.xxx.com/services')
      -> on_action( sub { return 'http://www.xxx.com/services/Send' } )
      -> proxy('https://www.xxx.co.uk/xxx.asmx');

      my $header = SOAP::Header->name(CredentialHeader => {
      username => "xxx", password => "xxx"
      })->uri('http://www.xxx.com/services')->prefix('');

      my @params = ($header,
      SOAP::Data->name('xmlNode' => $data)->uri
      ('http://www.xxx.com/services'));

      my $method = SOAP::Data->name('Send')
      ->attr({xmlns => 'http://www.xxx.com/services'});

      my $result = $soap->call($method => @params);

      I've trawled numerous forums and read the documentation; I've most
      likely seen the answer and failed to recognize it as such. Anyone
      help?
    • Duncan Cameron
      ... <Acknowledgements ... portal_conveyancer_acknowledgement.xsd ... Set the type of xmlNode to be xml and S::L will not escape it
      Message 2 of 2 , Jan 19, 2005
      • 0 Attachment
        --- oldfic4 <chris@...> wrote:
        >
        >
        > Someone please preserve my sanity! I'm attempting to consume a .net
        > web service via a perl client using SOAP::LITE. Within the SOAP BODY
        > I'm sending an element that contains an XML formatted message as
        > follows:
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        > <Acknowledgements xmlns="portal-acknowledgments-schema"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xsi:schemaLocation="portal-acknowledgments-schema
        > portal_conveyancer_acknowledgement.xsd">
        > <Accept>
        > <PortalId>999</PortalId>
        > <Reason>passed conflict checks</Reason>
        > <ConveyancerId>1xxx</ConveyancerId>
        > </Accept>
        > </Acknowledgements>
        >
        > This is unintelligible to the .net server as url type encoding
        > appears to have been added by the call. It reads to the .net service
        > as:
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        <Acknowledgements
        > xmlns="portal-acknowledgments-schema"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xsi:schemaLocation="portal-acknowledgments-
        > schema
        portal_conveyancer_acknowledgement.xsd">
        > <Accept>

        > <PortalId>809</PortalId>
        >
        > How to I get it to do all the good SOAP wrapping but just send what
        > I want it to send.
        > The code looks like this with the xml message above contained in the
        > variable $data:
        >
        > use SOAP::Lite ( +trace => "all", maptype => {} );
        >
        > my $data;
        > open(FILE,"accept.xml") || die "cannot open file";
        > $data = <FILE>;
        > close(FILE);
        >
        > my $soap = SOAP::Lite
        > -> uri('http://www.xxx.com/services')
        > -> on_action( sub { return 'http://www.xxx.com/services/Send' } )
        > -> proxy('https://www.xxx.co.uk/xxx.asmx');
        >
        > my $header = SOAP::Header->name(CredentialHeader => {
        > username => "xxx", password => "xxx"
        > })->uri('http://www.xxx.com/services')->prefix('');
        >
        > my @params = ($header,
        > SOAP::Data->name('xmlNode' => $data)->uri
        > ('http://www.xxx.com/services'));

        Set the type of xmlNode to be 'xml' and S::L will not escape it

        SOAP::Data->type('xm')->name( ... )

        But even then you cannot have an xml declaration part way through an
        xml document, so you will have to remove it from your example.

        Regards

        Duncan Cameron






        ___________________________________________________________
        ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
      Your message has been successfully submitted and would be delivered to recipients shortly.