Friday, January 13, 2012

How to test #SOAP #WebServices from #PERL command line

Code-generation based on WSDL

Another way in which the SOAP::Lite package provides support for WSDL is through a tool that comes with the package called stubmaker.pl.

The stubmaker.pl tool is a handy utility that both demonstrates the WSDL support in SOAP::Lite and produces a useful result. When run against a WSDL file or URL that refers to a WSDL resource, it generates a loadable Perl module from the services defined by the WSDL.The resulting file’s name is based on the class name that would be selected if the service were loaded directly by a SOAP::Lite client object. The WSDL for the WSDL describing the WishList service would yield a file called WishListCustomer.pm (which would be very different from the file by that name in the software project), while the WSDL for the use.perl.org journal system would yield UsePerlJournal.pm. Calling the tool is simple enough:

Generates code:

$perl stubmaker.pl file:./useperlorg.wsdl $ls $stubmaker.pl useperlorg.wsdl useperlorg.pm

Once the stub file has been generated, it can then be used in a client in place of explicitly configuring the client settings:

$perl -MUsePerlJournal -e 'get_entries(shift, shift)' 1 15

From: Programming Web Services with Perl By: Randy J. Ray & Pavel Kulchenko ISBN: 0-596-00206-8

No comments: