| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
package SOAP::WSDL::Serializer::XSD; |
|
3
|
3
|
|
|
3
|
|
988
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
103
|
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
97
|
|
|
5
|
3
|
|
|
3
|
|
4752
|
use Class::Std::Fast::Storable; |
|
|
3
|
|
|
|
|
34234
|
|
|
|
3
|
|
|
|
|
25
|
|
|
6
|
3
|
|
|
3
|
|
422
|
use Scalar::Util qw(blessed); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
258
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = $SOAP::WSDL::VERSION; |
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
691
|
use SOAP::WSDL::Factory::Serializer; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
1745
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $SOAP_NS = 'http://schemas.xmlsoap.org/soap/envelope/'; |
|
13
|
|
|
|
|
|
|
my $XML_INSTANCE_NS = 'http://www.w3.org/2001/XMLSchema-instance'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub serialize { |
|
16
|
10
|
|
|
10
|
1
|
1346
|
my ($self, $args_of_ref) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
10
|
|
|
|
|
19
|
my $opt = $args_of_ref->{ options }; |
|
19
|
|
|
|
|
|
|
|
|
20
|
10
|
100
|
|
|
|
37
|
if (not $opt->{ namespace }->{ $SOAP_NS }) |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
9
|
|
|
|
|
22
|
$opt->{ namespace }->{ $SOAP_NS } = 'SOAP-ENV'; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
10
|
100
|
|
|
|
24
|
if (not $opt->{ namespace }->{ $XML_INSTANCE_NS }) |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
9
|
|
|
|
|
19
|
$opt->{ namespace }->{ $XML_INSTANCE_NS } = 'xsi'; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
10
|
|
|
|
|
18
|
my $soap_prefix = $opt->{ namespace }->{ $SOAP_NS }; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# envelope start with namespaces |
|
33
|
10
|
|
|
|
|
23
|
my $xml = qq|<$soap_prefix\:Envelope |; |
|
34
|
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
11
|
for my $uri ( sort { $a cmp $b } keys %{ $opt->{ namespace } } ) |
|
|
10
|
|
|
|
|
30
|
|
|
|
10
|
|
|
|
|
41
|
|
|
36
|
|
|
|
|
|
|
{ |
|
37
|
20
|
|
|
|
|
29
|
my $prefix = $opt->{ namespace }->{ $uri }; |
|
38
|
20
|
|
|
|
|
57
|
$xml .= "xmlns:$prefix=\"$uri\" "; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# add namespace for user-supplied prefix if needed |
|
42
|
10
|
100
|
|
|
|
38
|
$xml .= "xmlns:$opt->{prefix}=\"" . $args_of_ref->{ body }->get_xmlns() . "\" " |
|
43
|
|
|
|
|
|
|
if $opt->{prefix}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# TODO insert encoding |
|
46
|
10
|
|
|
|
|
15
|
$xml.='>'; |
|
47
|
10
|
|
|
|
|
38
|
$xml .= $self->serialize_header($args_of_ref->{ method }, $args_of_ref->{ header }, $opt); |
|
48
|
10
|
|
|
|
|
47
|
$xml .= $self->serialize_body($args_of_ref->{ method }, $args_of_ref->{ body }, $opt); |
|
49
|
10
|
|
|
|
|
46
|
$xml .= '' . $soap_prefix .':Envelope>'; |
|
50
|
10
|
|
|
|
|
73
|
return $xml; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub serialize_header { |
|
54
|
10
|
|
|
10
|
1
|
25
|
my ($self, $method, $data, $opt) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# header is optional. Leave out if there's no header data |
|
57
|
10
|
100
|
|
|
|
24
|
return q{} if not $data; |
|
58
|
6
|
100
|
|
|
|
40
|
return join ( q{}, |
|
59
|
|
|
|
|
|
|
"<$opt->{ namespace }->{ $SOAP_NS }\:Header>", |
|
60
|
|
|
|
|
|
|
blessed $data ? $data->serialize_qualified : (), |
|
61
|
|
|
|
|
|
|
"$opt->{ namespace }->{ $SOAP_NS }\:Header>", |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub serialize_body { |
|
66
|
10
|
|
|
10
|
1
|
20
|
my ($self, $method, $data, $opt) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# TODO This one wipes out the old class' XML name globally |
|
69
|
|
|
|
|
|
|
# Fix in some more appropriate place... |
|
70
|
10
|
100
|
|
|
|
38
|
$data->__set_name("$opt->{prefix}:" . $data->__get_name() ) if $opt->{prefix}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Body is NOT optional. Serialize to empty body |
|
73
|
|
|
|
|
|
|
# if we have no data. |
|
74
|
3
|
100
|
|
|
|
39
|
return join ( q{}, |
|
75
|
|
|
|
|
|
|
"<$opt->{ namespace }->{ $SOAP_NS }\:Body>", |
|
76
|
|
|
|
|
|
|
defined $data |
|
77
|
|
|
|
|
|
|
? ref $data eq 'ARRAY' |
|
78
|
10
|
100
|
|
|
|
75
|
? join q{}, map { blessed $_ ? $_->serialize_qualified() : () } @{ $data } |
|
|
5
|
100
|
|
|
|
13
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
: blessed $data |
|
80
|
|
|
|
|
|
|
? $opt->{prefix} |
|
81
|
|
|
|
|
|
|
? $data->serialize() |
|
82
|
|
|
|
|
|
|
: $data->serialize_qualified() |
|
83
|
|
|
|
|
|
|
: () |
|
84
|
|
|
|
|
|
|
: (), |
|
85
|
|
|
|
|
|
|
"$opt->{ namespace }->{ $SOAP_NS }\:Body>", |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |