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