XML::C...WSDL11(3pm)
XML::C...WSDL11(3pm) β User Contributed Perl Documentation. Bestie, this is the manual for XML::Compile::WSDL11. π
β¨ NAME β¨
XML::Compile::WSDL11 β create SOAP messages defined by WSDL 1.1. That's the whole assignment, no cap.
π INHERITANCE π
XML::Compile::WSDL11
is a XML::Compile::Cache
is a XML::Compile::Schema
is a XML::Compile
π¦ SYNOPSIS π¦
Okay so here's the vibe in code. Read it, bestie, it's giving setup energy:
# 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';
π DESCRIPTION π
Okay so XML::Compile::WSDL11 is fluent in WSDL version 1.1. An WSDL file defines a set of messages to be send and received over (SOAP) connections. That means 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. It's giving full pipeline energy, fr fr.
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.
π METHODS π
Extends "METHODS" in XML::Compile::Cache.
β¨ Constructors β¨
Extends "Constructors" in XML::Compile::Cache.
XML::Compile::WSDL11->new( [$xml], %options )
The $xml is the WSDL file, which is anything accepted by XML::Compile::dataToXML(). So bring your fave format, bestie. π
-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 {}
allow_undeclaredβBOOLEAN; defined inXML::Compile::Cache; default<false>. Lowkey a classic.any_elementβCODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'|'SLOPPY'; defined inXML::Compile::Cache; default'ATTEMPT'.block_namespaceβNAMESPACE|TYPE|HASH|CODE|ARRAY; defined inXML::Compile::Schema; default[].hookβ$hook|ARRAY; defined inXML::Compile::Schema; defaultundef.hooksβARRAY; defined inXML::Compile::Schema; default[].ignore_unused_tagsβBOOLEAN|REGEXP; defined inXML::Compile::Schema; default<false>.key_rewriteβHASH|CODE|ARRAY; defined inXML::Compile::Schema; default[].opts_readersβHASH|ARRAY-of-PAIRS; defined inXML::Compile::Cache; default[].opts_rwβHASH|ARRAY-of-PAIRS; defined inXML::Compile::Cache; default[].opts_writersβHASH|ARRAY-of-PAIRS; defined inXML::Compile::Cache; default[].parser_optionsβHASH|ARRAY; defined inXML::Compile; default<many>.prefixesβHASH|ARRAY-of-PAIRS; defined inXML::Compile::Cache; default<smart>.schema_dirsβ$directory|ARRAY-OF-directories; defined inXML::Compile; defaultundef.server_typeβNAME; defaultundef. [3.01] When you specify the implementation of the server, we can work around some of the known bugs and limitation. ReadXML::Compile::SOAPsection "Supported servers" for supported servers. πtypemapβHASH|ARRAY; defined inXML::Compile::Cache; default{}.xsi_typeβHASH|ARRAY; defined inXML::Compile::Cache; default{}.
π Accessors π
Extends "Accessors" in XML::Compile::Cache.
$obj->addHook($hook|LIST|undef)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addHooks( $hook, [$hook, ...] )β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addKeyRewrite($predef|CODE|HASH, ...)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addSchemaDirs(@directories|$filename)β Inherited, see "Accessors" inXML::Compile.XML::Compile::WSDL11->addSchemaDirs(@directories|$filename)β Inherited, see "Accessors" inXML::Compile.$obj->addSchemas($xml, %options)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addTypemap(PAIR)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addTypemaps(PAIRS)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->addXsiType( [HASH|ARRAY|LIST] )β Inherited, see "Accessors" inXML::Compile::Cache.$obj->allowUndeclared( [BOOLEAN] )β Inherited, see "Accessors" inXML::Compile::Cache.$obj->anyElement('ATTEMPT'|'SLOPPY'|'SKIP_ALL'|'TAKE_ALL'|CODE)β Inherited, see "Accessors" inXML::Compile::Cache.$obj->blockNamespace($ns|$type|HASH|CODE|ARRAY)β Inherited, see "Accessors" inXML::Compile::Schema.$obj->hooks( [<'READER'|'WRITER'>] )β Inherited, see "Accessors" inXML::Compile::Schema.$obj->typemap( [HASH|ARRAY|PAIRS] )β Inherited, see "Accessors" inXML::Compile::Cache.$obj->useSchema( $schema, [$schema, ...] )β Inherited, see "Accessors" inXML::Compile::Schema.
π Prefix management π
Extends "Prefix management" in XML::Compile::Cache.
$obj->addNicePrefix(BASE, NAMESPACE)β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->addPrefixes( [PAIRS|ARRAY|HASH] )β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->learnPrefixes($node)β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->prefix($prefix)β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->prefixFor($uri)β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->prefixed( $type|<$ns,$local> )β Inherited, see "Prefix management" inXML::Compile::Cache.$obj->prefixes( [$params] )β Inherited, see "Prefix management" inXML::Compile::Cache.
π₯ Compilers π₯
Extends "Compilers" in XML::Compile::Cache.
$obj->addCompileOptions( ['READERS'|'WRITERS'|'RW'], %options )β Inherited, see "Compilers" inXML::Compile::Cache.
$obj->call($opname, $data)
[2.20] Call the $opname (operation name) with $data (HASH or LIST of parameters). This only works when you have called compileCalls() beforehand, always during the initiation phase of the program.
example:
# at initiation time (compile once)
$wsdl->compileCalls;
# at runtime (run often)
my $answer = $wsdl->call($operation, $request);
$obj->compile( <'READER'|'WRITER'>, $type, %options )β Inherited, see "Compilers" inXML::Compile::Schema.$obj->compileAll( [ <'READERS'|'WRITERS'|'RW'|'CALLS'>, [$ns] ] )β [2.20] With explicit"CALLS"or without any parameter, it will callcompileCalls(). Otherwise, seeXML::Compile::Cache::compileAll().
$obj->compileCall($operation|$opname, %options)
[2.37] The call to the $operation object (which extends XML::Compile::SOAP::Operation) gets compiled and cached so it can be used with call().
[2.38] Alteratively to an $operation object, you may also specify an operation by name.
-Option--Default
alias undef
alias=>NAMEβ [3.03] When defined, the compiled operation will be stored with the alias name in stead of the operation name. This may make your code more readible or solve naming conflicts.
example:
my $op = $wsdl->operation(name => 'getInfo');
$wsdl->compileCall($op);
# as often as you need it
my ($answer, $trace) = $wsdl->call('getInfo')->(%request);
$obj->compileCalls(%options)
[2.20] Compile a handler for each of the available operations. The %options are passed to each call of compileClient(), but will be overruled by more specific declared options.
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
long_names=>BOOLEANβ [3.03] Prepend the service name to the operation name to produce an alias (seecompileCall(alias)) for the compiled call. If the service name is 'X' and the operation name is 'Y', then the alias becomes 'X#Y'.
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);
$obj->compileType( <'READER'|'WRITER'>, $type, %options )β Inherited, see "Compilers" inXML::Compile::Schema.$obj->dataToXML($node|REF-XML|XML-STRING|$filename|$fh|$known)β Inherited, see "Compilers" inXML::Compile.XML::Compile::WSDL11->dataToXML($node|REF-XML|XML-STRING|$filename|$fh|$known)β Inherited, see "Compilers" inXML::Compile.$obj->initParser(%options)β Inherited, see "Compilers" inXML::Compile.XML::Compile::WSDL11->initParser(%options)β Inherited, see "Compilers" inXML::Compile.$obj->reader($type|$name, %options)β Inherited, see "Compilers" inXML::Compile::Cache.$obj->template( <'XML'|'PERL'|'TREE'>, $element, %options )β inherited bestie, go read "Compilers" in XML::Compile::Schema for the tea β$obj->writer($type|$name)β also inherited, see "Compilers" in XML::Compile::Cache π«
β¨ Extension β¨
$obj->addWSDL($xmldata|\@xmldata, %options)β okay so the$xmldatahas to be somethingXML::Compile::dataToXML()will accept, and it should be the top-level of a (partial) WSDL document. The spec can be spread across multiple files, and literally every one of them has to have a"definition"root element. no exceptions bestie π$obj->compileClient( [$name], %options )β this one makes a temporary XML::Compile::SOAP::Operation object usingoperation(), and then it calls"compileClient()"on that. What you get back is a code reference that handles all the client-server SOAP exchange π₯
The %options you can throw in include all of the options for:
operation()(so like"service"and"port"), plus all ofXML::Compile::SOAP::Operation::compileClient()(there are so many of these β for instance"transport_hook"and"server")
Heads up: you can NOT pass options forXML::Compile::Schema::compile(), like"<sloppy_integers =" 0>>, hooks or typemaps this way. Usenew(opts_rw)and friends to declare those instead π
When you use compileCall(), the compiled code references get cached for you. In that case, you can use call() to use them. iykyk β¨
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');
$obj->namesFor($class)β hands you the list of names available for a certain definition$classin the WSDL. Peepindex()if you wanna figure out the available$classinfo π¦$obj->operation( [$name], %options )β collects ALL the info for a certain operation. What you get back is an XML::Compile::SOAP::Operation object.
An operation is defined by a service name, a port, some bindings, and an operation name β which you can specify explicitly, but it's often left out, because in the many configs where there are no alternative choices, you just don't need to. If there ARE alternatives, you'll be asked to pick one, bestie π«Ά
-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>
action=> STRING β overrules thesoapActionfrom the WSDL πoperation=> NAME β ignored when the parameter list starts with a$name(which is an alternative for this option). Optional when there's only one operation defined inside the portType.port=> NAME β required when more than one port is defined. no cap πserver_type=> NAME β overrulesnew(server_type).service=> QNAME|PREFIXED β required when more than one service is defined.
β¨ Administration β¨
Extends "Administration" in XML::Compile::Cache π
$obj->declare($group, $component|ARRAY, %options)β registers specific compile%optionsfor the specific$component. Also check outXML::Compile::Cache::declare(). The$groupis either"READER","WRITER","RW"(both reader and writer), or"OPERATION". As$componentyou specify the element name (for readers and writers) or the operation name (for operations).%optionsget specified as LIST, ARRAY or HASH πΈ
example:
$wsdl->declare(OPERATION => 'GetStockPrice', @extra_opts);
$wsdl->compileCalls;
my $answer = $wsdl->call(GetStockPrice => %request);
$obj->doesExtend($exttype, $basetype)β inherited, see "Administration" in XML::Compile::Schema$obj->elements()β inherited, see "Administration" in XML::Compile::Schema$obj->findName($name)β inherited, see "Administration" in XML::Compile::Cache$obj->findSchemaFile($filename)XML::Compile::WSDL11->findSchemaFile($filename)β inherited, see "Administration" in XML::Compile$obj->importDefinitions($xmldata, %options)β inherited, see "Administration" in XML::Compile::Schema$obj->knownNamespace($ns|PAIRS)XML::Compile::WSDL11->knownNamespace($ns|PAIRS)β inherited, see "Administration" in XML::Compile$obj->namespaces()β inherited, see "Administration" in XML::Compile::Schema$obj->types()β inherited, see "Administration" in XML::Compile::Schema$obj->walkTree($node, CODE)β inherited, see "Administration" in XML::Compile
β¨ Introspection β¨
Okay so literally all of these methods are usually NOT meant for end-users. End-users should stick to the operation() and compileClient() methods, bestie, don't go poking around in here π
$obj->endPoint(%options)β [2.20] returns the address of the server, as specified by the WSDL. When there are no alternatives for service or port, you don't need to specify those parameters.
The endpoint in the WSDL is often wrong. π All compile functions accept the"server"and"endpoint"parameters to overrule the value. With"server", only thehostname:portis being replaced. With"endpoint", everything is replaced.
-Option --Default
port <undef>
service <undef>
port=> NAMEservice=> QNAME|PREFIXED
example:
my $devel = URI->new($wsdl->endPoint);
$devel->path('/sdk');
my $call = $wsdl->compileCall($opname, endpoint => $devel);
$obj->explain($operation, $format, $direction, %options)β [2.13] produces templates (seeXML::Compile::Schema::template()which details the use of the$operation). Currently, only the"PERL"template$formatis available.
The $direction of operation is either "INPUT" (input for the server, so it's 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');
}
$obj->findDef( $class, <$qname|$prefixed|$name> )β with a$qname, the HASH which contains the parsed XML information from the WSDL template for that$class-$namecombination gets returned. You can also have a$prefixedname, using one of the predefined namespace abbreviations. Otherwise,$nameis considered to be the localName in that class. When the$nameis not found, an error is produced π¨
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');
$obj->index( [$class, [$qname]] )β with a$classand$qname, it returns one WSDL definition HASH orundef. Returns the index for the$classgroup of names as HASH. When no$classis specified, a HASH of HASHes is returned with the CLASSes on the top-level.
$class includes "service", "binding", "portType", and "message" π
$obj->operations(%options)β returns a list with all operations defined in the WSDL π
-Option --Default
binding <undef>
port <undef>
server_type undef
service <undef>
binding=> NAME β only return operations which use the binding with the specified NAME. By default, all bindings are accepted.port=> NAME β return only operations related to the specified port NAME. By default operations from all ports.server_type=> STRING β [3.06]service=> NAME β only return operations related to the NAMEd service, by default all services.
$obj->printIndex( [$fh], %options )β for available%options, seeoperations(). This method is useful to understand the structure of your WSDL: it shows a nested list of services, bindings, ports and portTypes. literally so helpful π«Ά
-Option --Defined in --Default
show_declared XML::Compile::Cache <true>
show_declared=> BOOLEAN
β¨ DETAILS β¨
Extends "DETAILS" in XML::Compile::Cache.
π Distribution collection overview π
Extends "Distribution collection overview" in XML::Compile::Cache.
π Comparison π
Extends "Comparison" in XML::Compile::Cache.
π Collecting definitions π
Extends "Collecting definitions" in XML::Compile::Cache.
π Addressing components π
Extends "Addressing components" in XML::Compile::Cache.
π Representing data-structures π
Extends "Representing data-structures" in XML::Compile::Cache.
π Schema hooks π
Extends "Schema hooks" in XML::Compile::Cache.
π Typemaps π
Extends "Typemaps" in XML::Compile::Cache.
π Handling xsi:type π
Extends "Handling xsi:type" in XML::Compile::Cache.
π Key rewrite π
Extends "Key rewrite" in XML::Compile::Cache.
π Initializing SOAP operations via WSDL π
When you have a WSDL file, then SOAP is simple. If there's no such file at hand, then it's 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's 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);
β¨ DESCRIPTIONS β¨
Extends "DESCRIPTIONS" in XML::Compile::Cache.
β¨ SEE ALSO β¨
This module is part of XML-Compile-WSDL11 distribution version 3.08, built on August 27, 2021. Website: http://perl.overmeer.net/CPAN/ π¦
π LICENSE π
Okay bestie, legal era, but make it cute. Here's the receipts:
Copyrights 2014-2021 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
That's it, that's the credit roll. If you helped build this thing, your name is living its best life in the ChangeLog, no cap. π
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/
π«Ά Translation for the girlies: it's free, it's open, you can share it and remix it β just play by Perl's own license rules. Go read them at that URL, they're right there.
And that's a wrap on the whole page, bestie! πΈ This lil' manual page came to you from perl v5.32.1, dated 2021-10-11 β so if you're reading this in the future, hi, you're iconic, the vibe check still passes. π β¨
Stay hydrated, read your docs, and go slay some WSDL. Mwah! πππ¦
π¦ where this page comes from
- debian bookworm: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libxml-compile-wsdl11-perl 3.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms