View on
Keith Brown > SOAP > SOAP::Packager



Annotate this POD


New  4
Open  0
View/Report Bugs
Module Version: 0.28   Source  


SOAP::Packager - SOAP internal helper class


    use SOAP::Packager;
    my $packager = SOAP::Packager->new('s:', 1, sub { print shift } );

    # some object used as a reference
    my $object = SOAP::Object->new();

    # on a given packager, register() always returns the same id for a given object
    my $id = $packager->register($env, $object);
    unless($id == $packager->register($env, $object)) { die "internal error" }

    # this serializes objectA

    # note that the package is still valid
    unless($id == $packager->register($env, $object)) { die "internal error" }

    my $objectB = SOAP::Object->new();
    my $idB = $packager->register($env, $objectB);
    unless($idB == $packager->register($env, $objectB)) { die "internal error" }

    # this just serializes objectB - objectA was already serialized before

    # this does nothing except waste some cycles enumerating a hash table

    # hash tables shut down at destruction of packager, releasing object references
    $packager = undef;


This is an internal class used by the SOAP/Perl implementation. It is designed to manage a table of object references and XML ids used for serializing object graphs that may contain multiref data (and perhaps even cycles). If you are extending SOAP/Perl, the above synopsis will probably be all you need if you want to reuse this class. Whatever you pass for the $env reference should implement a function called _alloc_id that returns a unique string each time it is called. This is normally implemented by SOAP::Envelope, so you can see a sample implementation there.

NOTE NOTE NOTE: The SOAP "package" attribute was dropped when the SOAP spec went from version 1.0 to version 1.1. Use package-related functionality at your own risk - you may not interoperate with other servers if you rely on it. I'll eventually remove this feature if it doesn't reappear in the spec soon.


Keith Brown


SOAP::Envelope SOAP::OutputStream

syntax highlighting: