| 1 | =pod | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | WSDL::Generator::Base - Base class for WSDL::Generator::* | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | use base 'WSDL::Generator::Base'; | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||
| 12 | package WSDL::Generator::Base; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use warnings::register; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | our %WSDL = ( | |||||||||||||||||||||||||||
| 21 | ELEMENT => [ '<xsd:element name="[%name%]" type="xsd:[%type%]" />' ], | ||||||||||||||||||||||||||||
| 22 | ARRAYREF => [ '<xsd:element minOccurs="[%min_occur%]" maxOccurs="[%max_occur%]" name="[%name%]" wsdl:arrayType="xsd:[%type%][]" />' ], | ||||||||||||||||||||||||||||
| 23 | HASHREF => [ | ||||||||||||||||||||||||||||
| 24 | '<xsd:complexType name="[%name%]">', | ||||||||||||||||||||||||||||
| 25 | [ | ||||||||||||||||||||||||||||
| 26 | '<xsd:sequence>', | ||||||||||||||||||||||||||||
| 27 | ['@[%elements%]'], | ||||||||||||||||||||||||||||
| 28 | '</xsd:sequence>', | ||||||||||||||||||||||||||||
| 29 | ], | ||||||||||||||||||||||||||||
| 30 | '</xsd:complexType>', | ||||||||||||||||||||||||||||
| 31 | ], | ||||||||||||||||||||||||||||
| 32 | TYPES => [ | ||||||||||||||||||||||||||||
| 33 | '<types>', | ||||||||||||||||||||||||||||
| 34 | [ | ||||||||||||||||||||||||||||
| 35 | '<xsd:schema targetNamespace="[%schema_namesp%]">', | ||||||||||||||||||||||||||||
| 36 | ['@[%schema%]'], | ||||||||||||||||||||||||||||
| 37 | '</xsd:schema>', | ||||||||||||||||||||||||||||
| 38 | ], | ||||||||||||||||||||||||||||
| 39 | '</types>', | ||||||||||||||||||||||||||||
| 40 | ], | ||||||||||||||||||||||||||||
| 41 | MESSAGE => [ | ||||||||||||||||||||||||||||
| 42 | '<message name="[%methodRe%]">', | ||||||||||||||||||||||||||||
| 43 | [ '<part name="[%methodRe%]SoapMsg" element="xsdl:[%type%]"/>' ], | ||||||||||||||||||||||||||||
| 44 | '</message>', | ||||||||||||||||||||||||||||
| 45 | ], | ||||||||||||||||||||||||||||
| 46 | PORTTYPE_OPERATION => | ||||||||||||||||||||||||||||
| 47 | [ '<operation name="[%method%]">', | ||||||||||||||||||||||||||||
| 48 | [ | ||||||||||||||||||||||||||||
| 49 | '<input message="tns:[%request%]" />', | ||||||||||||||||||||||||||||
| 50 | '<output message="tns:[%response%]" />', | ||||||||||||||||||||||||||||
| 51 | ], | ||||||||||||||||||||||||||||
| 52 | '</operation>', | ||||||||||||||||||||||||||||
| 53 | ], | ||||||||||||||||||||||||||||
| 54 | PORTTYPE => [ | ||||||||||||||||||||||||||||
| 55 | '<portType name="[%services%][%service_name%]PortType">', | ||||||||||||||||||||||||||||
| 56 | ['@[%porttype_operation%]'], | ||||||||||||||||||||||||||||
| 57 | '</portType>', | ||||||||||||||||||||||||||||
| 58 | ], | ||||||||||||||||||||||||||||
| 59 | BINDING_OPERATION => | ||||||||||||||||||||||||||||
| 60 | [ | ||||||||||||||||||||||||||||
| 61 | '<operation name="[%method%]">', | ||||||||||||||||||||||||||||
| 62 | [ | ||||||||||||||||||||||||||||
| 63 | '<soap:operation style="document" soapAction=""/>', | ||||||||||||||||||||||||||||
| 64 | '<input>', | ||||||||||||||||||||||||||||
| 65 | [ '<soap:body use="literal"/>' ], | ||||||||||||||||||||||||||||
| 66 | '</input>', | ||||||||||||||||||||||||||||
| 67 | '<output>', | ||||||||||||||||||||||||||||
| 68 | [ '<soap:body use="literal"/>' ], | ||||||||||||||||||||||||||||
| 69 | '</output>', | ||||||||||||||||||||||||||||
| 70 | ], | ||||||||||||||||||||||||||||
| 71 | '</operation>', | ||||||||||||||||||||||||||||
| 72 | ], | ||||||||||||||||||||||||||||
| 73 | BINDING => | ||||||||||||||||||||||||||||
| 74 | [ | ||||||||||||||||||||||||||||
| 75 | '<binding name="[%services%][%service_name%]Binding" type="tns:[%services%][%service_name%]PortType">', | ||||||||||||||||||||||||||||
| 76 | [ | ||||||||||||||||||||||||||||
| 77 | '<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>', | ||||||||||||||||||||||||||||
| 78 | ['@[%binding_operation%]'], | ||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||
| 80 | '</binding>', | ||||||||||||||||||||||||||||
| 81 | ], | ||||||||||||||||||||||||||||
| 82 | SERVICE => | ||||||||||||||||||||||||||||
| 83 | [ | ||||||||||||||||||||||||||||
| 84 | '<service name="[%service_name%]">', | ||||||||||||||||||||||||||||
| 85 | [ | ||||||||||||||||||||||||||||
| 86 | '<documentation>', | ||||||||||||||||||||||||||||
| 87 | [ | ||||||||||||||||||||||||||||
| 88 | '[%documentation%]', | ||||||||||||||||||||||||||||
| 89 | ], | ||||||||||||||||||||||||||||
| 90 | '</documentation>', | ||||||||||||||||||||||||||||
| 91 | '<port name="[%services%][%service_name%]Port" binding="tns:[%services%][%service_name%]Binding">', | ||||||||||||||||||||||||||||
| 92 | [ | ||||||||||||||||||||||||||||
| 93 | '<soap:address location="[%location%]"/>', | ||||||||||||||||||||||||||||
| 94 | ], | ||||||||||||||||||||||||||||
| 95 | '</port>', | ||||||||||||||||||||||||||||
| 96 | ], | ||||||||||||||||||||||||||||
| 97 | '</service>', | ||||||||||||||||||||||||||||
| 98 | ], | ||||||||||||||||||||||||||||
| 99 | DEFINITIONS => | ||||||||||||||||||||||||||||
| 100 | [ | ||||||||||||||||||||||||||||
| 101 | '<definitions name="[%service_name%]" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="[%target_namesp%]" xmlns:tns="[%target_namesp%]" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsdl="[%schema_namesp%]">', | ||||||||||||||||||||||||||||
| 102 | ['@[%schema%]'], | ||||||||||||||||||||||||||||
| 103 | ['@[%message%]'], | ||||||||||||||||||||||||||||
| 104 | ['@[%porttype%]'], | ||||||||||||||||||||||||||||
| 105 | ['@[%binding%]'], | ||||||||||||||||||||||||||||
| 106 | ['@[%service%]'], | ||||||||||||||||||||||||||||
| 107 | '</definitions>', | ||||||||||||||||||||||||||||
| 108 | ], | ||||||||||||||||||||||||||||
| 109 | WSDL => | ||||||||||||||||||||||||||||
| 110 | [ | ||||||||||||||||||||||||||||
| 111 | '<?xml version="1.0"?>', | ||||||||||||||||||||||||||||
| 112 | '@[%definitions%]', | ||||||||||||||||||||||||||||
| 113 | ], | ||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =pod | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =head1 METHODS | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head2 get_wsdl_element($param, $tab) | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | $param contains the parameters to parse the element template. | ||||||||||||||||||||||||||||
| 123 | $tab is the depth of the structure - optional - useful for indented display. | ||||||||||||||||||||||||||||
| 124 | Returns an array of elements ready to be displayed. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =cut | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub get_wsdl_element { | ||||||||||||||||||||||||||
|
Subroutine
get_wsdl_element: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 0 | my ($self, $param, $depth) = @_; | |||||||||||||||||||||||||||
| 130 | 0 | ▶ | $param->{min_occur} = 1 unless (exists $param->{min_occur} and defined $param->{min_occur}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $param->{"min_occur"} and defined $param->{"min_occur"}
MC/DC0%0/2
exists $param->{"min_occur"} and defined $param->{"min_occur"}
exists $param->{"min_occur"}
defined $param->{"min_occur"}
Truth table0%0/3
A and B
A= exists $param->{"min_occur"}B= defined $param->{"min_occur"}
| |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | $param->{max_occur} = 1 unless (exists $param->{max_occur} and defined $param->{max_occur}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $param->{"max_occur"} and defined $param->{"max_occur"}
MC/DC0%0/2
exists $param->{"max_occur"} and defined $param->{"max_occur"}
exists $param->{"max_occur"}
defined $param->{"max_occur"}
Truth table0%0/3
A and B
A= exists $param->{"max_occur"}B= defined $param->{"max_occur"}
| |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $depth ||= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$depth ||= 0
MC/DC0%0/1
$depth ||= 0
$depth
Truth table0%0/2
A
A= $depth
| |||||||||||||||||||||||||||||
| 133 | 0 | my $element = $WSDL{$param->{wsdl_type}}; | |||||||||||||||||||||||||||
| 134 | 0 | my @return = $self->get_wsdl_element_recurse($param, $element, $depth - 1); | |||||||||||||||||||||||||||
| 135 | 0 | return bless \@return => ref($self); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =pod | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =head2 to_string() | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | Returns a string containing lines of WSDL data | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub to_string { | ||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 146 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 147 | 0 | my $string = ''; | |||||||||||||||||||||||||||
| 148 | 0 | foreach ( @$self ) { | |||||||||||||||||||||||||||
| 149 | 0 | $string .= "\t" x $_->{depth} . $_->{content} . "\n"; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 0 | return $string; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =pod | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =head2 dumper($struct) | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | Extends the data structure received by adding data type infos at each branch | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =cut | ||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub dumper { | ||||||||||||||||||||||||||
|
Subroutine
dumper: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 163 | 0 | my ($self, $param) = @_; | |||||||||||||||||||||||||||
| 164 | 0 | my $branch = {}; | |||||||||||||||||||||||||||
| 165 | 0 | my $ref = ref($param); | |||||||||||||||||||||||||||
| 166 | 0 | ▶ | if (! $ref) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 167 | 0 | $branch->{type} = 'SCALAR'; | |||||||||||||||||||||||||||
| 168 | 0 | $branch->{value} = $param; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if (@$param) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | $branch->{type} = 'ARRAYREF'; | |||||||||||||||||||||||||||
| 173 | 0 | foreach my $elem (@$param) { | |||||||||||||||||||||||||||
| 174 | 0 | push @{$branch->{value}}, $self->dumper($elem); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||
| 178 | 0 | $branch->{type} = 'SCALAR'; | |||||||||||||||||||||||||||
| 179 | 0 | $branch->{value} = undef; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | else { | ||||||||||||||||||||||||||||
| 183 | 0 | $branch->{type} = 'HASHREF'; | |||||||||||||||||||||||||||
| 184 | 0 | foreach my $key (keys %$param) { | |||||||||||||||||||||||||||
| 185 | 0 | $branch->{value}->{$key} = $self->dumper($param->{$key}); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | 0 | return $branch; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub get_wsdl_element_recurse { | ||||||||||||||||||||||||||
|
Subroutine
get_wsdl_element_recurse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 193 | 0 | my ($self, $param, $array, $depth) = @_; | |||||||||||||||||||||||||||
| 194 | 0 | $depth++; | |||||||||||||||||||||||||||
| 195 | 0 | my @lines = (); | |||||||||||||||||||||||||||
| 196 | 0 | foreach my $elt (@$array) { | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | if (ref $elt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | push @lines, $self->get_wsdl_element_recurse($param, $elt, $depth); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | else { | ||||||||||||||||||||||||||||
| 201 | 0 | my $parsed = $elt; | |||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($parsed =~ /^\@\[%(.+?)%\]/ and ref $param->{$1}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parsed =~ /^\@\[%(.+?)%\]/ and ref $param->{$1}
MC/DC0%0/2
$parsed =~ /^\@\[%(.+?)%\]/ and ref $param->{$1}
$parsed =~ /^\@\[%(.+?)%\]/
ref $param->{$1}
Truth table0%0/3
A and B
A= $parsed =~ /^\@\[%(.+?)%\]/B= ref $param->{$1}
| |||||||||||||||||||||||||||||
| 203 | 0 | foreach my $element ( @{$param->{$1}} ) { | |||||||||||||||||||||||||||
| 204 | 0 | my $parsed2 = $parsed; | |||||||||||||||||||||||||||
| 205 | 0 | $parsed2 =~ s/\@\[%(.+?)%\]/$element->{content}/gi; | |||||||||||||||||||||||||||
| 206 | push @lines, { content => $parsed2, | ||||||||||||||||||||||||||||
| 207 | 0 | depth => $element->{depth}+$depth }; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 0 | $parsed =~ s/\@\[%(.+?)%\]//g; | |||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ($parsed =~ s/\[%(.+?)%\]/$param->{$1}/gi) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | push @lines, { content => $parsed, | |||||||||||||||||||||||||||
| 212 | depth => $depth }; | ||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | else { | ||||||||||||||||||||||||||||
| 216 | 0 | $parsed =~ s/\[%(.+?)%\]/$param->{$1}/gi; | |||||||||||||||||||||||||||
| 217 | 0 | push @lines, { content => $parsed, | |||||||||||||||||||||||||||
| 218 | depth => $depth }; | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | 0 | return @lines; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1 | 1; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =pod | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | WSDL::Generator | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | "Pierre Denis" <pdenis@fotango.com> | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | Copyright (C) 2001, Fotango Ltd - All rights reserved. | ||||||||||||||||||||||||||||
| 240 | This is free software. This software may be modified and/or distributed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =cut | ||||||||||||||||||||||||||||