NAME
XML::Compile::WSDL11 - create SOAP messages defined by WSDL 1.1
INHERITANCE
XML::Compile::WSDL11
is a XML::Compile
SYNOPSIS
** SOAP-RPC style broken in this release.
# preparation
my $wsdl = XML::Compile::WSDL11->new($wsdlfile);
$wsdl->addWSDL(...additional WSDL file...);
$wsdl->importDefinitions(...more schemas...);
my $call = $wsdl->compileClient('GetStockPrice');
my $op = $wsdl->operation('GetStockPrice');
my $call = $op->compileClient;
my $answer = $call->(%request);
my ($answer, $trace) = $call->(%request);
my @op_defs = $wsdl->operations;
# Install XML::Compile::SOAP::Daemon
my $server = XML::Compile::SOAP::HTTPDaemon->new;
$server->actionsFromWSDL($wsdl);
# For debug info, start your script with:
use Log::Report mode => 'DEBUG';
DESCRIPTION
This module currently supports WSDL 1.1 on SOAP 1.1, with HTTP-SOAP. Missing are pure HTTP GET/POST bindings, multipart-mime transport protocols, WSDL2 and SOAP 1.2.
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 exchange of them: it's all Perl to 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, because XML::Compile::Schema does not wish dynamic internet download magic to happen.
METHODS
Constructors
XML::Compile::WSDL11->new(XML, OPTIONS)
The XML is the WSDL file, which is anything accepted by XML::Compile::dataToXML(). All options are also passed to create an internal XML::Compile::Schema object. See XML::Compile::Schema::new()
Option --Defined in --Default
schema_dirs XML::Compile undef
schemas <created internally>
wsdl_namespace undef
. schema_dirs => DIRECTORY|ARRAY-OF-DIRECTORIES
. schemas => XML::Compile::Schema object
. wsdl_namespace => IRI
Force to accept only WSDL descriptions which are in this namespace. If not specified, the name-space which is found in the first WSDL document is used.
Accessors
$obj->addSchemaDirs(DIRECTORIES|FILENAME)
XML::Compile::WSDL11->addSchemaDirs(DIRECTORIES|FILENAME)
$obj->schemas
Returns the XML::Compile::Schema object which collects all type information.
$obj->wsdlNamespace([NAMESPACE])
Returns (optionally after setting) the namespace used by the WSDL specification. This is the namespace in which the definition
document root element is defined.
Compilers
$obj->dataToXML(NODE|REF-XML-STRING|XML-STRING|FILENAME|FILEHANDLE|KNOWN)
Administration
$obj->findSchemaFile(FILENAME)
$obj->knownNamespace(NAMESPACE|PAIRS)
XML::Compile::WSDL11->knownNamespace(NAMESPACE|PAIRS)
$obj->walkTree(NODE, CODE)
Extension
$obj->addWSDL(XMLDATA)
Some XMLDATA, accepted by XML::Compile::dataToXML() is provided, which should represent the top-level of a (partial) WSDL document. The specification can be spread over multiple files, which each have a definition
root element.
$obj->compileClient([NAME], OPTIONS)
- .
-
operation() (i.e.
service
andport
), and all of - .
-
XML::Compile::WSDL11::Operation::compileClient() (a whole lot, for instance
transport_hook
), plus - .
-
everything you can pass to XML::Compile::Schema::compile(), for instance
check_values => 0
, hooks, and typemaps.
Creates temporarily an XML::Compile::WSDL11::Operation with operation(), and then calls compileClient()
on that; an usual combination.
As OPTIONS are available the combination of all possibilities for
example:
$wsdl->compileClient
( operation => 'HelloWorld'
, port => 'PrefillSoap' # only needed when multiple ports
, sloppy_integers => 1
);
$obj->importDefinitions(XMLDATA, OPTIONS)
Add schema information to the WSDL interface knowledge. This should not be needed, because WSDL definitions must be self-contained.
$obj->namesFor(CLASS)
Returns the list of names available for a certain definition CLASS in the WSDL.
$obj->operation([NAME], OPTIONS)
Collect all information for a certain operation. Returned is an XML::Compile::WSDL11::Operation object.
An operation is defined by a service name, a port, some bindings, and an operation name, which can be specified explicitly or sometimes left-out.
When not specified explicitly via OPTIONS, each of the CLASSes are only permitted to have exactly one definition. Otherwise, you must make a choice explicitly. There is a very good reason to be not too flexible in this area: developers need to be aware when there are choices, where some flexibility is required.
Option --Default
operation <required>
port <only when just one>
service <only when just one>
. 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
Required when more than one service is defined.
Inspection
All of the following methods are usually NOT meant for end-users. End-users should stick to the operation() and compileClient() methods.
$obj->find(CLASS, [QNAME])
With a QNAME, the HASH which contains the parsed XML information from the WSDL template for that CLASS-NAME combination is returned. 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.
$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.
$obj->operations(OPTIONS)
Return a list with all operations defined in the WSDL.
Option --Default
produce 'HASHES'
. produce => 'OBJECTS'|'HASHES'
By default, this function will return a list of HASHes, each representing one defined operation. When this option is set, those HASHes are immediately used to create XML::Compile::WSDL11::Operation objects per operation.
DETAILS
Comparison
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 this 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 are required to select one explicitly.
use XML::Compile::WSDL11 ();
# once in your program
my $wsdl = XML::Compile::WSDL11->new('def.wsdl');
# XML::Compile::Schema does not want 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);
DIAGNOSTICS
Error: cannot find pre-installed name-space files
Use $ENV{SCHEMA_LOCATION}
or new(schema_dirs) to express location of installed name-space files, which came with the XML::Compile distribution package.
Error: don't known how to interpret XML data
SEE ALSO
This module is part of XML-Compile-SOAP distribution version 0.78, built on October 10, 2008. Website: http://perl.overmeer.net/xml-compile/
All modules in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::SOAP::Daemon, XML::Compile::Tester, XML::Compile::Cache, XML::Rewrite, XML::Compile::Dumper.
Please post questions or ideas to the mailinglist at http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile For life contact with other developers, visit the #xml-compile
channel on irc.perl.org
.
LICENSE
Copyrights 2007-2008 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