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