| 1 | package SOAP::WSDL::Factory::Serializer; | ||||||||||||
| 2 | 28 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 28 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 28 | our $VERSION = 3.004; | |||||||||||
| 6 | |||||||||||||
| 7 | 28 | my %SERIALIZER = ( | |||||||||||
| 8 | '1.1' => 'SOAP::WSDL::Serializer::XSD', | ||||||||||||
| 9 | ); | ||||||||||||
| 10 | |||||||||||||
| 11 | # class method | ||||||||||||
| 12 | 1 | ▶ | sub register { | ||||||||||
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 13 | 1 | my ($class, $ref_type, $package) = @_; | |||||||||||
| 14 | 1 | $SERIALIZER{ $ref_type } = $package; | |||||||||||
| 15 | } | ||||||||||||
| 16 | |||||||||||||
| 17 | 5 | ▶ | sub get_serializer { | ||||||||||
|
Subroutine
get_serializer: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 18 | 5 | my ($self, $args_of_ref) = @_; | |||||||||||
| 19 | 5 | ▶ | $args_of_ref->{ soap_version } ||= '1.1'; | ||||||||||
|
Condition100%2/2
$args_of_ref->{"soap_version"} ||= "1.1"
MC/DC100%1/1
$args_of_ref->{"soap_version"} ||= "1.1"
$args_of_ref->{"soap_version"}
Truth table100%2/2
A
A= $args_of_ref->{"soap_version"}
| |||||||||||||
| 20 | # sanity check | ||||||||||||
| 21 | die "no serializer registered for SOAP version $args_of_ref->{ soap_version }" | ||||||||||||
| 22 | 5 | ▶ | if not exists ($SERIALIZER{ $args_of_ref->{ soap_version } }); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | # load module | ||||||||||||
| 25 | 4 | ▶ | eval "require $SERIALIZER{ $args_of_ref->{ soap_version } }" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | or die "Cannot load serializer $SERIALIZER{ $args_of_ref->{ soap_version } }", $@; | ||||||||||||
| 27 | |||||||||||||
| 28 | 3 | return $SERIALIZER{ $args_of_ref->{ soap_version } }->new(); | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 28 | 1; | |||||||||||
| 32 | |||||||||||||
| 33 | =pod | ||||||||||||
| 34 | |||||||||||||
| 35 | =head1 NAME | ||||||||||||
| 36 | |||||||||||||
| 37 | SOAP::WSDL::Factory::Serializer - Factory for retrieving serializer objects | ||||||||||||
| 38 | |||||||||||||
| 39 | =head1 SYNOPSIS | ||||||||||||
| 40 | |||||||||||||
| 41 | # from SOAP::WSDL::Client: | ||||||||||||
| 42 | $serializer = SOAP::WSDL::Factory::Serializer->get_serializer({ | ||||||||||||
| 43 | soap_version => $soap_version, | ||||||||||||
| 44 | }); | ||||||||||||
| 45 | |||||||||||||
| 46 | # in serializer class: | ||||||||||||
| 47 | package MyWickedSerializer; | ||||||||||||
| 48 | use SOAP::WSDL::Factory::Serializer; | ||||||||||||
| 49 | |||||||||||||
| 50 | # register as serializer for SOAP1.2 messages | ||||||||||||
| 51 | SOAP::WSDL::Factory::Serializer->register( '1.2' , __PACKAGE__ ); | ||||||||||||
| 52 | |||||||||||||
| 53 | =head1 DESCRIPTION | ||||||||||||
| 54 | |||||||||||||
| 55 | SOAP::WSDL::Factory::Serializer serves as factory for retrieving | ||||||||||||
| 56 | serializer objects for SOAP::WSDL. | ||||||||||||
| 57 | |||||||||||||
| 58 | The actual work is done by specific serializer classes. | ||||||||||||
| 59 | |||||||||||||
| 60 | SOAP::WSDL::Serializer tries to load one of the following classes: | ||||||||||||
| 61 | |||||||||||||
| 62 | =over | ||||||||||||
| 63 | |||||||||||||
| 64 | =item * the class registered for the scheme via register() | ||||||||||||
| 65 | |||||||||||||
| 66 | =back | ||||||||||||
| 67 | |||||||||||||
| 68 | =head1 METHODS | ||||||||||||
| 69 | |||||||||||||
| 70 | =head2 register | ||||||||||||
| 71 | |||||||||||||
| 72 | SOAP::WSDL::Serializer->register('1.1', 'MyWickedSerializer'); | ||||||||||||
| 73 | |||||||||||||
| 74 | Globally registers a class for use as serializer class. | ||||||||||||
| 75 | |||||||||||||
| 76 | =head2 get_serializer | ||||||||||||
| 77 | |||||||||||||
| 78 | Returns an object of the serializer class for this endpoint. | ||||||||||||
| 79 | |||||||||||||
| 80 | =head1 WRITING YOUR OWN SERIALIZER CLASS | ||||||||||||
| 81 | |||||||||||||
| 82 | =head2 Registering a deserializer | ||||||||||||
| 83 | |||||||||||||
| 84 | Serializer classes may register with SOAP::WSDL::Factory::Serializer. | ||||||||||||
| 85 | |||||||||||||
| 86 | Serializer objects may also be passed directly to SOAP::WSDL::Client by | ||||||||||||
| 87 | using the set_serializer method. Note that serializers objects set via | ||||||||||||
| 88 | SOAP::WSDL::Client's set_serializer method are discarded when the SOAP | ||||||||||||
| 89 | version is changed via set_soap_version. | ||||||||||||
| 90 | |||||||||||||
| 91 | Registering a serializer class with SOAP::WSDL::Factory::Serializer is done | ||||||||||||
| 92 | by executing the following code where $version is the SOAP version the | ||||||||||||
| 93 | class should be used for, and $class is the class name. | ||||||||||||
| 94 | |||||||||||||
| 95 | SOAP::WSDL::Factory::Serializer->register( $version, $class); | ||||||||||||
| 96 | |||||||||||||
| 97 | To auto-register your transport class on loading, execute register() in | ||||||||||||
| 98 | your tranport class (see L</SYNOPSIS> above). | ||||||||||||
| 99 | |||||||||||||
| 100 | =head2 Serializer package layout | ||||||||||||
| 101 | |||||||||||||
| 102 | Serializer modules must be named equal to the serializer class they contain. | ||||||||||||
| 103 | There can only be one serializer class per serializer module. | ||||||||||||
| 104 | |||||||||||||
| 105 | =head2 Methods to implement | ||||||||||||
| 106 | |||||||||||||
| 107 | Serializer classes must implement the following methods: | ||||||||||||
| 108 | |||||||||||||
| 109 | =over | ||||||||||||
| 110 | |||||||||||||
| 111 | =item * new | ||||||||||||
| 112 | |||||||||||||
| 113 | Constructor. | ||||||||||||
| 114 | |||||||||||||
| 115 | =item * serialize | ||||||||||||
| 116 | |||||||||||||
| 117 | Serializes data to XML. The following named parameters are passed to the | ||||||||||||
| 118 | serialize method in a anonymous hash ref: | ||||||||||||
| 119 | |||||||||||||
| 120 | { | ||||||||||||
| 121 | method => $operation_name, | ||||||||||||
| 122 | header => $header_data, | ||||||||||||
| 123 | body => $body_data, | ||||||||||||
| 124 | } | ||||||||||||
| 125 | |||||||||||||
| 126 | =back | ||||||||||||
| 127 | |||||||||||||
| 128 | =head1 LICENSE AND COPYRIGHT | ||||||||||||
| 129 | |||||||||||||
| 130 | Copyright 2004-2007 Martin Kutter. All rights reserved. | ||||||||||||
| 131 | |||||||||||||
| 132 | This file is part of SOAP-WSDL. You may distribute/modify it under | ||||||||||||
| 133 | the same terms as perl itself. | ||||||||||||
| 134 | |||||||||||||
| 135 | =head1 AUTHOR | ||||||||||||
| 136 | |||||||||||||
| 137 | Martin Kutter E<lt>martin.kutter fen-net.deE<gt> | ||||||||||||
| 138 | |||||||||||||
| 139 | =head1 REPOSITORY INFORMATION | ||||||||||||
| 140 | |||||||||||||
| 141 | $Rev: 851 $ | ||||||||||||
| 142 | $LastChangedBy: kutterma $ | ||||||||||||
| 143 | $Id: Serializer.pm 851 2009-05-15 22:45:18Z kutterma $ | ||||||||||||
| 144 | $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Factory/Serializer.pm $ | ||||||||||||
| 145 | |||||||||||||
| 146 | =cut | ||||||||||||