line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
SOAP::payload - Perl module to send various forms of information as SOAP envelopes. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
There are three methods here is a brief example demonstrating each one |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Use in conjunction with DBI to extract array_ref's |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use DBI; |
13
|
|
|
|
|
|
|
use SOAP::payload; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $dbh; |
16
|
|
|
|
|
|
|
my $xml; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $soap= new payload; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $query = 'SELECT coat_id, coat_desc FROM coating ORDER BY coat_id'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $sth = $dbh->prepare($query); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $rv = $sth->execute(); |
27
|
|
|
|
|
|
|
defined $rv or die $sth->errstr; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $arrayref = $sth->fetchall_arrayref({}); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$rv = $sth->finish(); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$dbh->disconnect; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
(undef,$xml) = $soap->dbiSOAPenvelope($arrayref,'XML_module','sayHello'); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
print "$xml\n"; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Also returned is the transaction ID, if a transaction ID is not supplied as the |
40
|
|
|
|
|
|
|
4th parameter to the method a randomly generated one is created. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The second method is to supply a string of characters. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use strict; |
46
|
|
|
|
|
|
|
use Carp; |
47
|
|
|
|
|
|
|
use SOAP::payload; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my %i; |
50
|
|
|
|
|
|
|
my $xml; |
51
|
|
|
|
|
|
|
my $soap = new SOAP::payload; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $string="Hello World!"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
(undef,$xml) = $soap->stringSOAPenvelope($string,'XML_module','sayHello'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
print "$xml\n"; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The third method is to supply an array reference. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use strict; |
65
|
|
|
|
|
|
|
use Carp; |
66
|
|
|
|
|
|
|
use SOAP::payload; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my @hash_ref; |
69
|
|
|
|
|
|
|
my %i; |
70
|
|
|
|
|
|
|
my $xml; |
71
|
|
|
|
|
|
|
my $soap = new SOAP::payload; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my @data=('one','two','three','four','five'); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $array_ref=\@data; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
(undef,$xml) = $soap->arraySOAPenvelope($array_ref,'XML_module','sayHello'); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
print "$xml\n"; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The output of the module is an XML 1.0 compliant XML envelope |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" |
88
|
|
|
|
|
|
|
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" |
89
|
|
|
|
|
|
|
xmlns:xsd="http://www.w3.org/1999/XMLSchema"> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
00511 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This module can be used in conjunction with other modules |
111
|
|
|
|
|
|
|
such as DBI, to send data elements as part of a SOAP transaction |
112
|
|
|
|
|
|
|
envelope. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Methods exist within this object to send the results of |
115
|
|
|
|
|
|
|
an $sth->fetchall_arrayref({}), a string of literal characters |
116
|
|
|
|
|
|
|
or an array as a SOAP envelope. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Each method for sending an envelope returns a transaction ID and the SOAP XML. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Copyright (c) 2002 Stephen Martin |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Permission to use, copy, and distribute is hereby granted, |
123
|
|
|
|
|
|
|
providing that the above copyright notice and this permission |
124
|
|
|
|
|
|
|
appear in all copies and in supporting documentation. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 EXPORT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
None. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
package SOAP::payload; |
137
|
|
|
|
|
|
|
require Exporter; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$VERSION = '1.02'; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
142
|
|
|
|
|
|
|
@EXPORT = qw(dbiSOAPenvelope stringSOAPenvelope arraySOAPenvelope new version); |
143
|
|
|
|
|
|
|
@EXPORT_OK = qw(dbiSOAPenvelope stringSOAPenvelope arraySOAPenvelope new version); |
144
|
|
|
|
|
|
|
|
145
|
1
|
|
|
1
|
|
5626
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
966
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub new { |
148
|
0
|
|
|
0
|
0
|
|
my $object = {}; |
149
|
0
|
|
|
|
|
|
bless $object; |
150
|
0
|
|
|
|
|
|
return $object; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub version { |
154
|
0
|
|
|
0
|
0
|
|
return "1.00"; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub dbiSOAPenvelope { |
158
|
0
|
|
|
0
|
0
|
|
shift; |
159
|
0
|
|
|
|
|
|
my ($_ref) = @_; |
160
|
0
|
|
|
|
|
|
shift; |
161
|
0
|
|
|
|
|
|
my ($_mod) = @_; |
162
|
0
|
|
|
|
|
|
shift; |
163
|
0
|
|
|
|
|
|
my ($_sub) = @_; |
164
|
0
|
|
|
|
|
|
shift; |
165
|
0
|
|
|
|
|
|
my ($_trns) = @_; |
166
|
0
|
|
|
|
|
|
shift; |
167
|
0
|
|
|
|
|
|
my ($s) = @_; |
168
|
0
|
|
|
|
|
|
shift; |
169
|
0
|
|
|
|
|
|
my ($xsi) = @_; |
170
|
0
|
|
|
|
|
|
shift; |
171
|
0
|
|
|
|
|
|
my ($xsd) = @_; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
my $_resp; |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
defined $_mod or $_mod = "ReqPackage"; |
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
defined $_sub or $_sub = "ReqHandler"; |
178
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if ( !$_trns ) { |
180
|
0
|
|
|
|
|
|
srand( time() ^ ( $$ + ( $$ << 15 ) ) ); |
181
|
0
|
|
|
|
|
|
$_trns = int( rand(65534) ) + 1; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
$_trns = sprintf( "%05d", $_trns ); |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
defined $s or $s = "http:\/\/schemas.xmlsoap.org\/soap\/envelope\/"; |
187
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
defined $xsi or $xsi = "http:\/\/www.w3.org\/1999\/XMLSchema-instance"; |
189
|
|
|
|
|
|
|
|
190
|
0
|
0
|
|
|
|
|
defined $xsd or $xsd = "http:\/\/www.w3.org\/1999\/XMLSchema"; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
$_resp = qq~ |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
xmlns:s="$s" |
195
|
|
|
|
|
|
|
xmlns:xsi="$xsi" |
196
|
|
|
|
|
|
|
xmlns:xsd="$xsd"> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$_trns |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
\t |
205
|
|
|
|
|
|
|
\t |
206
|
|
|
|
|
|
|
~; |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
foreach my $i (@$_ref) { |
209
|
0
|
|
|
|
|
|
$_resp = $_resp . "\t
|
210
|
0
|
|
|
|
|
|
while ( ( my $_k, my $_v ) = each %$i ) { |
211
|
0
|
|
|
|
|
|
$_resp = $_resp . "$_k=\"$_v\" "; |
212
|
|
|
|
|
|
|
} |
213
|
0
|
|
|
|
|
|
$_resp = $_resp . "/>\n"; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$_resp = $_resp . qq~\t |
217
|
|
|
|
|
|
|
\t |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
~; |
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
return ( $_trns, $_resp ); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub stringSOAPenvelope { |
228
|
0
|
|
|
0
|
0
|
|
shift; |
229
|
0
|
|
|
|
|
|
my ($_astr) = @_; |
230
|
0
|
|
|
|
|
|
shift; |
231
|
0
|
|
|
|
|
|
my ($_mod) = @_; |
232
|
0
|
|
|
|
|
|
shift; |
233
|
0
|
|
|
|
|
|
my ($_sub) = @_; |
234
|
0
|
|
|
|
|
|
shift; |
235
|
0
|
|
|
|
|
|
my ($_trns) = @_; |
236
|
0
|
|
|
|
|
|
shift; |
237
|
0
|
|
|
|
|
|
my ($s) = @_; |
238
|
0
|
|
|
|
|
|
shift; |
239
|
0
|
|
|
|
|
|
my ($xsi) = @_; |
240
|
0
|
|
|
|
|
|
shift; |
241
|
0
|
|
|
|
|
|
my ($xsd) = @_; |
242
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
my $_resp; |
244
|
|
|
|
|
|
|
|
245
|
0
|
0
|
|
|
|
|
defined $_mod or $_mod = "ReqPackage"; |
246
|
|
|
|
|
|
|
|
247
|
0
|
0
|
|
|
|
|
defined $_sub or $_sub = "ReqHandler"; |
248
|
|
|
|
|
|
|
|
249
|
0
|
0
|
|
|
|
|
if ( !$_trns ) { |
250
|
0
|
|
|
|
|
|
srand( time() ^ ( $$ + ( $$ << 15 ) ) ); |
251
|
0
|
|
|
|
|
|
$_trns = int( rand(65534) ) + 1; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
$_trns = sprintf( "%05d", $_trns ); |
255
|
|
|
|
|
|
|
|
256
|
0
|
0
|
|
|
|
|
defined $s or $s = "http:\/\/schemas.xmlsoap.org\/soap\/envelope\/"; |
257
|
|
|
|
|
|
|
|
258
|
0
|
0
|
|
|
|
|
defined $xsi or $xsi = "http:\/\/www.w3.org\/1999\/XMLSchema-instance"; |
259
|
|
|
|
|
|
|
|
260
|
0
|
0
|
|
|
|
|
defined $xsd or $xsd = "http:\/\/www.w3.org\/1999\/XMLSchema"; |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
$_resp = qq~ |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
xmlns:s="$s" |
265
|
|
|
|
|
|
|
xmlns:xsi="$xsi" |
266
|
|
|
|
|
|
|
xmlns:xsd="$xsd"> |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
$_trns |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
\t |
275
|
|
|
|
|
|
|
\t |
276
|
|
|
|
|
|
|
\t |
277
|
|
|
|
|
|
|
\t |
278
|
|
|
|
|
|
|
\t |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
~; |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
return ( $_trns, $_resp ); |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub arraySOAPenvelope { |
289
|
0
|
|
|
0
|
0
|
|
shift; |
290
|
0
|
|
|
|
|
|
my ($_ref) = @_; |
291
|
0
|
|
|
|
|
|
shift; |
292
|
0
|
|
|
|
|
|
my ($_mod) = @_; |
293
|
0
|
|
|
|
|
|
shift; |
294
|
0
|
|
|
|
|
|
my ($_sub) = @_; |
295
|
0
|
|
|
|
|
|
shift; |
296
|
0
|
|
|
|
|
|
my ($_trns) = @_; |
297
|
0
|
|
|
|
|
|
shift; |
298
|
0
|
|
|
|
|
|
my ($s) = @_; |
299
|
0
|
|
|
|
|
|
shift; |
300
|
0
|
|
|
|
|
|
my ($xsi) = @_; |
301
|
0
|
|
|
|
|
|
shift; |
302
|
0
|
|
|
|
|
|
my ($xsd) = @_; |
303
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
my $_resp; |
305
|
|
|
|
|
|
|
|
306
|
0
|
0
|
|
|
|
|
defined $_mod or $_mod = "ReqPackage"; |
307
|
|
|
|
|
|
|
|
308
|
0
|
0
|
|
|
|
|
defined $_sub or $_sub = "ReqHandler"; |
309
|
|
|
|
|
|
|
|
310
|
0
|
0
|
|
|
|
|
if ( !$_trns ) { |
311
|
0
|
|
|
|
|
|
srand( time() ^ ( $$ + ( $$ << 15 ) ) ); |
312
|
0
|
|
|
|
|
|
$_trns = int( rand(65534) ) + 1; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
0
|
|
|
|
|
|
$_trns = sprintf( "%05d", $_trns ); |
316
|
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
defined $s or $s = "http:\/\/schemas.xmlsoap.org\/soap\/envelope\/"; |
318
|
|
|
|
|
|
|
|
319
|
0
|
0
|
|
|
|
|
defined $xsi or $xsi = "http:\/\/www.w3.org\/1999\/XMLSchema-instance"; |
320
|
|
|
|
|
|
|
|
321
|
0
|
0
|
|
|
|
|
defined $xsd or $xsd = "http:\/\/www.w3.org\/1999\/XMLSchema"; |
322
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
|
$_resp = qq~ |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
xmlns:s="$s" |
326
|
|
|
|
|
|
|
xmlns:xsi="$xsi" |
327
|
|
|
|
|
|
|
xmlns:xsd="$xsd"> |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
$_trns |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
\t |
336
|
|
|
|
|
|
|
\t |
337
|
|
|
|
|
|
|
~; |
338
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
|
foreach my $i (@$_ref) { |
340
|
0
|
|
|
|
|
|
$_resp = $_resp . "\t\n"; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
0
|
|
|
|
|
|
$_resp = $_resp . qq~\t |
344
|
|
|
|
|
|
|
\t |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
~; |
349
|
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
return ( $_trns, $_resp ); |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
1; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|