Martin Kutter > SOAP-WSDL-2.00.10 > SOAP::WSDL::Manual::Parser

Download:
SOAP-WSDL-2.00.10.tar.gz

Annotate this POD

CPAN RT

New  27
Open  15
View/Report Bugs
Source   Latest Release: SOAP-WSDL-2.00.99_3

NAME ^

SOAP::WSDL::Manual::Parser - How SOAP::WSDL parses XML messages

Which XML message does SOAP::WSDL parse ? ^

Naturally, there are two kinds of XML documents (or messages) SOAP::WSDL has to parse:

There are different parser implementations available for SOAP messages and WSDL definitions.

WSDL definitions parser ^

SOAP::WSDL::Expat::WSDLParser

A parser for WSDL definitions based on XML::Parser::Expat.

 my $parser = SOAP::WSDL::Expat::WSDLParser->new();
 my $wsdl = $parser->parse_file( $filename );

The WSDL parser creates a tree of perl objects, whose root is a SOAP::WSDL::Definitions element.

SOAP messages parser ^

SOAP::WSDL::Expat::MessageParser

SOAP::WSDL::Expat::MessageParser converts SOAP messages to SOAP::WSDL::XSD object trees.

It uses a class resolvers for finding out which class a particular XML element should be of, and type libs containing these classes.

Creating a class resolver

The easiest way for creating a class resolver is to run SOAP::WSDL's generator.

See wsdl2perl.pl.

The class resolver must implement a class method "get_class", which is passed a list ref of the current element's XPath (relative to Body), split by /.

This method must return a class name appropriate for a XML element.

A class resolver package might look like this:

 package ClassResolver;

 my %class_list = (
    'EnqueueMessage' => 'Typelib::TEnqueueMessage',
    'EnqueueMessage/MMessage' => 'Typelib::TMessage',
    'EnqueueMessage/MMessage/MRecipientURI' => 'SOAP::WSDL::XSD::Builtin::anyURI',
    'EnqueueMessage/MMessage/MMessageContent' => 'SOAP::WSDL::XSD::Builtin::string',
 );

 sub new { return bless {}, 'ClassResolver' };

 sub get_class {
    my $name = join('/', @{ $_[1] });
    return ($class_list{ $name }) ? $class_list{ $name }
        : warn "no class found for $name";
 };
 1;

Skipping unwanted items

Sometimes there's unneccessary information transported in SOAP messages.

To skip XML nodes (including all child nodes), just edit the type map for the message and set the type map entry to '__SKIP__'.

In the example above, EnqueueMessage/StuffIDontNeed and all child elements are skipped.

 my %class_list = (
    'EnqueueMessage' => 'Typelib::TEnqueueMessage',
    'EnqueueMessage/MMessage' => 'Typelib::TMessage',
    'EnqueueMessage/MMessage/MRecipientURI' => 'SOAP::WSDL::XSD::Builtin::anyURI',
    'EnqueueMessage/MMessage/MMessageContent' => 'SOAP::WSDL::XSD::Builtin::string',
    'EnqueueMessage/StuffIDontNeed' => '__SKIP__',
    'EnqueueMessage/StuffIDontNeed/Foo' => 'SOAP::WSDL::XSD::Builtin::string',
    'EnqueueMessage/StuffIDontNeed/Bar' => 'SOAP::WSDL::XSD::Builtin::string',
 );

Note that only SOAP::WSDL::Expat::MessageParser implements skipping elements at the time of writing.

Creating type lib classes

Every element must have a correspondent one in the type library.

Builtin types should be resolved as SOAP::WSDL::XSD::Builtin::* classes

Creating a type lib is easy: Just run SOAP::WSDL's generator - it will create both a typemap and the type lib classes for a WSDL file.

Sometimes it is nessecary to create type lib classes by hand - not all WSDL definitions are complete.

For writing your own lib classes, see SOAP::WSDL::XSD::Typelib::Element, SOAP::WSDL::XSD::Typelib::ComplexType and SOAP::WSDL::XSD::Typelib::SimpleType.

SOAP::WSDL::Expat::Message2Hash

Transforms a SOAP message into a perl hash refs. Using this parser is usually triggered by calling the outputhash method of SOAP::WSDL, or by using SOAP::WSDL::Deserializer::Hash.

Acts somewhat like XML::Simple, but faster.

The following restrictions apply:

OLD SAX HANDLER ^

Historically, SOAP::WSDL used SAX for parsing XML. The SAX handlers were implemented as XML::LibXML handlers, which also worked with XML::SAX::ParserFactory.

Support for SAX and XML::LibXML in SOAP::WSDL is discontinued for the following reasons:

The old SAX handler historically used in SOAP::WSDL are not included in the SOAP::WSDL package any more.

However, they may be obtained from the "attic" directory in SOAP::WSDL's SVN repository at

https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/attic

LICENSE AND COPYRIGHT ^

Copyright 2007 Martin Kutter.

This file is part of SOAP-WSDL. You may distribute/modify it under the same terms as perl itself.

AUTHOR ^

Martin Kutter <martin.kutter fen-net.de>

REPOSITORY INFORMATION ^

 $Rev: 391 $
 $LastChangedBy: kutterma $
 $Id: Parser.pod 391 2007-11-17 21:56:13Z kutterma $
 $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Manual/Parser.pod $
syntax highlighting: