XML::Compile::WSDL11(3pm) | User Contributed Perl Documentation | XML::Compile::WSDL11(3pm) |
XML::Compile::WSDL11 - create SOAP messages defined by WSDL 1.1
XML::Compile::WSDL11 is a XML::Compile::Cache is a XML::Compile::Schema is a XML::Compile
# preparation use XML::Compile::WSDL11; # use WSDL version 1.1 use XML::Compile::SOAP11; # use SOAP version 1.1 use XML::Compile::Transport::SOAPHTTP; # you want some trace? use Log::Report mode => 'DEBUG'; # or 'VERBOSE' # collect one or more wsdls and xsds in one object my $wsdl = XML::Compile::WSDL11->new($wsdlfile , server_type => 'BEA' ); $wsdl->addWSDL(...more WSDL files...); $wsdl->importDefinitions(...more schemas...); # during initiation, for each used call my $call = $wsdl->compileClient('GetStockPrice', ...); # at "run-time", call as often as you want (fast) my $answer = $call->(%request); # capture useful trace information my ($answer, $trace) = $call->(%request); if($trace->errors) { $trace->printError; } # no need to administer the operations by hand: alternative $wsdl->compileCalls; # at initiation my $answer = $wsdl->call(GetStockPrice => %request); # investigate the %request structure (server input) print $wsdl->explain('GetStockPrice', PERL => 'INPUT', recurse => 1); # investigate the $answer structure (server output) print $wsdl->explain('GetStockPrice', PERL => 'OUTPUT'); # when you like, get all operation definitions my @all_ops = $wsdl->operations; # Install XML::Compile::SOAP::Daemon my $server = XML::Compile::SOAP::HTTPDaemon->new; $server->operationsFromWSDL($wsdl); undef $wsdl; # not needed any further # For debug info, start your script with: use Log::Report mode => 'DEBUG';
This module understands WSDL version 1.1. An WSDL file defines a set of messages to be send and received over (SOAP) connections. This involves encoding of the message to be send into XML, sending the message to the server, collect the answer, and finally decoding the XML to Perl.
As end-user, you do not have to worry about the complex details of the messages and the way to exchange them: it's all simple Perl for you. Also, faults are handled automatically. The only complication you have to worry about is to shape a nested HASH structure to the sending message structure. XML::Compile::Schema::template() may help you.
When the definitions are spread over multiple files you will need to use addWSDL() (wsdl) or importDefinitions() (additional schema's) explicitly. Usually, interreferences between those files are broken. Often they reference over networks (you should never trust). So, on purpose you must explicitly load the files you need from local disk! (of course, it is simple to find one-liners as work-arounds, but I will not tell you how! See XML::Compile::SOAP::FAQ)
Extends "DESCRIPTION" in XML::Compile::Cache.
Extends "METHODS" in XML::Compile::Cache.
Extends "Constructors" in XML::Compile::Cache.
-Option --Defined in --Default allow_undeclared XML::Compile::Cache <false> any_element XML::Compile::Cache 'ATTEMPT' block_namespace XML::Compile::Schema [] hook XML::Compile::Schema undef hooks XML::Compile::Schema [] ignore_unused_tags XML::Compile::Schema <false> key_rewrite XML::Compile::Schema [] opts_readers XML::Compile::Cache [] opts_rw XML::Compile::Cache [] opts_writers XML::Compile::Cache [] parser_options XML::Compile <many> prefixes XML::Compile::Cache <smart> schema_dirs XML::Compile undef server_type undef typemap XML::Compile::Cache {} xsi_type XML::Compile::Cache {}
Extends "Accessors" in XML::Compile::Cache.
Extends "Prefix management" in XML::Compile::Cache.
Extends "Compilers" in XML::Compile::Cache.
example:
# at initiation time (compile once) $wsdl->compileCalls; # at runtime (run often) my $answer = $wsdl->call($operation, $request);
[2.38] Alteratively to an $operation object, you may also specify an operation by name.
-Option--Default alias undef
example:
my $op = $wsdl->operation(name => 'getInfo'); $wsdl->compileCall($op); # as often as you need it my ($answer, $trace) = $wsdl->call('getInfo')->(%request);
Additionally, %options can contain "service", "port", and "binding" to limit the set of involved calls. See operations() for details on these options.
You may declare additional specific compilation options with the declare() method.
-Option --Default long_names false
You will need this if you have multiple operations with the same name in your WSDL (-collection).
example:
my $trans = XML::Compile::Transport::SOAPHTTP ->new(timeout => 500, address => $wsdl->endPoint); $wsdl->compileCalls(transport => $trans); # alternatives for simple cases $wsdl->compileAll('CALLS'); $wsdl->compileAll; my $answer = $wsdl->call($myop, $request);
The %options available include all of the options for:
You cannot pass options for XML::Compile::Schema::compile(), like "<sloppy_integers =" 0>>, hooks or typemaps this way. Use new(opts_rw) and friends to declare those.
When you use compileCall(), the compiled code references get cached for you. In that case, you can use call() to use them.
example:
my $call = $wsdl->compileClient ( operation => 'HelloWorld' , port => 'PrefillSoap' # only required when multiple ports ); my ($answer, $trace) = $call->($request); # 'operation' keyword optional my $call = $wsdl->compileClient('HelloWorld');
An operation is defined by a service name, a port, some bindings, and an operation name, which can be specified explicitly and is often left-out: in the many configurations where there are no alternative choices. In case there are alternatives, you will be requested to pick an option.
-Option --Default action <undef> operation <required> port <only when just one port in WSDL> server_type undef service <only when just one service in WSDL>
Extends "Administration" in XML::Compile::Cache.
example:
$wsdl->declare(OPERATION => 'GetStockPrice', @extra_opts); $wsdl->compileCalls; my $answer = $wsdl->call(GetStockPrice => %request);
All of the following methods are usually NOT meant for end-users. End-users should stick to the operation() and compileClient() methods.
The endpoint in the WSDL is often wrong. All compile functions accept the "server" and "endpoint" parameters to overrule the value. With "server", only the hostname:port is being replaced. With "endpoint", everything is replaced.
-Option --Default port <undef> service <undef>
example:
my $devel = URI->new($wsdl->endPoint); $devel->path('/sdk'); my $call = $wsdl->compileCall($opname, endpoint => $devel);
The $direction of operation is either "INPUT" (input for the server, hence to be produced by the client), or "OUTPUT" (from the server, received by the client).
The actual work is done by XML::Compile::SOAP::Operation::explain(). The %options passed to that method include "recurse" and "skip_header".
example:
print $wsdl->explain('CheckStatus', PERL => 'INPUT'); print $wsdl->explain('CheckStatus', PERL => 'OUTPUT' , recurse => 1 # explain options , port => 'Soap12PortName' # operation options ); foreach my $op ($wsdl->operations) { print $op->explain($wsdl, PERL => 'INPUT'); }
Without $qname in SCALAR context, there may only be one such name defined otherwise an error is produced. In LIST context, all definitions in $class are returned.
example:
$service = $obj->findDef(service => 'http://xyz'); @services = $obj->findDef('service');
$class includes "service", "binding", "portType", and "message".
-Option --Default binding <undef> port <undef> server_type undef service <undef>
-Option --Defined in --Default show_declared XML::Compile::Cache <true>
Extends "DETAILS" in XML::Compile::Cache.
Extends "Distribution collection overview" in XML::Compile::Cache.
Extends "Comparison" in XML::Compile::Cache.
Extends "Collecting definitions" in XML::Compile::Cache.
Extends "Addressing components" in XML::Compile::Cache.
Extends "Representing data-structures" in XML::Compile::Cache.
Extends "Schema hooks" in XML::Compile::Cache.
Extends "Typemaps" in XML::Compile::Cache.
Extends "Handling xsi:type" in XML::Compile::Cache.
Extends "Key rewrite" in XML::Compile::Cache.
When you have a WSDL file, then SOAP is simple. If there is no such file at hand, then it is still possible to use SOAP. See the DETAILS chapter in XML::Compile::SOAP.
The WSDL file contains operations which can be addressed by name. In the WSDL file you need to find the name of the port to be used. In most cases, the WSDL has only one service, one port, one binding, and one portType and those names can therefore be omitted. If there is a choice, then you must explicitly select one.
use XML::Compile::WSDL11 (); # once in your program my $wsdl = XML::Compile::WSDL11->new('def.wsdl'); # XML::Compile::Schema refuses to follow "include" and # "import" commands, so you need to invoke them explicitly. # $wsdl->addWSDL('file2.wsdl'); # optional # $wsdl->importDefinitions('schema1.xsd'); # optional # once for each of the defined operations my $call = $wsdl->compileClient('GetStockPrice'); # see XML::Compile::SOAP chapter DETAILS about call params my $answer = $call->(%request);
Extends "DESCRIPTIONS" in XML::Compile::Cache.
This module is part of XML-Compile-WSDL11 distribution version 3.08, built on August 27, 2021. Website: http://perl.overmeer.net/CPAN/
Copyrights 2014-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
2021-10-11 | perl v5.32.1 |