home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_72c14e60ce1a60aee3bdd9df21699fcc
< prev
next >
Wrap
Text File
|
2000-03-23
|
7KB
|
199 lines
<HTML>
<HEAD>
<TITLE>SOAP::Parser - Parses SOAP documents</TITLE>
<LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> SOAP::Parser - Parses SOAP documents</P></STRONG>
</TD></TR>
</TABLE>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<UL>
<LI><A HREF="#new(typemapper)"><CODE>new(TypeMapper)</CODE></A></LI>
<LI><A HREF="#parsestring(string)"><CODE>parsestring(String)</CODE></A></LI>
<LI><A HREF="#parsefile(filename)"><CODE>parsefile(Filename)</CODE></A></LI>
<LI><A HREF="#get_headers()"><CODE>get_headers()</CODE></A></LI>
<LI><A HREF="#get_body()"><CODE>get_body()</CODE></A></LI>
</UL>
<LI><A HREF="#dependencies">DEPENDENCIES</A></LI>
<LI><A HREF="#author">AUTHOR</A></LI>
<LI><A HREF="#see also">SEE ALSO</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>SOAP::Parser - Parses SOAP documents</P>
<P>
<HR>
<H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
<UL>
<LI>Linux</LI>
<LI>Solaris</LI>
<LI>Windows</LI>
</UL>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
use SOAP::Parser;
</PRE>
<PRE>
my $parser = SOAP::Parser->new();</PRE>
<PRE>
$parser->parsefile('soap.xml');</PRE>
<PRE>
my $headers = $parser->get_headers();
my $body = $parser->get_body();</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>SOAP::Parser has all the logic for traversing a SOAP packet, including
Envelope, Header, and Body, dealing with namespaces and tracking down
references. It is basically an extension of a SAX-like parser, which
means that it exposes an event-driven interface that you can implement
to get the results of the parse. By default, SOAP/Perl provides
SOAP::GenericInputStream to handle these events, which simply produces
an object graph of hash references. If you want something
different, on a per type URI basis, you can register alternate handlers
so you can produce different output. See SOAP::TypeMapper for details.</P>
<P>The handler needs to implement a set of methods, and these are outlined
in SOAP::GenericInputStream along with descriptions of what the default
behavior is (in other words, what SOAP::GenericInputStream does for each
of these methods).</P>
<P>The benefit of this design is that it avoids using a DOM to parse SOAP
packets; rather, the packet is unmarshaled directly into whatever final
form you need. This is more efficient in space and time than first unmarshaling
into a DOM and then traversing the DOM to create an object graph that is
meaningful to your program. To get the full benefit of this, you may need to
implement a handler that creates your custom object graph from the SOAP packet
(see SOAP::GenericInputStream for details). Since SOAP::Parser does all the
hard work, implementing a handler (or set of handlers) is really pretty
painless.</P>
<P>
<H2><A NAME="new(typemapper)"><CODE>new(TypeMapper)</CODE></A></H2>
<P>Creates a new parser. Be sure *not* to reuse a parser for multiple SOAP
packets - create one, use it, and then throw it away and get a new one if you
need to parse a second SOAP packet.</P>
<P>TypeMapper is an optional parameter that points to an instance of SOAP::TypeMapper
that allows you to register alternate serializers and deserializers for different
classes of objects. See the docs for that class for more details. If you don't
pass this parameter, the system uses a global TypeMapper object.</P>
<P>
<H2><A NAME="parsestring(string)"><CODE>parsestring(String)</CODE></A></H2>
<P>Parses the given string.</P>
<P>
<H2><A NAME="parsefile(filename)"><CODE>parsefile(Filename)</CODE></A></H2>
<P>Parses the given file.</P>
<P>
<H2><A NAME="get_headers()"><CODE>get_headers()</CODE></A></H2>
<P>After parsing, this function returns the array of headers
in the SOAP envelope.</P>
<P>Specifically, this function returns an array reference that
contains zero or more hash references, each
of which always take the following form:</P>
<PRE>
{
soap_typeuri => 'namespace qualification of header',
soap_typename => 'unqualified name of header',
content => <header object>
}</PRE>
<P>For instance, the following header:</P>
<PRE>
<f:MyHeader xmlns:f="urn:foo">42 </f:MyHeader></PRE>
<P>would be deserialized in this form:</P>
<PRE>
{
soap_typeuri => 'urn:foo',
soap_typename => 'MyHeader',
content => 42,
}
</PRE>
<PRE>
while this header:</PRE>
<PRE>
<f:MyHeader xmlns:f="urn:foo">
<m1>something</m1>
<m2>something else</m2>
</f:MyHeader></PRE>
<P>would be deserialized (by default) in this form:</P>
<PRE>
{
soap_typeuri => 'urn:foo',
soap_typename => 'MyHeader',
content => {
soap_typeuri => 'urn:foo',
soap_typename => 'MyHeader',
m1 => 'something',
m2 => 'something else',
},
}</PRE>
<P>Note the redundancy of the soap_typeuri and soap_typename isn't
strictly necessary in this case because this information is embedded
in the content itself. However, because of the potential (and common
need) for sending scalars as the entirety of the header content,
we need some way of communicating the namespace and typename of the
header. Thus the content, for consistency, is always packaged in
a hash along with explicit type information.</P>
<P>
<H2><A NAME="get_body()"><CODE>get_body()</CODE></A></H2>
<P>After parsing, this function retrieves the body of the SOAP envelope.</P>
<P>Since it doesn't make sense to send just a scalar as the body
of a SOAP request, we don't need the redundancy of packaging the content
inside of a hash along with its type and namespace (as was done above
with headers). For instance:</P>
<PRE>
<f:MyBody xmlns:f="urn:foo">
<m1>something</m1>
<m2>something else</m2>
</f:MyBody></PRE>
<P>would be deserialized (by default) as the following:</P>
<PRE>
{
soap_typeuri => 'urn:foo',
soap_typename => 'MyBody',
m1 => 'something',
m2 => 'something else',
}</PRE>
<P>
<HR>
<H1><A NAME="dependencies">DEPENDENCIES</A></H1>
<P>XML::Parser::Expat
SOAP::GenericInputStream
SOAP::Defs</P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Keith Brown</P>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P>SOAP::GenericInputStream</P>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> SOAP::Parser - Parses SOAP documents</P></STRONG>
</TD></TR>
</TABLE>
</BODY>
</HTML>