line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SOAP::WSDL::Factory::Transport; |
2
|
23
|
|
|
23
|
|
13492
|
use strict; |
|
23
|
|
|
|
|
27
|
|
|
23
|
|
|
|
|
728
|
|
3
|
23
|
|
|
23
|
|
75
|
use warnings; |
|
23
|
|
|
|
|
21
|
|
|
23
|
|
|
|
|
3004
|
|
4
|
|
|
|
|
|
|
our $VERSION = 3.003; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my %registered_transport_of = (); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Local constants |
9
|
|
|
|
|
|
|
# Could be made readonly, but that's just for the paranoid... |
10
|
|
|
|
|
|
|
my %SOAP_LITE_TRANSPORT_OF = ( |
11
|
|
|
|
|
|
|
ftp => 'SOAP::Transport::FTP', |
12
|
|
|
|
|
|
|
http => 'SOAP::Transport::HTTP', |
13
|
|
|
|
|
|
|
https => 'SOAP::Transport::HTTP', |
14
|
|
|
|
|
|
|
mailto => 'SOAP::Transport::MAILTO', |
15
|
|
|
|
|
|
|
'local' => 'SOAP::Transport::LOCAL', |
16
|
|
|
|
|
|
|
jabber => 'SOAP::Transport::JABBER', |
17
|
|
|
|
|
|
|
mq => 'SOAP::Transport::MQ', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %SOAP_WSDL_TRANSPORT_OF = ( |
21
|
|
|
|
|
|
|
http => 'SOAP::WSDL::Transport::HTTP', |
22
|
|
|
|
|
|
|
https => 'SOAP::WSDL::Transport::HTTP', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# class methods only |
26
|
|
|
|
|
|
|
sub register { |
27
|
8
|
|
|
8
|
1
|
698
|
my ($class, $scheme, $package) = @_; |
28
|
8
|
100
|
|
|
|
26
|
die "Cannot use reference as scheme" if ref $scheme; |
29
|
7
|
|
|
|
|
15
|
$registered_transport_of{ $scheme } = $package; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_transport { |
33
|
6
|
|
|
6
|
1
|
1393
|
my ($class, $url, %attrs) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
8
|
my $scheme = $url; |
37
|
6
|
|
|
|
|
17
|
$scheme =~s{ \:.+$ }{}xm; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
6
|
100
|
|
|
|
13
|
if (defined $registered_transport_of{ $scheme }) { |
41
|
23
|
|
|
23
|
|
98
|
no strict qw(refs); |
|
23
|
|
|
|
|
29
|
|
|
23
|
|
|
|
|
1661
|
|
42
|
3
|
100
|
100
|
|
|
156
|
$registered_transport_of{ $scheme }->can('new') or |
43
|
|
|
|
|
|
|
eval "require $registered_transport_of{ $scheme }" |
44
|
|
|
|
|
|
|
or die "Cannot load transport class $registered_transport_of{ $scheme } : $@"; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# try "foo::Client" class first - SOAP::Tranport always requires |
47
|
|
|
|
|
|
|
# a package withoug the ::Client appended, and then |
48
|
|
|
|
|
|
|
# instantiates a ::Client object... |
49
|
|
|
|
|
|
|
# ... pretty weird ... |
50
|
|
|
|
|
|
|
# ... must be from some time when the max number of files was a |
51
|
|
|
|
|
|
|
# sparse resource ... |
52
|
|
|
|
|
|
|
# ... but we've decided to mimic SOAP::Lite... |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
13
|
return $registered_transport_of{ $scheme }->new( %attrs ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# try SOAP::Lite's Transport module - just skip if not require'able |
58
|
|
|
|
|
|
|
SOAP_Lite: { |
59
|
3
|
100
|
|
|
|
3
|
if (exists $SOAP_LITE_TRANSPORT_OF{ $scheme }) { |
|
3
|
|
|
|
|
6
|
|
60
|
23
|
|
|
23
|
|
94
|
no strict qw(refs); |
|
23
|
|
|
|
|
23
|
|
|
23
|
|
|
|
|
1622
|
|
61
|
|
|
|
|
|
|
# behaves interestingly different under different versions of perl |
62
|
|
|
|
|
|
|
# maybe true even if it's not available |
63
|
1
|
|
|
|
|
3
|
my $protocol_class = $SOAP_LITE_TRANSPORT_OF{ $scheme } . '::Client'; |
64
|
1
|
50
|
33
|
|
|
62
|
$protocol_class->can('new') |
65
|
|
|
|
|
|
|
or eval "require $SOAP_LITE_TRANSPORT_OF{ $scheme }" |
66
|
|
|
|
|
|
|
or last SOAP_Lite; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# may fail if it's not available |
69
|
0
|
0
|
|
|
|
0
|
my $transport = eval { $protocol_class->new( %attrs ) } |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
or last SOAP_Lite; |
71
|
0
|
|
|
|
|
0
|
return $transport; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
100
|
|
|
|
8
|
if (exists $SOAP_WSDL_TRANSPORT_OF{ $scheme }) { |
76
|
23
|
|
|
23
|
|
81
|
no strict qw(refs); |
|
23
|
|
|
|
|
28
|
|
|
23
|
|
|
|
|
2420
|
|
77
|
1
|
50
|
33
|
|
|
50
|
$SOAP_WSDL_TRANSPORT_OF{ $scheme }->can('new') |
78
|
|
|
|
|
|
|
or eval "require $SOAP_WSDL_TRANSPORT_OF{ $scheme }" |
79
|
|
|
|
|
|
|
or die "Cannot load transport class $SOAP_WSDL_TRANSPORT_OF{ $scheme } : $@"; |
80
|
1
|
|
|
|
|
11
|
return $SOAP_WSDL_TRANSPORT_OF{ $scheme }->new( %attrs ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
16
|
die "no transport class found for scheme <$scheme>"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
SOAP::WSDL::Factory::Transport - Factory for retrieving transport objects |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# from SOAP::WSDL::Client: |
97
|
|
|
|
|
|
|
$transport = SOAP::WSDL::Factory::Transport->get_transport( $url, @opt ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# in transport class: |
100
|
|
|
|
|
|
|
package MyWickedTransport; |
101
|
|
|
|
|
|
|
use SOAP::WSDL::Factory::Transport; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# register class as transport module for httpr and https |
104
|
|
|
|
|
|
|
# (httpr is "reliable http", a protocol developed by IBM). |
105
|
|
|
|
|
|
|
SOAP::WSDL::Factory::Transport->register( 'httpr' , __PACKAGE__ ); |
106
|
|
|
|
|
|
|
SOAP::WSDL::Factory::Transport->register( 'https' , __PACKAGE__ ); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
SOAP::WSDL::Transport serves as factory for retrieving transport objects for |
111
|
|
|
|
|
|
|
SOAP::WSDL. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The actual work is done by specific transport classes. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
SOAP::WSDL::Transport tries to load one of the following classes: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * the class registered for the scheme via register() |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * the SOAP::Lite class matching the scheme |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * the SOAP::WSDL class matching the scheme |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 METHODS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 register |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
SOAP::WSDL::Transport->register('https', 'MyWickedTransport'); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Globally registers a class for use as transport class. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 proxy |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$trans->proxy('http://soap-wsdl.sourceforge.net'); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Sets the proxy (endpoint). |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns the transport for this protocol. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 set_transport |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Sets the current transport object. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 get_transport |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Gets the current transport object. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 WRITING YOUR OWN TRANSPORT CLASS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 Registering a transport class |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Transport classes must be registered with SOAP::WSDL::Factory::Transport. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is done by executing the following code where $scheme is the URL scheme |
158
|
|
|
|
|
|
|
the class should be used for, and $module is the class' module name. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
SOAP::WSDL::Factory::Transport->register( $scheme, $module); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
To auto-register your transport class on loading, execute register() in your |
163
|
|
|
|
|
|
|
tranport class (see L above). |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Multiple protocols or multiple classes are registered by multiple calls to |
166
|
|
|
|
|
|
|
register(). |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 Transport plugin package layout |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You may only use transport classes whose name is either |
171
|
|
|
|
|
|
|
the module name or the module name with '::Client' appended. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 Methods to implement |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Transport classes must implement the interface required for SOAP::Lite |
176
|
|
|
|
|
|
|
transport classes (see L for details, |
177
|
|
|
|
|
|
|
L for an example). |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
To provide this interface, transport modules must implement the following |
180
|
|
|
|
|
|
|
methods: |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=over |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * new |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * send_receive |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Dispatches a request and returns the content of the response. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * code |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Returns the status code of the last send_receive call (if any). |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * message |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Returns the status message of the last send_receive call (if any). |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * status |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Returns the status of the last send_receive call (if any). |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * is_success |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Returns true after a send_receive was successful, false if it was not. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=back |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
SOAP::Lite requires transport modules to pack client and server |
209
|
|
|
|
|
|
|
classes in one file, and to follow this naming scheme: |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Module name: |
212
|
|
|
|
|
|
|
"SOAP::Transport::" . uc($scheme) |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Client class (additional package in module): |
215
|
|
|
|
|
|
|
"SOAP::Transport::" . uc($scheme) . "::Client" |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Server class (additional package in module): |
218
|
|
|
|
|
|
|
"SOAP::Transport::" . uc($scheme) . "::Client" |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
SOAP::WSDL does not require you to follow these restrictions. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
There is only one restriction in SOAP::WSDL: |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
You may only use transport classes whose name is either the module name or |
225
|
|
|
|
|
|
|
the module name with '::Client' appended. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
SOAP::WSDL will try to instantiate an object of your transport class with |
228
|
|
|
|
|
|
|
'::Client' appended to allow using transport classes written for SOAP::Lite. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
This may lead to errors when a different module with the name of your |
231
|
|
|
|
|
|
|
transport module suffixed with ::Client is also loaded. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Copyright 2004-2007 Martin Kutter. All rights reserved. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This file is part of SOAP-WSDL. You may distribute/modify it under |
238
|
|
|
|
|
|
|
the same terms as perl itself |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 AUTHOR |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Martin Kutter Emartin.kutter fen-net.deE |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 REPOSITORY INFORMATION |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
$Rev: 851 $ |
247
|
|
|
|
|
|
|
$LastChangedBy: kutterma $ |
248
|
|
|
|
|
|
|
$Id: Transport.pm 851 2009-05-15 22:45:18Z kutterma $ |
249
|
|
|
|
|
|
|
$HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Transport.pm $ |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |