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

I have tried to test a script from perl.com to test how I might send a request for data to a webservice. I tried running :
#!/usr/bin/perl -w use SOAP::Lite; my $service = SOAP::Lite -> service('http://www.xmethods.net/sd/StockQuoteService.wsdl'); print 'MSFT + ORCL = ', $service->getQuote('MSFT') + $service->get +Quote('ORCL');
this returns an internal server error (I have CHMOD 755) and it is saved as a cgi file. What am I doing wrong? DO I need anything else? (I have SOAP::LITE installed on my server)

Replies are listed 'Best First'.
Re: SOAP WSDL and perl
by moritz (Cardinal) on Apr 08, 2009 at 15:12 UTC
    The error log of your web server tells you more. Without an error message we can't say what's wrong.

    Oh, and please read Writeup Formatting Tips and updated your question with <code>...</code> tags.

Re: SOAP WSDL and perl
by ikegami (Patriarch) on Apr 08, 2009 at 15:43 UTC

    Please put code in <c>...</c> tags.

    Check your error log when you get 500 error. You should see:

    Service description 'http://www.xmethods.net/sd/StockQuoteService.wsdl +' can't be loaded: 404 Not Found

    That URL is no longer valid.

    ( Even that did work, you're also not emitting a necessary CGI header like jhourcle points out! )

Re: SOAP WSDL and perl
by jhourcle (Prior) on Apr 08, 2009 at 17:22 UTC

    From your comment about saving it as a CGI file, I suspect that you're running into the same problem as Webservices and browsers

      I am running a local StockQuoteService , http://localhost:8080/axis2/services/StockQuoteService?wsdl
      $stockprice=SOAP::Lite ->service('http://localhost:8080/axis2/service/StockQuoteService?w +sdl') ->getPrice('IBM'); print Dumper($stockprice);
      The result returns $VAR1 = undef; I am getting a undef value , what is the correct way to call a webservice using Perl?
        I usually use this:

        #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use SOAP::Lite; use SOAP::WSDL; my $service = SOAP::Lite ->service('http://localhost:8080/axis2/service/StockQuoteSer +vice?wsdl'); print Dumper "IBM ", $service->getQuote('IBM'), "\n";