W3C::SOAP - Static and dynamic SOAP client generator from WSDL & XSD files
This documentation refers to W3C::SOAP version 0.14.
# Dynamically created clients use W3C::SOAP qw/load_wsdl/; # load some wsdl file my $wsdl = load_wsdl("http://example.com/eg.wsdl"); # call a method exported by the WSDL $wsdl->some_method( HASH | HASH_REF ); # A real world example my $wsdl = load_wsdl('http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl'); my $res = $wsdl->resolve_ip( ip_address => '184.108.40.206', license_key => 0 ); printf "lat: %.4f\n", $res->resolve_ipresult->latitude; # load some xsd file my $xsd = load_xsd("http://example.com/eg.xsd"); # create a new object of of the XSD my $obj = $xsd->new( HASH | HASH_REF ); # Statically created clients # on the command line build Client module (and included XSD modules) # see wsdl-parser --help for more details $ wsdl-parser -b ResolveIP ResolveIP 'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl' # back in perl # the default directory modules are created into use lib 'lib'; # load the ResolveIP client module use ResolveIP; # Create a client object my $client = ResolveIP->new(); # call the WS my $res = $client->resolve_ip( ip_address => '220.127.116.11', license_key => 0 ); # show the results printf "lat: %.4f\n", $res->resolve_ipresult->latitude;
Java style camel case names are converted to the more legible Perl style underscore separated names for everything that doesn't end up being a Perl package or Moose type. Eg in the Synopsis the operation defined in the IP 2 GEO WSDL is defined as ResolveIP this is translated to the perly name resolve_ip.
When something goes wrong there are two ways to see what XML is being sent and received.
$W3C_SOAP_DEBUG_CLIENTenvironment variable will cause the all request and response HTTP bodies to be dumped to STDOUT. The length of the content is limited to 1024 by default but this can be changed with the
logmethod with a log object, the only restriction is that it implements
debug, info, warn, error and fatalmethods. Log::Log4perl and
Catalyst::Logare known working examples.
eg my $client = ResolveIP->new(log => $log); or $client->log($log);
Both methods can be used together.
Loads a WSDL file, parses is and generates dynamic Moose objects that represent the WSDL file and any XML Schema xsd content that it refers to.
See W3C::SOAP::WSDL::Parser for more details.
Loads an XML Schema (.xsd) file, parses is and generates dynamic Moose objects that representing that schema and any other included/imported XML Schema content that it refers to.
See W3C::SOAP::XSD::Parser for more details.
If this environment variable is a true value it will turn on printing request and response HTTP messages bodies to STDOUT.
Alter the amount of data shown by
$W3C_SOAP_DEBUG_CLIENT which defaults to 1024.
Perl 5.18 see below.
Currently the WSDL handling doesn't deal with more than one input or output on an operation or inputs/outputs that aren't specified by an XMLSchema. A;so operation fault objects aren't yet handled.
Please report problems to Ivan Wills (email@example.com).
Patches are welcome.
Ivan Wills - (firstname.lastname@example.org)
Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW 2077 Australia). All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.