Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

PERL soap not well-formed (invalid token)

by kanewilliam7777 (Novice)
on Aug 21, 2018 at 11:22 UTC ( [id://1220776]=perlquestion: print w/replies, xml ) Need Help??

kanewilliam7777 has asked for the wisdom of the Perl Monks concerning the following question:

I have created WSDL file connect the file with PERL soap method. After the exection i get the below error message

"not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm line 187." .

Please let me know have to fix the issue.

soap-client.pl
#!/usr/bin/perl -w #use SOAP::Lite +trace => ‘debug’; use SOAP::Lite; my $client = SOAP::Lite ->service('http://localhost/soap/perl/marketplace.wsdl'); my $result = $client->login( 'test_user', 'test_password' ); #~ my $result = $client->sayHello(''); print $result;
soap-server.pl
#!/usr/bin/perl function login( $login, $password ) { return $login; } function doFilter( $params ) { return "some string"; }
marketplace.wsdl
<?xml version="1.0" encoding="UTF-8"?> <definitions name="Marketplace" targetNamespace="urn:Marketplace" xmlns:tns="urn:Marketplace" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="LoginRequest"> <part name="login" type="xsd:string"/> <part name="password" type="xsd:string"/> </message> <message name="LoginResponse"> <part name="result" type="xsd:string"/> </message> <portType name="LoginPort"> <operation name="login"> <input message="tns:LoginRequest"/> <output message="tns:LoginResponse"/> </operation> </portType> <binding name="LoginBinding" type="tns:LoginPort"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.or +g/soap/http"/> <operation name="login"> <soap:operation soapAction="urn:LoginAction"/> <input> <soap:body use="encoded" namespace="urn:Marketplace" e +ncodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" namespace="urn:Marketplace" e +ncodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="WSDLService"> <port name="LoginPort" binding="tns:LoginBinding"> <soap:address location="http://localhost/soap/perl/soap-se +rver.pl"/> </port> </service> </definitions>

finally run the soap-client.pl file return below error message.

"not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lib/x86_64-linux-gnu/perl5/5.26/XML/Parser.pm line 187." .

Replies are listed 'Best First'.
Re: PERL soap not well-formed (invalid token)
by Corion (Patriarch) on Aug 21, 2018 at 11:30 UTC

    SOAP::Lite expects something that looks like XML in the reply, but at least XML::Parser doesn't think that it gets XML back.

    Your next step is to look at what exactly comes back from the other end.

    You already have a line # use SOAP::Lite +trace => ‘debug’; in your code, but that doesn't match what the SOAP::Trace documentation suggests. Maybe changing that line to the following gives you more output that gives you a hint where things to wrong?

    use SOAP::Lite +trace => 'all';

    What you are looking for is likely the response from the server. Maybe the server sends an HTML error message, or some JSON or whatever.

      Hi,

      It's sent html error message. Now i have enable the "use SOAP::Lite +trace => "debug";".

      Review full response.

      SOAP::Transport::HTTP::Client::send_receive: POST http://localhost/soa +p/perl/soap-server.pl HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 566 Content-Type: text/xml; charset=utf-8 SOAPAction: "urn:LoginAction" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyl +e="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://sche +mas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap +.org/soap/encoding/" xmlns:tns="urn:Marketplace" xmlns:wsdl="http://s +chemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><t +ns:login><login xsi:type="xsd:string">test_user</login><password xsi: +type="xsd:string">test_password</password></tns:login></soap:Body></s +oap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Tue, 21 Aug 2018 12:16:02 GMT Accept-Ranges: bytes ETag: "7c-573f0161015b0" Server: Apache/2.4.29 (Ubuntu) Content-Length: 124 Content-Type: text/x-perl Last-Modified: Tue, 21 Aug 2018 11:11:23 GMT Client-Date: Tue, 21 Aug 2018 12:16:02 GMT Client-Peer: ::1:80 Client-Response-Num: 1 #!/usr/bin/perl sub login( $login, $password ) { return $login; } sub doFilter( $params ) { return "some string"; }

        So, this response means that your web server is not set up correctly and is not running your server Perl script.

        Your next task is to configure your web server so that it runs your Perl script when you go to that URL.

      Its legit like use SOAP::Lite +trace => 'debug', readable => 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1220776]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found