Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Problem with SOAP::Lite, getting the output from the SOAP server as a complete program and not the return value

by Anonymous Monk
on Jan 08, 2010 at 14:24 UTC ( #816319=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Everybody, I'm trying to implement a simple soap client and server. I get connected to the server from the Client but then the server response that I get is a bit weird. I get the entire server program instead of the return value itself.



This is my client program (hibye.pl).
#!/usr/bin/perl -w use strict; use SOAP::Lite; # +trace => 'all'; my $soap = SOAP::Lite -> uri('urn:Demo') -> proxy('http://localhost/soap-test/hibye.cgi') -> hi(); print $soap->result;

And this is my server program:


#!/usr/bin/perl -w use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to("Demo") -> handle; package Demo; sub hi { return "Hello"; }

And below is the output that I get.

no element found at line 1, column 0, byte -1 at /usr/local/lib/perl/5 +.10.0/XML/Parser.pm line 153 #!/usr/bin/perl -w use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to("Demo") -> handle; package Demo; sub hi { return "Hello"; } at hibye.pl line 4

I'm in real need of help here as this issue has taken two unproductive days. Please revert. Thanks.

Comment on Problem with SOAP::Lite, getting the output from the SOAP server as a complete program and not the return value
Select or Download Code
Re: Problem with SOAP::Lite, getting the output from the SOAP server as a complete program and not the return value
by Anonymous Monk on Jan 08, 2010 at 14:23 UTC
    Your problem is that your webserver isn't executing your cgi program, its treating it as a text file. This is problem with your webserver configuration.

      Hi Thank you for your immediate response, Well I did try to read the instructions and configured my webserver (apache2) for cgi support.

      I tested it by running a simple script on the browser and it all worked fine.

      But as far as soap is concerned whenever I run the client I get the 500 internal server error. Any clue as to what can be wrong here

      Plus this is what I get in the error log client 127.0.0.1 Use of uninitialized value $ENV{"HTTP_TRANSFER_ENCODING"} in pattern match (m//) at /usr/local/share/perl/5.10.0/SOAP/Transport/HTTP.pm line 530

        Hello,

        I do have the exact same problem, and unfortunatly it is not a warning but an error (from apache2 error log):

        [Wed Jan 13 15:58:36 2010] [error] [client 172.31.1.19] Use of uninitialized value $ENV{"HTTP_TRANSFER_ENCODING"} in pattern match (m//) at /usr/local/share/perl/5.10.0/SOAP/Transport/HTTP.pm line 530.

        Cgi scripts are running well otherwise.
        Any possible solution or hint?

Re: Problem with SOAP::Lite, getting the output from the SOAP server as a complete program and not the return value
by marto (Bishop) on Jan 08, 2010 at 14:33 UTC

    Sounds like you need to configure your web server to execute the script rather than simply serve contents of your sever example as a page. See CGI Help Guide from the tutorials section and your web server documentation.

      Hi Marto, Well I did try to read the instructions and configured my webserver (apache2) for cgi support.

      I tested it by running a simple script on the browser and it all worked fine.

      But as far as soap is concerned whenever I run the client I get the 500 internal server error. Any clue as to what can be wrong here

        Now that you've properly configured Apache it is executing the script and experiencing a problem. What does the error_log say? Do you have the required modules installed on this server? Also, check this reply for more CGI debugging advice.

Re: Problem with SOAP::Lite, getting the output from the SOAP server as a complete program and not the return value
by Khen1950fx (Canon) on Jan 08, 2010 at 21:38 UTC
    This works:
    #!/usr/bin/perl use strict; use warnings; use SOAP::Lite; print SOAP::Lite -> uri('http://www.soaplite.com/Demo') -> proxy('http://services.soaplite.com/hibye.cgi') -> hi() -> result; my $soap = SOAP::Lite->proxy('http://endpoint.server/', proxy => ['http' => 'http://my.proxy.server/']);
      Well that won't work either, their webserver is not setup to execute perl
        The point is that the given scripts won't work.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-07-07 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls