Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

WSDL::Generator I can't see the wsdl from the client

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

Hello fellow monks!

I'm trying to create a Webservice with Perl and I'm using some code I found that uses WSDL::Generator to create the wsdl. I have Perl 5.10.0 in the server. This is the code: WebserviceFunctions.pm
package WebserviceFunctions; sub new { bless {}, shift; } sub Hello { my ($s, $name) = @_; return "Hello, $name".$/; } sub Goodbye { my ($s, $name) = @_; return "Goodbye, $name".$/; } 1;
In the same directory:
webservice.cgi
#!/usr/bin/perl -w use WSDL::Generator; use CGI; print CGI->header('text/xml'); my $init = { 'schema_namesp' => "http://192.168.11.73/~efuentes/webservice/Webs +erviceFunctions.xsd", 'services' => "WebserviceFunctions", 'service_name' => "WebserviceFunctions", 'target_namesp' => "http://192.168.11.73/~efuentes/webservice/", 'documentation' => "Testing CGI SOAP Service", 'location' => "http://192.168.11.73/~efuentes/webservice" }; my $w = WSDL::Generator->new($init); WebserviceFunctions->Hello('Joe'); WebserviceFunctions->Goodbye('Joe'); print $w->get(WebserviceFunctions);
Now, I used the

"use CGI; print CGI->header('text/xml');"

part because without it it gave me an error. Anyway, now I'm trying to call this Webservice from a PHP client, I call "http://heresmyhost/webservice/webservice.cgi" but it replies

wsdl error: Getting http://heresmyhost/webservice/webservice.cgi - HTTP ERROR: Unsupported HTTP response status 404 Not Found (soapclient->response has contents of the response)

I need help with that, what I am doing wrong?

Comment on WSDL::Generator I can't see the wsdl from the client
Select or Download Code
Re: WSDL::Generator I can't see the wsdl from the client
by Anonymous Monk on May 02, 2013 at 17:14 UTC
Re: WSDL::Generator I can't see the wsdl from the client
by InfiniteSilence (Curate) on May 02, 2013 at 17:31 UTC
    The pod on WSDL::Generator says it has issues:
    WSDL doesn’t works only on perl 5.6 and not 5.8. UNIVERSAL::AUTOLOAD i +s broken in perl 5.8 and it is used by Class::Hook upon wich WSDL::Ge +nerator depends.
    You can use Pod::WSDL (update: wrong package name) instead though. Here's the package marked up with some pod and a different Perl script following it:
    package WebserviceFunctions; sub new { bless {}, shift; } =begin WSDL _DOC Hello + =end WSDL sub Hello { my ($s, $name) = @_; return "Hello, $name".$/; } + =begin WSDL _DOC Goodbye =end WSDL sub Goodbye { my ($s, $name) = @_; return "Goodbye, $name".$/; } +
    and the script:
    #!/usr/bin/perl -w use Pod::WSDL; use CGI; print CGI->header('text/xml'); my $pod = new Pod::WSDL(source=> 'WebServiceFunctions', location=>'http://localhost/webservice_pod.pl' +, pretty=>1, withDocumentation=>1); print $pod->WSDL; 1;

    Celebrate Intellectual Diversity

      Thank you!

      I've used Pod::WSDL as you sugested but I still get the error, however I've managed to find something that I think might be the issue.
      First of all, this is my new code:

      WebserviceFunctions.pm
      package WebserviceFunctions; =begin WSDL _DOC Hello _IN name $string this is the name _OUT text $string return text =end WSDL sub Hello { my ($s, $name) = @_; return "Hello, $name".$/; } =begin WSDL _DOC Goodbye _IN name $string this is the name _OUT text $string return text =end WSDL sub Goodbye { my ($s, $name) = @_; return "Goodbye, $name".$/; } 1;

      webservice.cgi
      #!/usr/bin/perl -w use Pod::WSDL; use CGI; print CGI->header('text/xml'); my $pod = new Pod::WSDL(source=> 'WebserviceFunctions.pm', location=>'http://192.168.11.73/~efuentes/webs +ervice', pretty=>1, withDocumentation=>1); $pod->addNamespace('http://192.168.11.73/~efuentes/webservice/','Webse +rviceFunctions'); print $pod->WSDL;

      Now, you can see the full address where I generate the Webservice is "http://192.168.11.73/~efuentes/cgi-bin/webservice/webservice.cgi", if I put that on my browser I get my wsdl, but now, I've found in that wsdl this code "targetNamespace="http://192.168.11.73/WebserviceFunctions" wish differs from my full path, I've tried to change it with "$pod->addNamespace('http://192.168.11.73/~efuentes/webservice/','WebserviceFunctions');" as you can see in the code, but I get the same targetNamespace on the wsdl.
      Any suggestions to fix that?
      After a lot of time searching for an answer, I finally fixed the error, it was in the client side on PHP where I had to specify the EndPoint. Thanks a lot for helping me, I'll keep using Pod::WSDL anyway, it works better than WSDL::Generator.

      Cheers!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2015-07-06 06:19 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 (70 votes), past polls