File Coverage

lib/XML/Compile/SOAP/Operation.pm
Criterion Covered Total %
statement 27 105 25.7
branch 0 42 0.0
condition 0 7 0.0
subroutine 9 34 26.4
pod 20 24 83.3
total 56 212 26.4


line stmt bran cond sub pod time code
1             # Copyrights 2007-2021 by [Mark Overmeer ].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.02.
5             # This code is part of distribution XML-Compile-SOAP. Meta-POD processed
6             # with OODoc into POD and HTML manual-pages. See README.md
7             # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8              
9             package XML::Compile::SOAP::Operation;
10 7     7   1068 use vars '$VERSION';
  7         14  
  7         347  
11             $VERSION = '3.27';
12              
13              
14 7     7   38 use warnings;
  7         16  
  7         162  
15 7     7   35 use strict;
  7         13  
  7         148  
16              
17 7     7   44 use Log::Report 'xml-report-soap';
  7         16  
  7         39  
18              
19 7     7   2057 use XML::Compile::Util qw/pack_type unpack_type/;
  7         16  
  7         434  
20 7     7   68 use XML::Compile::SOAP::Util qw/:wsdl11/;
  7         12  
  7         713  
21              
22 7     7   53 use File::Spec ();
  7         15  
  7         172  
23 7     7   40 use List::Util qw(first);
  7         49  
  7         431  
24 7     7   47 use File::Basename qw(dirname);
  7         10  
  7         9736  
25              
26             my %servers =
27             ( 'XML::Compile::Daemon' => # my own server implementation
28             { xsddir => 'xcdaemon'
29             , xsds => [ qw(xcdaemon.xsd) ]
30             }
31             # more in XML::Compile::Licensed
32             );
33              
34              
35 0     0 1   sub new(@) { my $class = shift; (bless {}, $class)->init( {@_} ) }
  0            
36              
37             sub init($)
38 0     0 0   { my ($self, $args) = @_;
39 0 0         $self->{kind} = $args->{kind} or panic;
40 0 0         $self->{name} = $args->{name} or panic;
41 0 0         $self->{schemas} = $args->{schemas} or panic;
42 0           $self->_server_type($args->{server_type});
43              
44 0           $self->{transport} = $args->{transport};
45 0           $self->{action} = $args->{action};
46              
47 0   0       my $ep = $args->{endpoints} || [];
48 0 0         my @ep = ref $ep eq 'ARRAY' ? @$ep : $ep;
49 0           $self->{endpoints} = \@ep;
50              
51             # undocumented, because not for end-user
52 0 0         if(my $binding = $args->{binding}) { $self->{bindname} = $binding->{name} }
  0            
53 0 0         if(my $service = $args->{service}) { $self->{servname} = $service->{name} }
  0            
54 0 0         if(my $port = $args->{serv_port}){ $self->{portname} = $port->{name} }
  0            
55 0 0         if(my $port_type= $args->{portType}){ $self->{porttypename} = $port_type->{name} }
  0            
56              
57 0           $self;
58             }
59              
60             sub registered
61             { # This cannot be resolved via dependencies, because that causes
62             # a dependency cycle which CPAN.pm cannot handle. This method was
63             # always called in <3.00 and moved to ::SOAP in >= 3.00
64 0     0 0   error "You need to upgrade XML::Compile::WSDL11 to at least 3.00";
65             }
66              
67             sub _server_type($)
68 0     0     { my ($self, $type) = @_;
69 0 0         $type or return;
70              
71 0           my $schemas = $self->schemas;
72 0 0         return if $schemas->{"did_init_server_$type"}++;
73              
74 0           my ($def, $xsddir);
75 0 0         if($def = $servers{$type})
76 0           { $xsddir = File::Spec->catdir(dirname(__FILE__), 'xsd', $def->{xsddir});
77             }
78             else
79 0           { eval "require XML::Compile::Licensed";
80 0 0         if($@)
81 0           { error __x"soap server type `{type}' is not supported (yet); installing XML::Compile::Licensed may help"
82             , type => $type;
83             }
84 0 0         ($xsddir, $def) = XML::Compile::Licensed->soapServer($type)
85             or error __x"soap server type `{type}' is not supported (yet)"
86             , type => $type;
87             }
88              
89             $schemas->importDefinitions(File::Spec->catfile($xsddir, $_))
90 0           for @{$def->{xsds}};
  0            
91             }
92              
93             #----------------
94              
95 0     0 1   sub schemas() {shift->{schemas}}
96 0     0 1   sub kind() {shift->{kind}}
97 0     0 1   sub name() {shift->{name}}
98 0     0 0   sub style() {shift->{style}}
99 0     0 1   sub transport() {shift->{transport}}
100 0     0 1   sub version() {panic}
101              
102 0     0 1   sub bindingName() {shift->{bindname}}
103 0     0 1   sub serviceName() {shift->{servname}}
104 0     0 1   sub portName() {shift->{portname}}
105 0     0 0   sub portTypeName(){shift->{porttypename}}
106              
107              
108 0     0 1   sub soapAction {shift->{action}}
109 0     0 1   sub action() {shift->{action}} # deprecated
110              
111             # wsaAction is implement in XML::Compile::SOAP::WSA
112              
113              
114 0     0 1   sub serverClass {panic}
115 0     0 1   sub clientClass {panic}
116              
117              
118 0     0 1   sub endPoints() { @{shift->{endpoints}} }
  0            
119              
120              
121             sub longName()
122 0     0 1   { my $self = shift;
123 0   0       ($self->serviceName // '') . '#' . $self->name;
124             }
125              
126             #-------------------------------------------
127              
128              
129             sub compileTransporter(@)
130 0     0 1   { my ($self, %args) = @_;
131              
132 0   0       my $transp = delete $args{transporter} || delete $args{transport};
133 0 0         return $transp if ref $transp eq 'CODE';
134              
135 0           my $proto = $self->transport;
136 0           my @endpoints;
137 0 0         if(my $endpoints = $args{endpoint})
138 0 0         { @endpoints = ref $endpoints eq 'ARRAY' ? @$endpoints : $endpoints;
139             }
140 0 0         unless(@endpoints)
141 0           { @endpoints = $self->endPoints;
142 0 0         if(my $s = $args{server})
143 0           { s#^(\w+)://([^/]+)#$1://$s# for @endpoints;
144             }
145             }
146              
147 0           my $id = join ';', sort @endpoints;
148 0           my $send = $self->{transp_cache}{$proto}{$id};
149 0 0         return $send if $send;
150              
151 0 0         unless($transp)
152 0 0         { my $type = XML::Compile::Transport->plugin($proto)
153             or error __x"transporter type {proto} not supported (add 'use {pkg}'?)"
154             , proto => $proto, pkg => 'XML::Compile::Transport::SOAPHTTP';
155 0           $transp = $type->new(address => \@endpoints, %args);
156             }
157              
158 0           my $transport = $self->{transp_cache}{$proto}{$id} = $transp;
159              
160             $transport->compileClient
161             ( name => $self->name
162             , kind => $self->kind
163             , action => $self->action
164             , hook => $args{transport_hook}
165 0           , %args
166             );
167             }
168              
169              
170 0     0 1   sub compileClient(@) { panic "not implemented" }
171 0     0 1   sub compileHandler(@) { panic "not implemented" }
172              
173             #---------------
174              
175             sub explain($$$@)
176 0     0 1   { my ($self, $wsdl, $format, $dir, %args) = @_;
177 0           panic "not implemented for ".ref $self;
178             }
179              
180              
181             sub parsedWSDL(%)
182 0     0 1   { my $self = shift;
183 0           panic "not implemented for ".ref $self;
184             }
185              
186             1;