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

Hey folks,
I am trying to use SOAP with WSDL but it won't work for me. I search already on the internet and read also Posts about SOAP here but it couldn't help me.
Normal communication between soap cgi server and the client, which is using SOAP::Lite works.
But when i try to use the WSDL file, which i've created with POD::WSDL i get
"syntax error at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser.pm line 187".
By using the trace ability of SOAP::LITE i discovered that the function were successfully executed because i got
... <soap:Body><tns1:mySub><foo xsi:type="xsd:string">HELLO</foo></tns1:my +Sub></soap:Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK ...
But after this i get the error message mentioned before. So I looked up in line 187 of Parser.pm.
There the module try to parse $args, so i checked what is stored in $args and its my server code. But why is my server code in $args? Shoudn't it be the xml data where my result ist stored?
I Also tried to use SOAP:WSDL
#my $soap = SOAP::WSDL->new( # wsdl => 'http://localhost/wsdl/wsdl.xml', # ); #my $result = $soap->call('MySub', "foobar");
But this gives me the following error:
"unable to extract schema from WSDL".
I tried many links which google gave me but all these links couldn't get me any further.

I hope that you can help me with this.

Replies are listed 'Best First'.
Re: SOAP::LITE with WSDL /SOAP::WSDL won't work
by Corion (Patriarch) on Sep 29, 2010 at 11:48 UTC
    syntax error at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser. +pm line 187

    This likely means that there is a syntax error in whatever XML is parsed at that location. The other errors you seem to get also seem to point towards invalid XML. So, are you sure that what you get as a server response is actual, valid XML?

      This is all what trace shows me:
      Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 578 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://localhost/MYSOAP#mySub" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h +ttp://schemas.xmlsoap.org/wsdl/soap/" soap:encodingStyle="http://sche +mas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.or +g/soap/envelope/" xmlns:tns1="http://localhost/MYSOAP" xmlns:wsdl="ht +tp://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap +.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst +ance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><tns1:m +ySub><foo xsi:type="xsd:string">HELLO</foo></tns1:mySub></soap:Body>< +/soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Wed, 29 Sep 2010 11:43:07 GMT Accept-Ranges: bytes Content-Length: 226 Content-Type: text/plain; charset=utf-8 Last-Modified: Wed, 29 Sep 2010 09:17:08 GMT Client-Date: Wed, 29 Sep 2010 11:43:07 GMT Client-Peer: IP:80 Client-Response-Num: 1 use lib qw(/path/to/my/module); use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -dispatch_to('MYSOAP') # ->dispatch_with({ 'urn:localhost:wsdl:MYSOAP' => 'MYSOAP' }) -> handle; syntax error at line 1, column 0, byte 0 at /usr/lib/perl5/XML/Parser. +pm line 190 use lib qw(/path/to/my/module); use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -dispatch_to('MYSOAP') # ->dispatch_with({ 'urn:localhost:wsdl:MYSOAP' => 'MYSOAP' }) -> handle;

      As you see there is my server code shown up, which is stored in $arg and i thought that here should be the xml part which is at the beginning of the output

      the WSDL file was created by Pod::WSDL so i think that should be valid but i'm going to check this out.
      I checked the xml Output which trace shows me and it is valid xml


      Thanks so far.

        I can't make much of your description, and don't really understand what is in your output and what is source code from a program and what produces what. Have you inspected the results you get using wget or curl, to inspect the actual data returned, instead of looking at things through SOAP?

        If the server returns invalid data, the problem is not in your client but in the server. Maybe you just have invalid POD when you created your WSDL file?