blib/lib/W3C/SOAP/WSDL/Document.pm

filter: Statementstmt 69.1% 103 / 149 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 72.0% 18 / 25 Podpod 100% 2 / 2 totaltotal 66.3% 130 / 196 CC 24 SCAR 15.6
CC
24
Cov
67%
_schemas
10.0
xsd_modules
6.2
_message
6.0
CRAP 4.8
« blib/lib/W3C/SOAP/WSDL/Document/Message.pm ↑ Summary Build »
1 package W3C::SOAP::WSDL::Document;
2  
3 # Created on: 2012-05-27 18:57:29
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use W3C::SOAP::XSD::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use W3C::SOAP::WSDL::Document::Binding;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use W3C::SOAP::WSDL::Document::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use W3C::SOAP::WSDL::Document::PortType;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use W3C::SOAP::WSDL::Document::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 extends 'W3C::SOAP::Document';
22  
23 5 our $VERSION = 0.13;
24  
25 5 has messages => (
26 is => 'rw',
27 isa => 'ArrayRef[W3C::SOAP::WSDL::Document::Message]',
28 builder => '_messages',
29 lazy => 1,
30 );
31 5 has message => (
32 is => 'rw',
33 isa => 'HashRef[W3C::SOAP::WSDL::Document::Message]',
34 builder => '_message',
35 lazy => 1,
36 weak_ref => 1,
37 );
38 5 has port_types => (
39 is => 'rw',
40 isa => 'ArrayRef[W3C::SOAP::WSDL::Document::PortType]',
41 builder => '_port_types',
42 lazy => 1,
43 );
44 5 has port_type => (
45 is => 'rw',
46 isa => 'HashRef[W3C::SOAP::WSDL::Document::PortType]',
47 builder => '_port_type',
48 lazy => 1,
49 weak_ref => 1,
50 );
51 5 has bindings => (
52 is => 'rw',
53 isa => 'ArrayRef[W3C::SOAP::WSDL::Document::Binding]',
54 builder => '_bindings',
55 lazy => 1,
56 );
57 5 has binding => (
58 is => 'rw',
59 isa => 'HashRef[W3C::SOAP::WSDL::Document::Binding]',
60 builder => '_binding',
61 lazy => 1,
62 weak_ref => 1,
63 );
64 5 has services => (
65 is => 'rw',
66 isa => 'ArrayRef[W3C::SOAP::WSDL::Document::Service]',
67 builder => '_services',
68 lazy => 1,
69 );
70 5 has service => (
71 is => 'rw',
72 isa => 'HashRef[W3C::SOAP::WSDL::Document::Service]',
73 builder => '_service',
74 lazy => 1,
75 weak_ref => 1,
76 );
77 5 has policies => (
78 is => 'rw',
79 isa => 'ArrayRef[W3C::SOAP::WSDL::Document::Policy]',
80 builder => '_policies',
81 lazy => 1,
82 weak_ref => 1,
83 );
84 5 has policy => (
85 is => 'rw',
86 isa => 'HashRef[W3C::SOAP::WSDL::Document::Policy]',
87 builder => '_policy',
88 lazy => 1,
89 weak_ref => 1,
90 );
91 5 has schemas => (
92 is => 'rw',
93 isa => 'ArrayRef[W3C::SOAP::XSD::Document]',
94 builder => '_schemas',
95 lazy => 1,
96 );
97 5 has schema => (
98 is => 'rw',
99 isa => 'HashRef[W3C::SOAP::XSD::Document]',
100 builder => '_schema',
101 lazy => 1,
102 weak_ref => 1,
103 );
104  
105 sub _messages {
106 4 ▶ my ($self) = @_;
Subroutine _messages: called CC=2 SCAR=6.9
107 4 my @messages;
108 4 my @nodes = $self->xpc->findnodes('//wsdl:message');
109  
110 4 for my $node (@nodes) {
111 14 push @messages, W3C::SOAP::WSDL::Document::Message->new(
112 document => $self,
113 node => $node,
114 );
115 }
116  
117 4 return \@messages;
118 }
119  
120 sub _message {
121 0 ▶ my ($self) = @_;
Subroutine _message: not called CC=2 SCAR=17.9
122 0 my %message;
123 0 for my $message ( @{ $self->messages }) {
124 0 $message{$message->name} = $message;
125 }
126  
127 0 return \%message;
128 }
129  
130 sub _port_types {
131 4 ▶ my ($self) = @_;
Subroutine _port_types: called CC=2 SCAR=6.9
132 4 my @port_types;
133 4 my @nodes = $self->xpc->findnodes('//wsdl:portType');
134  
135 4 for my $node (@nodes) {
136 4 push @port_types, W3C::SOAP::WSDL::Document::PortType->new(
137 document => $self,
138 node => $node,
139 );
140 }
141  
142 4 return \@port_types;
143 }
144  
145 sub _port_type {
146 0 ▶ my ($self) = @_;
Subroutine _port_type: not called CC=2 SCAR=17.9
147 0 my %port_type;
148 0 for my $port_type ( @{ $self->port_type }) {
149 0 $port_type{$port_type->name} = $port_type;
150 }
151  
152 0 return \%port_type;
153 }
154  
155 sub _bindings {
156 4 ▶ my ($self) = @_;
Subroutine _bindings: called CC=2 SCAR=6.9
157 4 my @bindings;
158 4 my @nodes = $self->xpc->findnodes('//wsdl:binding');
159  
160 4 for my $node (@nodes) {
161 4 push @bindings, W3C::SOAP::WSDL::Document::Binding->new(
162 document => $self,
163 node => $node,
164 );
165 }
166  
167 4 return \@bindings;
168 }
169  
170 sub _binding {
171 0 ▶ my ($self) = @_;
Subroutine _binding: not called CC=2 SCAR=17.9
172 0 my %binding;
173 0 for my $binding ( @{ $self->binding }) {
174 0 $binding{$binding->name} = $binding;
175 }
176  
177 0 return \%binding;
178 }
179  
180 sub _services {
181 4 ▶ my ($self) = @_;
Subroutine _services: called CC=2 SCAR=6.9
182 4 my @services;
183 4 my @nodes = $self->xpc->findnodes('//wsdl:service');
184  
185 4 for my $node (@nodes) {
186 4 push @services, W3C::SOAP::WSDL::Document::Service->new(
187 document => $self,
188 node => $node,
189 );
190 }
191  
192 4 return \@services;
193 }
194  
195 sub _service {
196 0 ▶ my ($self) = @_;
Subroutine _service: not called CC=2 SCAR=17.9
197 0 my %service;
198 0 for my $service ( @{ $self->service }) {
199 0 $service{$service->name} = $service;
200 }
201  
202 0 return \%service;
203 }
204  
205 sub _policies {
206 0 ▶ my ($self) = @_;
Subroutine _policies: not called CC=2 SCAR=17.9
207 0 my @policies;
208 0 my @nodes = $self->xpc->findnodes('/*/wsp:Policy');
209  
210 0 for my $node (@nodes) {
211 0 push @policies, W3C::SOAP::WSDL::Document::Policy->new(
212 document => $self,
213 node => $node,
214 );
215 }
216  
217 0 return \@policies;
218 }
219  
220 sub _policy {
221 0 ▶ my ($self) = @_;
Subroutine _policy: not called CC=2 SCAR=17.9
222 0 my %service;
223 0 for my $service ( @{ $self->service }) {
224 0 $service{$service->sec_id} = $service;
225 }
226  
227 0 return \%service;
228 }
229  
230 sub _schemas {
231 4 ▶ my ($self) = @_;
Subroutine _schemas: called CC=8 SCAR=23.0
232 4 my @schemas;
233 4 my @nodes = $self->xpc->findnodes('//wsdl:types/*');
234  
235 4 for my $node (@nodes) {
236 4 ▶ next if $node->getAttribute('namespace') && $node->getAttribute('namespace') eq 'http://www.w3.org/2001/XMLSchema';
Branch: 1 branch
BranchTrueFalseTotal
if $node->getAttribute("namespace") and $node->getAttribute("namespace") eq "http://www.w3.org/2001/XMLSchema" 0 4 4
Condition33%1/3
$node->getAttribute("namespace") and $node->getAttribute("namespace") eq "http://www.w3.org/2001/XMLSchema"
!ll&&!rl&&r
400
MC/DC0%0/2
$node->getAttribute("namespace") and $node->getAttribute("namespace") eq "http://www.w3.org/2001/XMLSchema"
$node->getAttribute("namespace") $node->getAttribute("namespace") eq "http://www.w3.org/2001/XMLSchema"
Truth table33%1/3
A and B
A= $node->getAttribute("namespace")B= $node->getAttribute("namespace") eq "http://www.w3.org/2001/XMLSchema"
ABresult
0X0
100
111
237  
238 # merge document namespaces into the schema's tags
239 4 my $doc = $self->xml->getDocumentElement;
240 4 my @attribs = $doc->getAttributes;
241 4 ▶ for my $ns ( grep {$_->name =~ /^xmlns:/ && !$node->getAttribute($_->name)} @attribs ) {
Branch: 1 branch
BranchTrueFalseTotal
$_->name =~ /^xmlns:/ and not $node->getAttribute($_->name) 20 6 26
242 20 $node->setAttribute( $ns->name, 'value' );
243 20 $node->setAttribute( $ns->name, $ns->value );
244 }
245  
246 4 my @args;
247 4 ▶ if ( $self->has_module_base ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_module_base) 0 4 4
248 0 my $base = $self->module_base;
249 0 $base =~ s/WSDL/XSD/;
250 0 ▶ $base .= '::XSD' if $base !~ /XSD/;
Branch: 1 branch
BranchTrueFalseTotal
unless $base =~ /XSD/ 0 0 0
251 0 push @args, ( module_base => $base );
252 }
253  
254 4 push @schemas, W3C::SOAP::XSD::Document->new(
255 string => $node->toString,
256 ns_module_map => $self->ns_module_map,
257 @args,
258 );
259 4 $schemas[-1]->location($self->location);
260 4 $schemas[-1]->target_namespace;
261 }
262  
263 4 return \@schemas;
264 }
265  
266 sub _schema {
267 0 ▶ my ($self) = @_;
Subroutine _schema: not called CC=2 SCAR=17.9
268 0 my %schema;
269 0 for my $schema ( @{ $self->schemas }) {
270 0 $schema{$schema->target_namespace} = $schema;
271 }
272  
273 0 return \%schema;
274 }
275  
276 sub get_nsuri {
277 14 ▶ my ($self, $ns) = @_;
Subroutine get_nsuri: called CC=1 SCAR=0.0
Pod documented
278 14 my ($node) = $self->xpc->findnodes("//namespace::*[name()='$ns']");
279 14 return $node->value;
280 }
281  
282 sub xsd_modules {
283 2 ▶ my ($self) = @_;
Subroutine xsd_modules: called CC=6 SCAR=18.3
Pod documented
284 2 my %modules;
285  
286 2 for my $service (@{ $self->services }) {
287 2 for my $port (@{ $service->ports }) {
288 2 for my $operation (@{ $port->binding->operations }) {
289 4 ▶ if ( $operation->port_type->outputs->[0] && $operation->port_type->outputs->[0]->message->element ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operation->port_type->outputs->[0] and $operation->port_type->outputs->[0]->message->element) 4 0 4
Condition33%1/3
$operation->port_type->outputs->[0] and $operation->port_type->outputs->[0]->message->element
!ll&&!rl&&r
004
MC/DC0%0/2
$operation->port_type->outputs->[0] and $operation->port_type->outputs->[0]->message->element
$operation->port_type->outputs->[0] $operation->port_type->outputs->[0]->message->element
Truth table33%1/3
A and B
A= $operation->port_type->outputs->[0]B= $operation->port_type->outputs->[0]->message->element
ABresult
0X0
100
111
290 4 $modules{$operation->port_type->outputs->[0]->message->element->module}++;
291 }
292 }
293 }
294 }
295  
296 2 return ( sort keys %modules );
297 }
298  
299 5 1;
300  
301 __END__
302  
303 =head1 NAME
304  
305 W3C::SOAP::WSDL::Document - Object to represent a WSDL Document
306  
307 =head1 VERSION
308  
309 This documentation refers to W3C::SOAP::WSDL::Document version 0.13.
310  
311 =head1 SYNOPSIS
312  
313 use W3C::SOAP::WSDL::Document;
314  
315 # Brief but working code example(s) here showing the most common usage(s)
316 # This section will be as far as many users bother reading, so make it as
317 # educational and exemplary as possible.
318  
319 =head1 DESCRIPTION
320  
321 Top level look at a WSDL, supplies access to messages, services etc defined
322 in the WSDL.
323  
324 =head1 SUBROUTINES/METHODS
325  
326 =over 4
327  
328 =item C<get_nsuri ()>
329  
330 =item C<xsd_modules ()>
331  
332 =back
333  
334 =head1 DIAGNOSTICS
335  
336 =head1 CONFIGURATION AND ENVIRONMENT
337  
338 =head1 DEPENDENCIES
339  
340 =head1 INCOMPATIBILITIES
341  
342 =head1 BUGS AND LIMITATIONS
343  
344 There are no known bugs in this module.
345  
346 Please report problems to Ivan Wills (ivan.wills@gmail.com).
347  
348 Patches are welcome.
349  
350 =head1 AUTHOR
351  
352 Ivan Wills - (ivan.wills@gmail.com)
353  
354 =head1 LICENSE AND COPYRIGHT
355  
356 Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
357 All rights reserved.
358  
359 This module is free software; you can redistribute it and/or modify it under
360 the same terms as Perl itself. See L<perlartistic>. This program is
361 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
362 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
363 PARTICULAR PURPOSE.
364  
365 =cut
« blib/lib/W3C/SOAP/WSDL/Document/Message.pm ↑ Summary Build »