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

Dear Monks,
Could someone give me a simple example of using WSDL api in perl to create a web page.
I know that SOAP:Lite should be used, but do not understand how to connect it with request from the client.

Replies are listed 'Best First'.
Re: wsdl api in perl
by Anonymous Monk on Feb 11, 2008 at 04:30 UTC
Re: wsdl api in perl
by roman (Monk) on Feb 11, 2008 at 10:56 UTC

    Do you want to create a SOAP server or a SOAP client?

    If server then you can use SOAP::Lite, but your service is by no means connected with any WSDL nor there is any support for WSDL creation.

    If client then SOAP::Lite can make a client stub via SOAP::Lite->service($WSDL_URI), but

    • It is not clear (for me) which WSDLs (types present in XML Schema in WSDL) can be handled by SOAP::Lite. Probably only rpc/encoded with simple XML Schema types.
    • There is a bug (http://rt.cpan.org/Public/Bug/Display.html?id=29505) in SOAP::Lite 0.69 - at least I think - that causes that SOAP::Lite client created by SOAP::Lite->service uses wrong namespace for SOAP envelope, which is then rejected by SOAP server.

    Sorry if my answer is of no help to you. If you plan to utilize WSDL (and document/literal SOAP) you should also see XML::Compile.

      Actually I was given a google api example
      #!/usr/bin/perl -w use SOAP::Lite; my $query = "perl"; my $googleSearch = SOAP::Lite -> service("http://api.google.com/Google +Search.wsdl"); my $result = $googleSearch -> doGoogleSearch( "iwnUXUtHj3bteg5FWfBJDwui3SPeB+iy", # password to access googl +e $query, 0, # Fisrt result 10, # Number of results "false", # Filter '', # Restriction "false", # Secure Search '', # lr 'latin1', # ie 'latin1' # oe ); print $result->{resultElements}->[0]->{title}; print "\n"; print $result->{resultElements}->[0]->{URL}; print "\n";
      I want to create google search on my web site which is developed using perl/CGI.
      So as far as I understand the result of calling this api should be generated HTML with google links, java scripts, etc. Im I right?

        Fortunately this WSDL is rpc/encoded so SOAP::Lite converts the response SOAP document into reasonable perl structure.

        As you found the result of doGoogleSearch call is a reference to a hash with keys ( "searchTime", "endIndex", "searchComments", "documentFiltering", "searchTips", "estimatedTotalResultsCount", "searchQuery", "startIndex", "resultElements", "directoryCategories", "estimateIsExact"). The hash can be analyzed the way you did. Actually the hash reference is an object - it is blessed into GoogleSearchResult package - but this package is empty, so there is no object api available.