Hi,

I'm currently facing an XML Parsing issue right on the xml declaration (<?xml ...) with using SOAP::Lite.

not well-formed (invalid token) at line 1, column 3, byte 3 at /usr/lib64/perl5/vendor_perl/XML/Parser.pm line 187.

Context: using SOAP::Lite as client to request a service endpoint (WSDL web service) with WSSE security.

URI is not provided as an attribute for method (getListOfSesms) Use of uninitialized value $name in substitution (s///) at /usr/local/ +share/perl5/SOAP/Lite.pm line 1117. Use of uninitialized value $name in exists at /usr/local/share/perl5/S +OAP/Lite.pm line 1118. Use of uninitialized value $name in hash element at /usr/local/share/p +erl5/SOAP/Lite.pm line 1118. Use of uninitialized value $name in hash element at /usr/local/share/p +erl5/SOAP/Lite.pm line 1122. Use of uninitialized value $name in hash element at /usr/local/share/p +erl5/SOAP/Lite.pm line 1122. SOAP::Transport::HTTP::Client::send_receive: POST https://A.B.C.D:8443 +/prov/services/ConfigAdminService HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 1384 Content-Type: text/xml; charset=utf-8 SOAPAction: "#getListOfSesms" <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:con="config.ws.nortelnetworks.com" xmlns:namesp1="http://namespaces.soaplite.com/perl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs. +oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd +" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- +wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-B2BC1A8DAD33A413E21488 +9629128004"> <wsse:Username>XXXXXX</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oa +sis-200401-wss-username-token-profile-1.0#PasswordText">XXXXXX</wsse: +Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/ +01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">YSB2YWx1Z +SBvZiA2OA==</wsse:Nonce> <wsu:Created>2017-03-10T09:12:51Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> </soapenv:Header> <soapenv:Body> <getListOfSesms soapenv:encodingStyle="http://schemas.xmlsoap.org/ +soap/encoding/" xsi:nil="true" /> </soapenv:Body> </soapenv:Envelope> SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to A.B. +C.D:8443 Content-Type: text/plain Client-Date: Fri, 10 Mar 2017 09:12:51 GMT Client-Warning: Internal response Can't connect to A.B.C.D:8443 not well-formed (invalid token) at line 1, column 3, byte 3 at /usr/li +b64/perl5/vendor_perl/XML/Parser.pm line 187. Can't connect to A.B.C.D:8443

For information:
- XML syntax from the trace above has been checked ok with some XML syntax tools
- I have used stubmaker to get WSDL into Perl (ConfigAdminIFService here)
- I had to use call() instead of method() to pass the authentication parameters ($auth)
- when using SOAPUI, there is no xml declaration in the request.

Some code extracts:

use strict; use utf8; use XML::Parser; use Time::Local; use Digest::SHA1; use MIME::Base64; use SOAP::Lite +trace => 'debug', readable => 1; use SOAP::WSDL; use ConfigAdminIFService; $SOAP::Constants::PREFIX_ENV = 'soapenv'; [...] my $service_url='https://A.B.C.D:8443/prov/services/ConfigAdminService +'; my $soap = new ConfigAdminIFService->new(); $soap->proxy($service_url); $soap->serializer->attr({ "xmlns:con" => "config.ws.nortelnetworks.com +" , "xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/" }) +; $soap->readable(1); my $response = $soap->call( SOAP::Data ->name('getListOfSesms') ->attr({ "soapenv:encodingStyle" => "http://sc +hemas.xmlsoap.org/soap/encoding/" }), $auth);

I have run through various settings, including encoding, Content-Type, etc. without luck so far.
Also, would there be any option for removing the xml declaration as it is not present in the raw request when using SOAPUI ?
Thanks a lot for your previous help and advice
Erwan.


In reply to XML Parsing issue with SOAP::Lite (xml declaration) by erwanhumez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.