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 in XML::Compile::Cache; default <false>. Lowkey a classic.
  • any_element β€” CODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'|'SLOPPY'; defined in XML::Compile::Cache; default 'ATTEMPT'.
  • block_namespace β€” NAMESPACE|TYPE|HASH|CODE|ARRAY; defined in XML::Compile::Schema; default [].
  • hook β€” $hook|ARRAY; defined in XML::Compile::Schema; default undef.
  • hooks β€” ARRAY; defined in XML::Compile::Schema; default [].
  • ignore_unused_tags β€” BOOLEAN|REGEXP; defined in XML::Compile::Schema; default <false>.
  • key_rewrite β€” HASH|CODE|ARRAY; defined in XML::Compile::Schema; default [].
  • opts_readers β€” HASH|ARRAY-of-PAIRS; defined in XML::Compile::Cache; default [].
  • opts_rw β€” HASH|ARRAY-of-PAIRS; defined in XML::Compile::Cache; default [].
  • opts_writers β€” HASH|ARRAY-of-PAIRS; defined in XML::Compile::Cache; default [].
  • parser_options β€” HASH|ARRAY; defined in XML::Compile; default <many>.
  • prefixes β€” HASH|ARRAY-of-PAIRS; defined in XML::Compile::Cache; default <smart>.
  • schema_dirs β€” $directory|ARRAY-OF-directories; defined in XML::Compile; default undef.
  • server_type β€” NAME; default undef. [3.01] When you specify the implementation of the server, we can work around some of the known bugs and limitation. Read XML::Compile::SOAP section "Supported servers" for supported servers. πŸ‘‘
  • typemap β€” HASH|ARRAY; defined in XML::Compile::Cache; default {}.
  • xsi_type β€” HASH|ARRAY; defined in XML::Compile::Cache; default {}.

πŸ’… Accessors πŸ’…

Extends "Accessors" in XML::Compile::Cache.

  • $obj->addHook($hook|LIST|undef) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addHooks( $hook, [$hook, ...] ) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addKeyRewrite($predef|CODE|HASH, ...) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addSchemaDirs(@directories|$filename) β€” Inherited, see "Accessors" in XML::Compile.
  • XML::Compile::WSDL11->addSchemaDirs(@directories|$filename) β€” Inherited, see "Accessors" in XML::Compile.
  • $obj->addSchemas($xml, %options) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addTypemap(PAIR) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addTypemaps(PAIRS) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->addXsiType( [HASH|ARRAY|LIST] ) β€” Inherited, see "Accessors" in XML::Compile::Cache.
  • $obj->allowUndeclared( [BOOLEAN] ) β€” Inherited, see "Accessors" in XML::Compile::Cache.
  • $obj->anyElement('ATTEMPT'|'SLOPPY'|'SKIP_ALL'|'TAKE_ALL'|CODE) β€” Inherited, see "Accessors" in XML::Compile::Cache.
  • $obj->blockNamespace($ns|$type|HASH|CODE|ARRAY) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->hooks( [<'READER'|'WRITER'>] ) β€” Inherited, see "Accessors" in XML::Compile::Schema.
  • $obj->typemap( [HASH|ARRAY|PAIRS] ) β€” Inherited, see "Accessors" in XML::Compile::Cache.
  • $obj->useSchema( $schema, [$schema, ...] ) β€” Inherited, see "Accessors" in XML::Compile::Schema.

🌈 Prefix management 🌈

Extends "Prefix management" in XML::Compile::Cache.

  • $obj->addNicePrefix(BASE, NAMESPACE) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->addPrefixes( [PAIRS|ARRAY|HASH] ) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->learnPrefixes($node) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->prefix($prefix) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->prefixFor($uri) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->prefixed( $type|<$ns,$local> ) β€” Inherited, see "Prefix management" in XML::Compile::Cache.
  • $obj->prefixes( [$params] ) β€” Inherited, see "Prefix management" in XML::Compile::Cache.

πŸ”₯ Compilers πŸ”₯

Extends "Compilers" in XML::Compile::Cache.

  • $obj->addCompileOptions( ['READERS'|'WRITERS'|'RW'], %options ) β€” Inherited, see "Compilers" in XML::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" in XML::Compile::Schema.
  • $obj->compileAll( [ <'READERS'|'WRITERS'|'RW'|'CALLS'>, [$ns] ] ) β€” [2.20] With explicit "CALLS" or without any parameter, it will call compileCalls(). Otherwise, see XML::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 (see compileCall(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" in XML::Compile::Schema.
  • $obj->dataToXML($node|REF-XML|XML-STRING|$filename|$fh|$known) β€” Inherited, see "Compilers" in XML::Compile.
  • XML::Compile::WSDL11->dataToXML($node|REF-XML|XML-STRING|$filename|$fh|$known) β€” Inherited, see "Compilers" in XML::Compile.
  • $obj->initParser(%options) β€” Inherited, see "Compilers" in XML::Compile.
  • XML::Compile::WSDL11->initParser(%options) β€” Inherited, see "Compilers" in XML::Compile.
  • $obj->reader($type|$name, %options) β€” Inherited, see "Compilers" in XML::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 $xmldata has to be something XML::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 using operation(), 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 of
  • XML::Compile::SOAP::Operation::compileClient() (there are so many of these β€” for instance "transport_hook" and "server")
Heads up: you can NOT 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 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 $class in the WSDL. Peep index() if you wanna figure out the available $class info πŸ¦‹
  • $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 the soapAction from 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 β€” overrules new(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 %options for the specific $component. Also check out XML::Compile::Cache::declare(). The $group is either "READER", "WRITER", "RW" (both reader and writer), or "OPERATION". As $component you specify the element name (for readers and writers) or the operation name (for operations). %options get 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 the hostname:port is being replaced. With "endpoint", everything is replaced.
 -Option --Default
  port     <undef>
  service  <undef>
  • port => NAME
  • service => 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 (see XML::Compile::Schema::template() which details the use of the $operation). Currently, only the "PERL" template $format is 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-$name combination gets returned. You can also have a $prefixed name, using one of the predefined namespace abbreviations. Otherwise, $name is considered to be the localName in that class. When the $name is 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 $class and $qname, it returns one WSDL definition HASH or undef. Returns the index for the $class group of names as HASH. When no $class is 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, see operations(). 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