1package SOAP::Struct; 2 3use strict; 4use vars qw($VERSION); 5 6use SOAP::StructSerializer; 7 8$VERSION = '0.28'; 9 10sub new { 11 my $class = shift; 12 my $self = { 13 content => [@_], 14 }; 15 bless $self, $class; 16} 17 18sub new_typed { 19 my $self = &new; 20 $self->{contains_types} = 1; 21 $self; 22} 23 24sub get_soap_serializer { 25 my $self = shift; 26 SOAP::StructSerializer->new($self); 27} 28 291; 30__END__ 31 32=head1 NAME 33 34SOAP::Struct - support for ordered hashes 35 36=head1 SYNOPSIS 37 38use SOAP::EnvelopeMaker; 39 40# produce a body that will retain the order of params 41# when serialized to a SOAP envelope 42my $body = SOAP::Struct->new( 43 a => 3, 44 b => 4, 45); 46 47# same as above, but explicit xsi:type attrs will also 48# be included for accessor 'b' 49my $body = SOAP::Struct->new_typed( 50 a => 3, undef, 51 b => 4, 'float', 52); 53 54=head1 DESCRIPTION 55 56The SOAP spec explicitly mandates that it should be possible to 57serialize structures and control both the names of the accessors 58and the order that they appear in the serialized stream. 59(SOAP 1.1, section 7.1, bullet 3) Prior to 60SOAP/Perl 0.25, this was impossible, as the only way to serialize 61a "struct" was to use a hash, which is unordered in Perl. This class 62allows you to specify a structure where the order of the accessors 63is preserved. This is important when making SOAP calls to many 64traditional RPC-style servers that expect parameters to arrive 65in a certain order (and could generally care less about the 66names of those parameters). 67 68=head2 new(accessor_1_name => accessor_1_value, ...) 69 70This constructor feels the same as constructing a hash, but the order 71of the accessors will be maintained when this "super-hash" is serialized. 72 73=head2 new_typed(accessor_1_name => accessor_1_value, accessor_1_type, ...) 74 75This constructor is for convenience - if you pass something other than 76undef for accessor_n_type, then accessor_n_value will be wrapped with 77a TypedPrimitive class with the specified type. This way you can force 78explicit type names to be used for each element in the structure. 79See SOAP::TypedPrimitive for a discussion of why this can be important. 80 81=head1 DEPENDENCIES 82 83SOAP::TypedPrimitive 84 85=head1 AUTHOR 86 87Keith Brown 88 89=head1 SEE ALSO 90 91SOAP::TypedPrimitive 92 93=cut 94