blib/lib/W3C/SOAP.pm

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