File Coverage

blib/lib/W3C/SOAP.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package W3C::SOAP;
2              
3             # Created on: 2012-06-29 07:52:54
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   889 use Moose;
  1         352303  
  1         8  
10 1     1   5434 use warnings;
  1         2  
  1         24  
11 1     1   593 use version;
  1         1517  
  1         6  
12 1     1   53 use Carp;
  1         1  
  1         67  
13 1     1   481 use English qw/ -no_match_vars /;
  1         1578  
  1         6  
14 1     1   823 use W3C::SOAP::XSD::Parser qw/load_xsd/;
  0            
  0            
15             use W3C::SOAP::WSDL::Parser qw/load_wsdl/;
16              
17             Moose::Exporter->setup_import_methods(
18             as_is => [qw/load_wsdl load_xsd/],
19             );
20              
21             our $VERSION = version->new('0.11');
22              
23             1;
24              
25             __END__
26              
27             =head1 NAME
28              
29             W3C::SOAP - Static and dynamic SOAP client generator from WSDL & XSD files
30              
31             =head1 VERSION
32              
33             This documentation refers to W3C::SOAP version 0.11.
34              
35             =head1 SYNOPSIS
36              
37             # Dynamically created clients
38             use W3C::SOAP qw/load_wsdl/;
39              
40             # load some wsdl file
41             my $wsdl = load_wsdl("http://example.com/eg.wsdl");
42              
43             # call a method exported by the WSDL
44             $wsdl->some_method( HASH | HASH_REF );
45              
46             # A real world example
47             my $wsdl = load_wsdl('http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl');
48             my $res = $wsdl->resolve_ip( ip_address => '59.106.161.11', license_key => 0 );
49             printf "lat: %.4f\n", $res->resolve_ipresult->latitude;
50              
51             # load some xsd file
52             my $xsd = load_xsd("http://example.com/eg.xsd");
53              
54             # create a new object of of the XSD
55             my $obj = $xsd->new( HASH | HASH_REF );
56              
57             # Statically created clients
58             # on the command line build Client module (and included XSD modules)
59             # see wsdl-parser --help for more details
60             $ wsdl-parser -b ResolveIP ResolveIP 'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl'
61              
62             # back in perl
63              
64             # the default directory modules are created into
65             use lib 'lib';
66             # load the ResolveIP client module
67             use ResolveIP;
68             # Create a client object
69             my $client = ResolveIP->new();
70             # call the WS
71             my $res = $client->resolve_ip( ip_address => '59.106.161.11', license_key => 0 );
72             # show the results
73             printf "lat: %.4f\n", $res->resolve_ipresult->latitude;
74              
75             =head1 DESCRIPTION
76              
77             A perly SOAP client library. To see more details on how to generate a WSDL client
78             see L<W3C::SOAP::WSDL::Parser>, and for generating Moose objects from XSD files
79             see L<W3C::SOAP::XSD::Parser>.
80              
81             =head2 Gotchas
82              
83             Java style camel case names are converted to the more legible Perl style underscore
84             separated names for everything that doesn't end up being a Perl package or Moose
85             type. Eg in the Synopsis the operation defined in the IP 2 GEO WSDL is defined as
86             ResolveIP this is translated to the perly name resolve_ip.
87              
88             =head2 Debugging
89              
90             When something goes wrong there are two ways to see what XML is being sent and
91             received.
92              
93             =over 4
94              
95             =item 1
96              
97             The C<$W3C_SOAP_DEBUG_CLIENT> environment variable will cause the all request
98             and response HTTP bodies to be dumped to STDOUT. The length of the content is
99             limited to 1024 by default but this can be changed with the
100             C<$W3C_SOAP_DEBUG_LENGTH> environment variable.
101              
102             =item 2
103              
104             Supplying a log object. When a client is instantiated you can supply it a log
105             object or after creation supply the C<log> method with a log object, the only
106             restriction is that it implements C<debug, info, warn, error and fatal>
107             methods. L<Log::Log4perl> and C<Catalyst::Log> are known working examples.
108              
109             eg
110             my $client = ResolveIP->new(log => $log);
111             or
112             $client->log($log);
113              
114             =back
115              
116             Both methods can be used together.
117              
118             =head1 SUBROUTINES/METHODS
119              
120             =over 4
121              
122             =item C<load_wsdl ($wsdl_location)>
123              
124             Loads a WSDL file, parses is and generates dynamic Moose objects that represent
125             the WSDL file and any XML Schema xsd content that it refers to.
126              
127             See L<W3C::SOAP::WSDL::Parser> for more details.
128              
129             =item C<load_xsd ($xsd_location)>
130              
131             Loads an XML Schema (.xsd) file, parses is and generates dynamic Moose objects
132             that representing that schema and any other included/imported XML Schema
133             content that it refers to.
134              
135             See L<W3C::SOAP::XSD::Parser> for more details.
136              
137             =back
138              
139             =head1 DIAGNOSTICS
140              
141             =head1 CONFIGURATION AND ENVIRONMENT
142              
143             =over 4
144              
145             =item C<$W3C_SOAP_DEBUG_CLIENT>
146              
147             If this environment variable is a true value it will turn on printing request
148             and response HTTP messages bodies to STDOUT.
149              
150             =item C<$W3C_SOAP_DEBUG_LENGTH>
151              
152             Alter the amount of data shown by C<$W3C_SOAP_DEBUG_CLIENT> which defaults to
153             1024.
154              
155             =back
156              
157             =head1 DEPENDENCIES
158              
159             =head1 INCOMPATIBILITIES
160              
161             Perl 5.18 see below.
162              
163             =head1 BUGS AND LIMITATIONS
164              
165             Currently the WSDL handling doesn't deal with more than one input or output
166             on an operation or inputs/outputs that aren't specified by an XMLSchema. A;so
167             operation fault objects aren't yet handled.
168              
169             Currently there is an issue with Perl 5.18 (probably caused by L<Moose> affecting
170             L<XML::LibXML> usage)
171              
172             Please report problems to Ivan Wills (ivan.wills@gmail.com).
173              
174             Patches are welcome.
175              
176             =head1 ALSO SEE
177              
178             L<wsdl-parser>, L<W3C::SOAP::Client>, L<XML::LibXML>, L<Moose>, L<MooseX::Types::XMLSchema>
179              
180             Inspired by L<SOAP::WSDL> & L<SOAP::Lite>
181              
182             =head1 AUTHOR
183              
184             Ivan Wills - (ivan.wills@gmail.com)
185              
186             =head1 LICENSE AND COPYRIGHT
187              
188             Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW 2077 Australia).
189             All rights reserved.
190              
191             This module is free software; you can redistribute it and/or modify it under
192             the same terms as Perl itself. See L<perlartistic>. This program is
193             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
194             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
195             PARTICULAR PURPOSE.
196              
197             =cut