NAME

XML::Compile::WSDL11 - create SOAP messages defined by WSDL 1.1

INHERITANCE

XML::Compile::WSDL11
  is a XML::Compile::Cache
  is a XML::Compile::Schema
  is a XML::Compile

SYNOPSIS

# preparation
use XML::Compile::WSDL11;      # use WSDL version 1.1
use XML::Compile::SOAP11;      # use SOAP version 1.1
use XML::Compile::Transport::SOAPHTTP;

my $wsdl = XML::Compile::WSDL11->new($wsdlfile);
$wsdl->addWSDL(...more WSDL files...);
$wsdl->importDefinitions(...more schemas...);

# during initiation, for each used call (slow)
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);

# investigate the %request structure (server input)
print $wsdl->explain('GetStockPrice', PERL => 'INPUT');

# 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

This module implements WSDL version 1.1. An WSDL file defines a set of messages to be send and received over (SOAP) connections.

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 to tell you how!)

METHODS

Constructors

XML::Compile::WSDL11->new(XML, OPTIONS)

    The XML is the WSDL file, which is anything accepted by XML::Compile::dataToXML().

    Option            --Defined in     --Default
    allow_undeclared    XML::Compile::Cache  <false>
    any_element         XML::Compile::Cache  'SKIP_ALL'
    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  []
    prefixes            XML::Compile::Cache  <smart>
    schema_dirs         XML::Compile     undef
    typemap             XML::Compile::Schema  {}

    . allow_undeclared => BOOLEAN

    . any_element => CODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'|'SLOPPY'

    . block_namespace => NAMESPACE|TYPE|HASH|CODE|ARRAY

    . hook => ARRAY-WITH-HOOKDATA | HOOK

    . hooks => ARRAY-OF-HOOK

    . ignore_unused_tags => BOOLEAN|REGEXP

    . key_rewrite => HASH|CODE|ARRAY-of-HASH-and-CODE

    . opts_readers => HASH|ARRAY-of-PAIRS

    . opts_rw => HASH|ARRAY-of-PAIRS

    . opts_writers => HASH|ARRAY-of-PAIRS

    . prefixes => HASH|ARRAY-of-PAIRS

    . schema_dirs => DIRECTORY|ARRAY-OF-DIRECTORIES

    . typemap => HASH

Accessors

$obj->addHook(HOOKDATA|HOOK|undef)

$obj->addHooks(HOOK, [HOOK, ...])

$obj->addKeyRewrite(PREDEF|CODE|HASH, ...)

$obj->addSchemaDirs(DIRECTORIES|FILENAME)

XML::Compile::WSDL11->addSchemaDirs(DIRECTORIES|FILENAME)

$obj->addSchemas(XML, OPTIONS)

$obj->addTypemap(PAIR)

$obj->addTypemaps(PAIRS)

$obj->allowUndeclared([BOOLEAN])

$obj->blockNamespace(NAMESPACE|TYPE|HASH|CODE|ARRAY)

$obj->hooks

$obj->prefix(PREFIX)

$obj->prefixFor(URI)

$obj->prefixed(TYPE)

$obj->prefixes([PAIRS|ARRAY|HASH])

$obj->useSchema(SCHEMA, [SCHEMA])

Compilers

$obj->compile(('READER'|'WRITER'), TYPE, OPTIONS)

$obj->compileAll(['READER'|'WRITER'|'RW', [NAMESPACE]])

XML::Compile::WSDL11->dataToXML(NODE|REF-XML-STRING|XML-STRING|FILENAME|FILEHANDLE|KNOWN)

$obj->reader(TYPE|NAME, OPTIONS)

$obj->template('XML'|'PERL', ELEMENT, OPTIONS)

$obj->writer(TYPE|NAME)

Administration

$obj->declare('READER'|'WRITER'|'RW', TYPE|ARRAY-of-TYPES, OPTIONS)

$obj->doesExtend(EXTTYPE, BASETYPE)

$obj->elements

$obj->findName(NAME)

$obj->findSchemaFile(FILENAME)

XML::Compile::WSDL11->findSchemaFile(FILENAME)

$obj->importDefinitions(XMLDATA, OPTIONS)

$obj->knownNamespace(NAMESPACE|PAIRS)

XML::Compile::WSDL11->knownNamespace(NAMESPACE|PAIRS)

$obj->namespaces

$obj->types

$obj->walkTree(NODE, CODE)

Administration

Extension

$obj->addWSDL(XMLDATA)

    The XMLDATA must be acceptable to XML::Compile::dataToXML() and should represent the top-level of a (partial) WSDL document. The specification can be spread over multiple files, each of which must have a definition root element.

$obj->compileClient([NAME], OPTIONS)

$obj->namesFor(CLASS)

    Returns the list of names available for a certain definition CLASS in the WSDL. See index() for a way to determine the available CLASS information.

$obj->operation([NAME], OPTIONS)

    Collect all information for a certain operation. Returned is an XML::Compile::SOAP::Operation object.

    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>
    service    <only when just one service in WSDL>

    . action => STRING

      Overrule 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 is only one operation defined within the portType.

    . port => NAME

      Required when more than one port is defined.

    . service => QNAME|PREFIXED

      Required when more than one service is defined.

Introspection

All of the following methods are usually NOT meant for end-users. End-users should stick to the operation() and compileClient() methods.

$obj->explain(OPERATION, FORMAT, DIRECTION, OPTIONS)

    [2.13] Produce templates (see XML::Compile::Schema::template() which detail the use of the OPERATION. Currently, only the PERL template FORMAT is available.

    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');

$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 is returned. You may 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)

    Return a list with all operations defined in the WSDL.

    Option --Default
    binding  <undef>
    port     <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.

    . service => NAME

      Only return operations related to the NAMEd service, by default all services.

$obj->printIndex([FILEHANDLE], 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.

    Option       --Defined in         --Default
    show_declared  XML::Compile::Cache  <true>

    . show_declared => BOOLEAN

DETAILS

Initializing SOAP operations via WSDL

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);

SEE ALSO

This module is part of XML-Compile-SOAP distribution version 2.19, built on November 09, 2010. Website: http://perl.overmeer.net/xml-compile/

Other distributions in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::SOAP12, XML::Compile::SOAP::Daemon, XML::Compile::SOAP::WSA, XML::Compile::Tester, XML::Compile::Cache, XML::Compile::Dumper, XML::Compile::RPC, XML::Rewrite, XML::eXistDB, and XML::LibXML::Simple.

Please post questions or ideas to the mailinglist at http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile For live contact with other developers, visit the #xml-compile channel on irc.perl.org.

LICENSE

Copyrights 2007-2010 by Mark Overmeer. 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://www.perl.com/perl/misc/Artistic.html