home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>SOAP::GenericInputStream - Default handler for SOAP::Parser output</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::GenericInputStream - Default handler for SOAP::Parser output</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(typeuri, typename, resolver)">new(TypeUri, TypeName, Resolver)</A></LI>
- <LI><A HREF="#simple_accessor(accessoruri, accessorname, typeuri, typename, content)">simple_accessor(AccessorUri, AccessorName, TypeUri, TypeName, Content)</A></LI>
- <LI><A HREF="#compound_accessor(accessoruri, accessorname, typeuri, typename, ispackage, resolver)">compound_accessor(AccessorUri, AccessorName, TypeUri, TypeName, IsPackage, Resolver)</A></LI>
- <LI><A HREF="#reference_accessor(accessoruri, accessorname, object)">reference_accessor(AccessorUri, AccessorName, Object)</A></LI>
- <LI><A HREF="#forward_reference_accessor(accessoruri, accessorname)">forward_reference_accessor(AccessorUri, AccessorName)</A></LI>
- <LI><A HREF="#term()"><CODE>term()</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::GenericInputStream - Default handler for SOAP::Parser output</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>As you can see from the synopsis, you won't use SOAP::GenericInputStream
- directly, but rather the SOAP::Parser will create instances of it when
- necessary to unmarshal SOAP documents.</P>
- <P>The main reason for this documentation is to describe the interface
- exposed from SOAP::GenericInputStream because you need to implement this
- interface if you'd like to have the parser create something more exotic
- than what SOAP::GenericInputStream produces.</P>
- <P>
- <H2><A NAME="new(typeuri, typename, resolver)">new(TypeUri, TypeName, Resolver)</A></H2>
- <P>TypeUri and TypeName are strings that indicate the type of object being
- unmarshaled. Resolver is a function pointer takes a single argument,
- the resulting object, and you should call through this pointer in your
- implementation of term (which means you need to store it until term is
- called). Here's an example of a minimal implementation, assuming you've
- stored the object reference in $self->{object}:</P>
- <PRE>
- sub new {
- my ($class, $typeuri, $typename, $resolver) = @_;
- return bless { resolver => $resolver }, $class;
- }</PRE>
- <PRE>
- sub term {
- my ($self) = @_;
- $self->{resolver}->($self->{object});
- }</PRE>
- <P>
- <H2><A NAME="simple_accessor(accessoruri, accessorname, typeuri, typename, content)">simple_accessor(AccessorUri, AccessorName, TypeUri, TypeName, Content)</A></H2>
- <P>SOAP::Parser calls this function when it encounters a simple (scalar) accessor.
- You are told the uri and name of both the accessor and any xsi:type attribute.
- If the packet being unmarshaled doesn't use namespaces (this is possible but isn't
- recommended by the SOAP spec), AccessorUri will be undefined. Unless there is an
- explicit xsi:type, TypeUri and TypeName will also be undefined. So the only two
- parameters that are guaranteed to be defined are AccessorName and Content.</P>
- <P>AccessorUri and AccessorName gives the namespace and name of the element,
- and Content contains the scalar content (always a string).</P>
- <P>
- <H2><A NAME="compound_accessor(accessoruri, accessorname, typeuri, typename, ispackage, resolver)">compound_accessor(AccessorUri, AccessorName, TypeUri, TypeName, IsPackage, Resolver)</A></H2>
- <P>SOAP::Parser calls this function when it encounters a compound accessor (e.g.,
- a structured type whose value is inlined under the accessor). The first four
- parameters here are as described in simple_accessor above. IsPackage is a hint
- that tells you that this node is a package (generally you can ignore this; SOAP::Parser
- does all the work to deal with packages). Resolver may or may not be defined,
- and I'll discuss how it works shortly.</P>
- <P>This function must return a blessed object reference that implements the
- same interface (nothing prohibits you from simply returning $self, but since SOAP::Parser
- keeps track of these object references on a per-node basis, it's usually easier just
- to create a new instance of your class and have each instance know how to unmarshal
- a single object).</P>
- <P>If Resolver is defined, you'll need to call it when the new stream is term'd to
- communicate the resulting object reference to the Parser, so be sure to propagate
- this reference to the new stream you create to do the unmarshaling. Since you probably
- also need to be notified when the new object is created, you'll not normally hand Resolver
- directly to the new stream, but rather you'll provide your own implementation of Resolver
- that does something with the object and then chains to the Resolver passed in from the
- parser:</P>
- <PRE>
- sub compound_accessor {
- my ($self, $accessor_uri, $accessor_name, $typeuri, $typename, $is_package, $resolver) = @_;</PRE>
- <PRE>
- my $object = $self->{object};</PRE>
- <PRE>
- # create a closure to pass to the new input stream
- my $my_resolver = sub {
- my ($newly_unmarshaled_object) = @_;</PRE>
- <PRE>
- # do something with the object yourself
- $object->{$accessor_name} = $newly_unmarshaled_object;</PRE>
- <PRE>
- # chain to the Parser's resolver if it's defined
- $resolver->($child_object) if $resolver;
- };</PRE>
- <PRE>
- return $self->{type_mapper}->get_deserializer($typeuri, $typename, $my_resolver);
- }</PRE>
- <P>
- <H2><A NAME="reference_accessor(accessoruri, accessorname, object)">reference_accessor(AccessorUri, AccessorName, Object)</A></H2>
- <P>SOAP::Parser calls this function when it encounters a reference to an object that
- it's already unmarshaled. AccessorUri and AccessorName are the same as in simple_accessor,
- and Object is a reference to a thingy; it's basically whatever was resolved when
- another stream (perhaps one that you implemented) unmarshaled the thingy. This could
- be a blessed object reference, or simply a reference to a scalar (in SOAP it is possible
- to communicate pointers to multiref scalars). In any case, you should add this new
- reference to the object graph. Here's a simple example:</P>
- <PRE>
- sub reference_accessor {
- my ($self, $accessor_uri, $accessor_name, $object) = @_;</PRE>
- <PRE>
- $self->{object}{$accessor_name} = $object;
- }</PRE>
- <P>
- <H2><A NAME="forward_reference_accessor(accessoruri, accessorname)">forward_reference_accessor(AccessorUri, AccessorName)</A></H2>
- <P>SOAP::Parser calls this function when it encounters a reference to an object that
- has not yet been unmarshaled (a forward reference). You should return a function
- pointer that expects a single argument (the unmarshaled object). This can be as simple
- as creating a closure that simply delays a call to reference_accessor on yourself:</P>
- <PRE>
- sub forward_reference_accessor {
- my ($self, $accessor_uri, $accessor_name) = @_;</PRE>
- <PRE>
- # return a closure to complete the transaction at a later date
- return sub {
- my $object = @_;
- $self->reference_accessor($accessor_uri, $accessor_name, $object);
- };
- }</PRE>
- <P>
- <H2><A NAME="term()"><CODE>term()</CODE></A></H2>
- <P>SOAP::Parser calls this function when there are no more accessors for the given node.
- You are expected to call the Resolver you were passed at construction time at this point
- to pass the unmarshaled object reference to your parent. Note that due to forward
- references, the object may not be complete yet (it may have oustanding forward references
- that haven't yet been resolved). This isn't a problem, because the parse isn't finished
- yet, and as long as you've provided a resolver that fixes up these object references
- from your implementation of forward_reference_accessor, by the time the parse is complete,
- your object have all its references resolved by the parser.</P>
- <P>See the description of <CODE>new()</CODE> for an example implementation of this function.</P>
- <P>
- <HR>
- <H1><A NAME="dependencies">DEPENDENCIES</A></H1>
- <P>SOAP::TypeMapper</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>perl(1).</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::GenericInputStream - Default handler for SOAP::Parser output</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-