Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Keep It Simple, Stupid
 
PerlMonks  

Using Pod::WSDL and getting error 301 when calling any method

by Max_Kooler (Initiate)
on May 03, 2013 at 15:42 UTC ( #1031916=perlquestion: print w/ replies, xml ) Need Help??
Max_Kooler has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm writing a little Web Service in Perl, and I'm using Pod::WSDL to achieve it. All appears to be right when I call it from the browser, it shows the WSDL code and it seems to be fine. But now I'm using the Web Services Explorer from Eclipse to call it and it looks perfect until I try to use a method, in any case I get:

IWAB0135E An unexpected error has occurred.
301
Moved Permanently


This is the code of my Web Service:
WebserviceFunctions.pm package WebserviceFunctions; =begin WSDL _DOC Hello return a String saying hello _IN name $string the name of the user to salute _RETURN $string Returns a string Hello, name =end WSDL sub Hello { my $name = shift; my $return = "Hello, $name"; return $return; } =begin WSDL _DOC Goodbye return a String saying goodbye _IN name $string the name of the user to dismiss _RETURN $string Returns a string Goodbye, name =end WSDL sub Goodbye { my $name = shift; my $return = "Goodbye, $name"; return $return; } 1; webservice.cgi #!/usr/bin/perl -w use Pod::WSDL; use CGI; use strict; use warnings; print CGI->header('text/xml'); my $pod = new Pod::WSDL(source=> './WebserviceFunctions.pm', location=>'http://192.168.11.73/cgi-bin/webser +vice', pretty=>1, withDocumentation=>1); $pod->addNamespace('http://192.168.11.73/cgi-bin/webservice/','Webserv +iceFunctions'); print $pod->WSDL;
To call the webservice I point to http://192.168.11.73/cgi-bin/webservice/webservice.cgi.
I hope you can help me to find out why I get this 301 error, Thank You!

Comment on Using Pod::WSDL and getting error 301 when calling any method
Download Code
Re: Using Pod::WSDL and getting error 301 when calling any method
by Anonymous Monk on May 03, 2013 at 19:26 UTC

    ... until I try to use a method ...

    What makes you think Pod::WSDL is used for calling methods web services?

      I used the Web Services Explorer from Eclipse to call the method, in this case if I call either Hello or Goodbye Eclipse will throw the 301 error.

        I used the Web Services Explorer from Eclipse to call the method, in this case if I call either Hello or Goodbye Eclipse will throw the 301 error.

        What method? What webservice?

        webservice.cgi is not a webservice, you can't call methods an it

        you can name it surely-you-cant-be-serious.cgi but it won't respond with "I am serious. And don't call me Shirley"

        Let me rephrase. webservice.cgi is not server, it provides no methods for you to call, it prints some xml, and that's it -- it always does this, it never does anything different

        Also, WebserviceFunctions.pm contains no code, it is 100% pod

        So, whether you use Eclipse or whatever, there is no server for you to call Hello or Goodbye on, it doesn't exist

Re: Using Pod::WSDL and getting error 301 when calling any method
by InfiniteSilence (Deacon) on May 03, 2013 at 21:40 UTC

    I was going to finalize my response with an example that actually read from the WSDL file and called the service but there is apparently a problem with SOAP::Lite just working with the WSDL file (as described here) and I don't have another SOAP client handy. Since you are not going to use a SOAP::Lite-based client anyway though that should not affect you.

    As others have anonymously responded, it is true, the Pod::WSDL just creates the WSDL file. It kind of says this in the pod, "Pod::WSDL will output the WSDL document. That's it." You know, you don't really need a WSDL file to have a webservice written in Perl (as shown below). If you insist on using the WSDL you'll have to change it to describe something else that will actually respond to the incoming SOAP packet with your WebServiceFunctions methods. Here's a crude example calling a webservice written in Perl that uses your WebServiceFunctions class:

    use SOAP::Lite +trace=>'all'; #removing tracing later my $soap_resp = SOAP::Lite->uri('http://localhost/WebServiceFunctions' +)->proxy('http://localhost/cgi-bin/soap-cooltest.pl')->Hello('world') +; print $soap_resp->result; if ($soap_resp->fault){print $soap_resp->faultstring}
    Here's the web service that loads your class and will fire off its methods when requested:
    #!/usr/bin/perl -w + use strict; use WebServiceFunctions; print "Content-type: application/soap\n"; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI->dispatch_to('WebServiceFunctions')->h +andle; 1;

    I renamed the class to WebServiceFunctions and I added '=cut' after the '=end WSDL' pod tags as SOAP::Transport::HTTP doesn't like it.

    Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1031916]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-04-17 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls