Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Error while receiving SOAP envelope from client

by chanakya (Friar)
on Mar 02, 2005 at 12:54 UTC ( [id://435803]=perlquestion: print w/replies, xml ) Need Help??

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

Greetings !

I just installed SOAP::Lite and decided to check it out, and in the process created the following scripts:

script /var/www/html/soap/soapserver.cgi
#!/usr/bin/env perl5.8.6 use SOAP::Transport::HTTP; use World; SOAP::Transport::HTTP::CGI -> dispatch_to('World') -> handle;
Module /var/www/html/soap/World.pm
package World; sub new { bless {}, shift; }; sub HelloPeople { my ($self) = @_; return "Answer from sub HelloPeople\n"; }; sub GoodBye { my ($self,$adjective) = @_; return "Goodbye $adjective \n"; } 1;
After this I started the Apache server.

The following is the soap client(soapClient.pl)
#!/usr/bin/env perl5.8.6 use SOAP::Lite; my $s = SOAP::Lite ->uri('World') ->proxy('http://localhost/soap/soapserver.cgi') ->HelloPeople() ->on_debug(sub{print@_}); print $s->result(); my $s = SOAP::Lite ->uri('World') ->proxy('http://localhost/soap/soapserver.cgi') ->GoodBye("Bad world") ->on_debug(sub{print@_}); print $s->result();
Everything's fine until this point. When I execute the client (soapClient.pl), It spews out the
following errors
not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lo +cal/lib/perl5/site_perl/5.8.6/i686-linux/XML/Parser.pm line 187 #!/usr/bin/env perl5.8.6 use SOAP::Transport::HTTP; use World; SOAP::Transport::HTTP::CGI -> dispatch_to('World') -> handle; at soapClient.pl line 9
Anybody has any idea, why is that so.

Thanks in advance

Replies are listed 'Best First'.
Re: Error while receiving SOAP envelope from client
by gellyfish (Monsignor) on Mar 02, 2005 at 13:24 UTC

    It would appear that this is a problem with the response from the server - you can get more diagnostic information from the client by changing the :

    use SOAP::Lite;
    to
    use SOAP::Lite +trace => 'all';
    This should give you enough to see what is going on - or if you can't work it out for yourself then paste the output here.

    /J\

Re: Error while receiving SOAP envelope from client
by jhourcle (Prior) on Mar 02, 2005 at 14:06 UTC

    I'm not sure what the exact problem is, but I did notice something odd in your client:

    my $s = SOAP::Lite ->uri('World') ->proxy('http://localhost/soap/soapserver.cgi') # vvvvvvvvvvvvvvvvvvvvvvvvvv ->GoodBye("Bad world") ->on_debug(sub{print@_}); # ^^^^^^^^^^^^^^^^^^^^^^^^^^ print $s->result();

    The method call to the server GoodBye() returns a SOAP::SOM object (a response of sorts), and not the SOAP object (which is a link to the server), so you probably won't get debugging output from the call. I'd suggest instead using something like the following

    my $soap = SOAP::Lite ->uri('World') ->proxy('http://localhost/soap/soapserver.cgi') ->on_debug(sub{warn @_}); $som = $soap ->GoodBye("Bad world"); if ( $som->fault ) { warn $som->faultcode() ||'', " : ", $som->faultstring()||'', " : ",$som->faultdetail()||'',"\n"; } else { print $som->result(); }

    With debugging on, you should get both the HTTP headers that are sent, and the XML payload of the request and response.

      I've used the code specified but I still get the same error which I've showed in the earlierpost

      Below is the output after executing the soap client(without use SOAP::Lite +trace => 'all';)

      [root@shobhan soap]# perl soapClient.pl POST http://localhost/soap/soapserver.cgi HTTP/1.1 Accept: text/xml Accept: multipart/* Content-Length: 503 Content-Type: text/xml; charset=utf-8 SOAPAction: "World#GoodBye" <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="ht +tp://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schem +as.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap +.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOA +P-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP +-ENV:Body><namesp1:GoodBye xmlns:namesp1="World"><c-gensym3 xsi:type= +"xsd:string">Bad world</c-gensym3></namesp1:GoodBye></SOAP-ENV:Body>< +/SOAP-ENV:Envelope> HTTP/1.1 200 OK Connection: close Date: Thu, 03 Mar 2005 10:22:21 GMT Accept-Ranges: bytes ETag: "6c341-85-68808f40" Server: Apache/2.0.52 (Fedora) Content-Length: 133 Content-Type: text/plain; charset=UTF-8 Last-Modified: Wed, 02 Mar 2005 10:59:33 GMT Client-Date: Thu, 03 Mar 2005 10:22:21 GMT Client-Peer: 127.0.0.1:80 Client-Response-Num: 1 #!/usr/bin/env perl5.8.6 use SOAP::Transport::HTTP; use World; SOAP::Transport::HTTP::CGI -> dispatch_to('World') -> handle; not well-formed (invalid token) at line 1, column 1, byte 1 at /usr/lo +cal/lib/perl5/site_perl/5.8.6/i686-linux/XML/Parser.pm line 187 #!/usr/bin/env perl5.8.6 use SOAP::Transport::HTTP; use World; SOAP::Transport::HTTP::CGI -> dispatch_to('World') -> handle; at soapClient.pl line 23
      Does this imply that the XML response from the server is not well-formed.
      Any ideas what might be wrong..

      Thanks
        you must add in your conf of apache2 AddHandler cgi-script .cgi .pl

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found