view release on metacpan or search on metacpan
1.19 August 26, 2015
! #106665 Correct the version manually, no autoversioning, and the maintainer screwed up
1.18 August 25, 2015
! Fix a couple of cases where undefined values were being passed to functions [github/redhotpenguin]
! Do not set content_length for compressed request [github/bor]
! Add test for check return of send_receive(), add titles for some tests [github/bor]
1.17 July 30, 2015
! #106051 Fix utf8 encoding for CGI test (thanks cpan/ETHER for tips)
1.16 July 23, 2015
! Fix empty release. Note to self - do not release code when wife is in early labor
1.15 July 21, 2015
+ Preventing "billion laughs" exponential entity expansion attack [github/thilo-fester]
1.14 March 24, 2015
+ Add header and body tags [@bubi6608]
! Fixed typo in trace logging example [@oschwald]
! #85098 Monkey patch for LWP::Protocol confuses the toolchain
! #78692 / #84724 / #83715 Sending large object (many levels deep) throws error Incorrect parameter
! #78502 t/08-schema.t noisy under 5.17.2 (unescaped left brace in regex is deprecated)
! #78608 Documentation for "+trace"
! #78639 Spelling error reported by Debian tools
0.715
! #75938 Change to warning / add configuration variable to allow XML tags starting with /xml/i
! #76902 Missing info in "SSL CERTIFICATE AUTHENTICATION" documentation
! #74577 work around/fixes for success with MS WS https/compressed
! #74308 SOAP-Lite fails for operations with period in name
! #73802 client did not set the encoding of the soap-envelope to 'iso-8859-1' in HTTP-request
! #75019 HTTP server doesn't process PIPE signal
! #72836 Processing a SOAP 1.2 request breaks the next SOAP 1.1 response
! #70381 SOAP-Lite performance
! #53375 comments after <?xml .. >
! #63693 Uninitalized value (again)
! #37360 Use of uninitialized variables in SOAP tests
! fixed encoding in xmlrpc keys
! #15176 problems with SOAP::Header ->value
0.714
Moved SOAP::Transport::TCP into SOAP-Transport-TPC distribution
! #70329 - not generating attributes properly (deleting id attribute)
0.713
! #52637 error sending a request in perl 5.10.0 containing utf-8 data using the string data type
! #48775 Small bug in SOAP::Packager
! #51178 Emailing: SOAP-Lite-0.710.10.patch
! #55962 Spelling errors
! #52015 defined(%hash) deprecated in Perl 5.11
+ To better segment SOAP::Lite documentation, many modules have been
added that contain documentation only. For those who loved the old
documentation, it can be found in lib/OldDocs/SOAP/*.pm and
lib/OldDocs/SOAP/Transport/*.pm
! Fix a bug in which doclit style arrays were not being deserialized
properly. IOW, Repeated elements were not made into an array, only
the last occurring value was recorded.
+ Added the ability for a SOAP Client to gain direct access to the
HTTP::Request and HTTP::Response objects.
+ Changed default envelope namespace prefix from SOAP-ENV to soap
+ Changed default encoding namespace prefix from SOAP-ENC to soapenc
+ Reachitected MIME support to decouple MIME layer from transport
layer. This only impacts the HTTP layer since that is the only
transport in SOAP::Lite that supports attachments.
+ Creation of SOAP::Packager - decoupled in an extensible way the
packaging of parts (a.k.a. attachments). This is used for encoding
and decoding. This enables a more seemless addition of DIME
support. Changes were made throughout SOAP::Lite to accomodate this
functionality.
- a call "context" was added to SOAP::Server and SOAP::Deserializer
so that those classes could have access to the global
SOAP::Packager instance
- deprecated many function calls and packages having to do with
attachment support
- fixed several of the SOAP::*::new() methods so that they don't
inadvertantly reinitialize themselves and destroy precious context
so that they have mechanisms for getting instance data from the
calling context. The value of context is either SOAP::Lite or
SOAP::Server depending upon the role the service is playing in the
transaction. Contexts are initialized when a call is made, and
destroyed when a call is completed.
+ Greater than character '>' has been added to list of characters
that will be automatically escaped. This is not a requirement by
the XML spec, it is a MAY, but I am doing it after seeing a minority
of people report a compatibility problem.
- Removed deprecated methods: SOAP::Serializer::namespace and
encodingspace
+ Added SOAP::Serializer::encodingStyle method which allows users to
set the URI for default encodingStyle.
+ Added initial support for literal encoding style. EXPERIMENTAL
+ Added some true constant values representing various SOAP namespace
URIs
+ Added SOAP::Constants::SUPPORTED_ENCODING_STYLES for better tracking
of the set of encoding styles that the toolkit can [de]serialize
! Fixed bug 840172 - "Makefile.PL --noprompt flag broken," now fixed
+ Updated SOAP 1.2 URIs to the latest (TODO - maintain support for
older ones)
+ Added HTTPS support for HTTP::Server Daemon class - thanks to Nils
Sowen for this contribution
-----------------------------------------------------------------------
PREVIOUS RELEASES
-----------------------------------------------------------------------
1 (bug 747281)
! Removed dependency on the URI module for non-HTTP transports
(bug 747306)
0.55 Mon Apr 15 22:20:39 2002
! fixed security vulnerability with fully qualified method names
(thanks to Randal Schwartz, Ilya Martynov and many others)
! fixed problem with TCP transport and SSL (thanks to Chris Hurd)
! fixed TCP transport to specify correct length with utf8 strings
(thanks to Robin Fuller)
! fixed incorrect encoding when parameters list includes undefined
values (thanks to Chris Radcliff)
! updated 'xmlsoap' prefix (thanks to Pierre Denis)
! updated MIME parser to accept messages that start with 'From'
(thanks to Chris Davies)
+ added check for TCP transport on Mac (thanks to Robin Fuller)
+ added check for shutdown() method on AIX (thanks to Jos Clijmans)
+ added check for blocking() method in TCP transport
(thanks to Jos Clijmans)
+ optimized parsing strings with entity encoding (thanks to Mathieu
Longtin)
+ added check for entity size for CGI transport
($SOAP::Constant::MAX_CONTENT_SIZE) (thanks to J. Klunder)
+ added example (google.pl)
+ updated tests and examples with new endpoints
0.52 Mon Oct 18 21:20:19 2001
! fixed content_type returned under mod_perl with 500 SERVER ERROR
status (thanks to Geoffrey Young and Scott Hutton)
! fixed problem with multiple bindings in WSDL file generated by
+ added XMLRPC support in COM interface. XMLRPC client and server
can be created using COM interface
+ added DO_NOT_PROCESS_XML_IN_MIME option for MIME parts with
text/xml content type
+ modified deserialization algorithm that allows to properly
deserialize SOAP1.2 messages when default is set to SOAP1.1 and
vice versa
+ added fault in XMLRPC::Lite for incorrect datatypes specified by
user (thanks to Paul Prescod)
+ added option to not generate XML declaration
+ added encoding for ']]>' (thanks to Matt Sergeant and James
Amrhein)
+ added '\r' => '
' conversion in strings
+ added complaint on incorrect simple types
+ added byNameOrOrder and byName functions for
SOAP::Server::Parameters (thanks to Matt Stum)
+ added handling relative locations in <import> in WSDL
+ added stringification of SOAP::Fault (thanks to Tim Jenness)
+ added documentation for SSL certificate authentication
+ added more examples (terraserver.pl, joke.pl, weblog.pl)
+ added more tests
+ added server scripts for MQ and JABBER transports
+ added roundtrip example for JABBER transport
+ updated documentation and added new examples
+ added more tests (more than 700 for now)
0.50 Wed Apr 18 11:45:14 2001
! fixed tests on Windows platform
! fixed authInfo in UDDI publishing interface
! fixed mod_soap (Apache::SOAP) on Perl 5.005/5.004
! fixed namespace prefix on arrays of arrays
! modified Content-encoding from 'compress' to 'deflate'
+ added XML::Parser::Lite, regexp-based XML parser
used automatically when XML::Parser is not available
+ added examples of custom serialization and deserialization
(XML::DOM)
+ added XMLRPC::Lite (XMLRPC client and server interface)
all transports and features of SOAP::Lite should be available
+ added XMLRPC interactive shell (XMLRPCsh.pl)
+ added dispatching based on URI and SOAPAction (dispatch_with)
+ added dispatching to object (in addition to class/method)
+ added dispatch from specific class(es) (dispatch_from)
! changed interface of schema() method. Use service() instead
+ added COM interface
single dll (standalone or minimal version, downloadable separately)
doesn't require ROPE.dll, MSXML.dll or listener.asp
tested on Windows 98/2K, and should work on Windows 9x/Me/NT/2K
ASP and daemon server implementations
examples in VB/VBS, Excel/VBA, JavaScript, Perl and ASP
+ added parsing multipart/form-data
SOAP server can accept SOAP requests directly from web form
examples are provided (examples/forms/*)
+ added Map type for hash encoding. Tested with ApacheSOAP
+ added function that maps classes to URI (maptype)
+ allowed multiple ports in WSDL
+ tested object interoperability with Apache SOAP
+ optimized internal functions
0.45 Tue Jan 16 00:38:04 2001
! fixed interoperability problem with incorrect Array prefix for
Apache SOAP
+ added interoperability tests for Apache SOAP
+ added interoperability tests with MS SOAP, 4s4c and Lucin
! fixed Makefile.PL
! tests confirmed that memory leak is gone
+ changed syntax for UDDI client to more flexible/convenient
+ added limited support for WSDL schemas. Dynamic and stub access
supported
+ added script for stub generation (stubmaker.pl)
+ optimized code on server side
+ object interface for SOAP, UDDI and schemas are supported
consistently
+ allowed manipulation of method's attributes and namespaces
+ added attributes encoding ('&', '<' and '"' are encoded)
+ updated documentation
(thanks to Robert Barta who basically did this work)
+ added more examples and tests (154 for now)
0.42 Tue Nov 14 23:14:18 2000
+ added UDDI client (UDDI::Lite) with documentation
+ added M-POST functionality in HTTP::Client
+ added redirect (3??) functionality in HTTP::Client
+ added session cache for M-POSTs and redirects
+ added conversion of all objects to o-b-r in parameters
+ changed passing envelope into method
+ allowed \x0d and \x0a in strings (will not do base64 encode)
+ added die with object that allows to specify complex Fault detail
+ optimized XML encoding
+ allowed function call with autodispatch
+ improved syntax for 'use SOAP::Lite'
+ added soap.tcp example for TCP server implementation
+ added tests with Microsoft implementation
+ added documentation and tests (145 for now)
0.41 Tue Oct 31 01:24:51 2000
! fixed memory leak on server side
! fixed die on absence of HTTP::* modules on server side
! fixed working with keep-alive connections (added test with
+ added versionMismatch reaction
+ added local: protocol for local binding without any transport
+ added examples for objects-by-reference: persistent/session
iterators and chat (40 lines on server and 25 lines on client side)
0.39 Sun Oct 8 22:55:20 2000
! fixed incompatibility with Perl 5.005
+ added interactive Makefile.PL for CPAN installation
0.38 Thu Oct 5 22:06:20 2000
! fixed namespace for base64 encoding
! fixed security problem on server side, upgrade is highly
recommended
+ added HTTPS/SSL support
+ added SMTP client implementation
+ added POP3 server implementation
+ added support for Basic/Digest server authentication
+ added support for header(s) on client/server side with SOAP::Header
+ added Array and SOAPStruct for interoperability with ApacheSOAP
+ added generic class for server support SOAP::Server
+ added Actor attribute
Debian_CPANTS.txt view on Meta::CPAN
"libemail-abstract-perl", "Email-Abstract", "3.004", "0", "0"
"libemail-address-perl", "Email-Address", "1.892", "1", "1"
"libemail-date-format-perl", "Email-Date-Format", "1.002", "0", "0"
"libemail-date-perl", "Email-Date", "1.103", "0", "0"
"libemail-filter-perl", "Email-Filter", "1.032", "0", "0"
"libemail-folder-perl", "Email-Folder", "0.855", "0", "0"
"libemail-localdelivery-perl", "Email-LocalDelivery", "0.217", "0", "1"
"libemail-messageid-perl", "Email-MessageID", "1.402", "0", "0"
"libemail-mime-contenttype-perl", "Email-MIME-ContentType", "1.014", "0", "0"
"libemail-mime-createhtml-perl", "Email-MIME-CreateHTML", "1.030", "0", "0"
"libemail-mime-encodings-perl", "Email-MIME-Encodings", "1.313", "0", "0"
"libemail-mime-perl", "Email-MIME", "1.907", "0", "0"
"libemail-outlook-message-perl", "Email-Outlook-Message", "0.910", "0", "0"
"libemail-received-perl", "Email-Received", "1.00", "0", "0"
"libemail-send-io-perl", "Email-Send-IO", "2.200", "1", "0"
"libemail-send-perl", "Email-Send", "2.198", "0", "2"
"libemail-sender-perl", "Email-Sender", "0.110001", "0", "0"
"libemail-sender-transport-smtp-tls-perl", "Email-Sender-Transport-SMTP-TLS", "0.07", "0", "0"
"libemail-simple-perl", "Email-Simple", "2.100", "1", "0"
"libemail-thread-perl", "Email-Thread", "0.711", "0", "0"
"libemail-valid-loose-perl", "Email-Valid-Loose", "0.05", "0", "0"
Debian_CPANTS.txt view on Meta::CPAN
"libhash-moreutils-perl", "Hash-MoreUtils", "0.02", "0", "0"
"libhash-multivalue-perl", "Hash-MultiValue", "0.08", "0", "0"
"libhash-withdefaults-perl", "Hash-WithDefaults", "0.04", "0", "0"
"libhook-lexwrap-perl", "Hook-LexWrap", "0.24", "0", "1"
"libhook-wrapsub-perl", "Hook-WrapSub", "0.03", "0", "0"
"libhtml-autopagerize-perl", "HTML-AutoPagerize", "0.01", "0", "0"
"libhtml-calendarmonthsimple-perl", "HTML-CalendarMonthSimple", "1.25", "0", "0"
"libhtml-clean-perl", "HTML-Clean", "0.8", "0", "5"
"libhtml-copy-perl", "HTML-Copy", "1.30", "0", "0"
"libhtml-display-perl", "HTML-Display", "0.39", "0", "0"
"libhtml-encoding-perl", "HTML-Encoding", "0.61", "0", "0"
"libhtml-fillinform-perl", "HTML-FillInForm", "2.00", "0", "0"
"libhtml-form-perl", "HTML-Form", "6.00", "0", "0"
"libhtml-format-perl", "HTML-Format", "2.05", "1", "0"
"libhtml-formattext-withlinks-perl", "HTML-FormatText-WithLinks", "0.14", "0", "0"
"libhtml-formfu-model-dbic-perl", "HTML-FormFu-Model-DBIC", "0.09000", "0", "2"
"libhtml-formfu-perl", "HTML-FormFu", "0.09003", "0", "4"
"libhtml-formhandler-model-dbic-perl", "HTML-FormHandler-Model-DBIC", "not-uploaded", "0", "0"
"libhtml-formhandler-perl", "HTML-FormHandler", "not-uploaded", "0", "0"
"libhtml-highlight-perl", "HTML-Highlight", "0.20", "0", "1"
"libhtml-html5-parser-perl", "HTML-HTML5-Parser", "0.103", "0", "0"
Debian_CPANTS.txt view on Meta::CPAN
"libhttp-lite-perl", "HTTP-Lite", "2.3", "0", "0"
"libhttp-message-perl", "HTTP-Message", "6.01", "2", "0"
"libhttp-negotiate-perl", "HTTP-Negotiate", "6.00", "0", "0"
"libhttp-oai-perl", "HTTP-OAI", "3.24", "0", "0"
"libhttp-parser-perl", "HTTP-Parser", "0.06", "0", "0"
"libhttp-parser-xs-perl", "HTTP-Parser-XS", "0.12", "0", "0"
"libhttp-proxy-perl", "HTTP-Proxy", "0.24", "1", "3"
"libhttp-recorder-perl", "HTTP-Recorder", "0.05", "0", "0"
"libhttp-request-ascgi-perl", "HTTP-Request-AsCGI", "1.2", "0", "0"
"libhttp-request-params-perl", "HTTP-Request-Params", "1.01", "0", "0"
"libhttp-response-encoding-perl", "HTTP-Response-Encoding", "0.05", "0", "0"
"libhttp-server-simple-mason-perl", "HTTP-Server-Simple-Mason", "0.14", "0", "1"
"libhttp-server-simple-perl", "HTTP-Server-Simple", "0.44", "1", "1"
"libhttp-server-simple-psgi-perl", "HTTP-Server-Simple-PSGI", "0.14", "0", "0"
"libhttp-server-simple-recorder-perl", "HTTP-Server-Simple-Recorder", "0.03", "0", "0"
"libhttp-server-simple-static-perl", "HTTP-Server-Simple-Static", "0.07", "0", "0"
"libhttp-tiny-perl", "HTTP-Tiny", "0.012", "0", "1"
"libi18n-acceptlanguage-perl", "I18N-AcceptLanguage", "1.04", "0", "0"
"libi18n-charset-perl", "I18N-Charset", "1.396", "0", "1"
"libical-parser-perl", "iCal-Parser", "1.16", "0", "0"
"libima-dbi-contextual-perl", "Ima-DBI-Contextual", "0.006", "0", "0"
Debian_CPANTS.txt view on Meta::CPAN
"libtemplate-multilingual-perl", "Template-Multilingual", "1.00", "0", "0"
"libtemplate-plugin-calendar-simple-perl", "Template-Plugin-Calendar-Simple", "0.02", "0", "0"
"libtemplate-plugin-class-perl", "Template-Plugin-Class", "0.13", "0", "1"
"libtemplate-plugin-clickable-email-perl", "Template-Plugin-Clickable-Email", "0.01", "0", "0"
"libtemplate-plugin-clickable-perl", "Template-Plugin-Clickable", "0.06", "0", "0"
"libtemplate-plugin-cycle-perl", "Template-Plugin-Cycle", "not-uploaded", "0", "1"
"libtemplate-plugin-javascript-perl", "Template-Plugin-JavaScript", "0.02", "0", "0"
"libtemplate-plugin-number-format-perl", "Template-Plugin-Number-Format", "1.02", "0", "0"
"libtemplate-plugin-textile2-perl", "Template-Plugin-Textile2", "1.21", "0", "0"
"libtemplate-plugin-yaml-perl", "Template-Plugin-YAML", "1.23", "0", "0"
"libtemplate-provider-encoding-perl", "Template-Provider-Encoding", "0.10", "0", "0"
"libtemplate-provider-fromdata-perl", "Template-Provider-FromDATA", "0.10", "0", "0"
"libtemplate-timer-perl", "Template-Timer", "1.00", "1", "0"
"libtemplate-tiny-perl", "Template-Tiny", "0.11", "0", "0"
"libterm-encoding-perl", "Term-Encoding", "0.02", "0", "0"
"libterm-progressbar-perl", "Term-ProgressBar", "2.09", "0", "1"
"libterm-prompt-perl", "Term-Prompt", "1.04", "0", "0"
"libterm-query-perl", "Term-Query", "2.0", "0", "1"
"libterm-readkey-perl", "TermReadKey", "2.30", "0", "2"
"libterm-readline-gnu-perl", "Term-ReadLine-Gnu", "1.20", "2", "3"
"libterm-readline-perl-perl", "Term-ReadLine-Perl", "1.0303", "0", "0"
"libterm-readpassword-perl", "Term-ReadPassword", "0.11", "0", "0"
"libterm-shell-perl", "Term-Shell", "0.02", "1", "0"
"libterm-size-perl", "Term-Size", "0.2", "0", "0"
"libterm-sk-perl", "Term-Sk", "0.07", "0", "1"
Debian_CPANTS.txt view on Meta::CPAN
"libxml-atom-service-perl", "XML-Atom-Service", "0.16.1", "0", "0"
"libxml-atom-simplefeed-perl", "XML-Atom-SimpleFeed", "0.86", "0", "0"
"libxml-autowriter-perl", "XML-AutoWriter", "0.40", "1", "1"
"libxml-bare-perl", "XML-Bare", "0.45", "0", "0"
"libxml-checker-perl", "XML-Checker", "0.13", "0", "0"
"libxml-csv-perl", "XML-CSV", "0.15", "0", "0"
"libxml-dom-perl", "XML-DOM", "1.44", "1", "2"
"libxml-dom-xpath-perl", "XML-DOM-XPath", "0.14", "0", "0"
"libxml-dtdparser-perl", "XML-DTDParser", "2.01", "0", "0"
"libxml-easyobj-perl", "XML-EasyOBJ", "1.12", "0", "1"
"libxml-encoding-perl", "XML-Encoding", "2.07", "0", "1"
"libxml-feed-perl", "XML-Feed", "0.43", "1", "2"
"libxml-feedpp-mediarss-perl", "XML-FeedPP-MediaRSS", "0.02", "0", "0"
"libxml-feedpp-perl", "XML-FeedPP", "0.43", "0", "0"
"libxml-filter-buffertext-perl", "XML-Filter-BufferText", "1.01", "0", "0"
"libxml-filter-detectws-perl", "XML-Filter-DetectWS", "0.01", "0", "0"
"libxml-filter-reindent-perl", "XML-Filter-Reindent", "0.03", "0", "1"
"libxml-filter-saxt-perl", "XML-Filter-SAXT", "0.01", "0", "0"
"libxml-filter-sort-perl", "XML-Filter-Sort", "1.01", "1", "0"
"libxml-filter-xslt-perl", "XML-Filter-XSLT", "0.03", "0", "0"
"libxml-generator-perl", "XML-Generator", "1.01", "0", "1"
The prefix itself has no meaning, but applications may wish to chose
one explicitly to denote different versions of SOAP or the like.
encprefix(QName)
$client->encprefix('enc');
This method is a shortcut for:
$client->serializer->encprefix(QName);
Gets or sets the namespace prefix for the encoding rules namespace.
The default value is SOAP-ENC.
While it may seem to be an unnecessary operation to set a value that
isn't relevant to the message, such as the namespace labels for the
envelope and encoding URNs, the ability to set these labels explicitly
can prove to be a great aid in distinguishing and debugging messages on
the server side of operations.
encoding(encoding URN)
$client->encoding($soap_12_encoding_URN);
This method is a shortcut for:
$client->serializer->encoding(args);
Where the earlier method dealt with the label used for the
attributes related to the SOAP encoding scheme, this method actually
sets the URN to be specified as the encoding scheme for the message.
The default is to specify the encoding for SOAP 1.1, so this is
handy for applications that need to encode according to SOAP 1.2
rules.
typelookup
$client->typelookup;
This method is a shortcut for:
$client->serializer->typelookup;
call(arguments)
$client->call($method => @arguments);
As has been illustrated in previous chapters, the "SOAP::Lite"
client objects can manage remote calls with auto-dispatching using
some of Perl's more elaborate features. call is used when the
application wants a greater degree of control over the details of
the call itself. The method may be built up from a SOAP::Data
object, so as to allow full control over the namespace associated
with the tag, as well as other attributes like encoding. This is
also important for calling methods that contain characters not
allowable in Perl function names, such as A.B.C.
The next four methods used in the "SOAP::Lite" class are geared towards
handling the types of events than can occur during the message
lifecycle. Each of these sets up a callback for the event in question:
on_action(callback)
$client->on_action(sub { qq("$_[0]") });
We will use "Martin Kutter" as the name for the call, so all variants
will print the following message on success:
Hello Martin Kutter!
SOAP message styles
There are three common (and one less common) variants of SOAP messages.
These address the message style (positional parameters vs. specified
message documents) and encoding (as-is vs. typed).
The different message styles are:
* rpc/encoded
Typed, positional parameters. Widely used in scripting languages.
The type of the arguments is included in the message. Arrays and the
like may be encoded using SOAP encoding rules (or others).
* rpc/literal
As-is, positional parameters. The type of arguments is defined by
some pre-exchanged interface definition.
* document/encoded
Specified message with typed elements. Rarely used.
</operation>
</portType>
<binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<operation name="sayHello">
<soap:operation soapAction="urn:HelloWorld#sayHello"/>
<input>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="HelloWorld">
<port name="HelloWorldSoap" binding="s0:Service1Soap">
<soap:address location="http://localhost:81/soap-wsdl-test/helloworld.pl" />
</port>
</service>
</definitions>
my $soap = SOAP::Lite->new( proxy => 'http://localhost:81/soap-wsdl-test/helloworld.pl');
$soap->default_ns('urn:HelloWorld');
my $som = $soap->call('sayHello',
SOAP::Data->name('name')->value('Kutter'),
SOAP::Data->name('givenName')->value('Martin')
);
die $som->faultstring if ($som->fault);
print $som->result, "\n";
RPC/LITERAL
SOAP web services using the document/literal message encoding are
usually described by some Web Service Definition. Our web service has
the following WSDL description:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HelloWorld"
targetNamespace="urn:HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:HelloWorld">
\SOAP::Data->value([
SOAP::Data->name('name')->value( 'Kutter' ),
SOAP::Data->name('givenName')->value('Martin'),
]))
);
die $som->fault->{ faultstring } if ($som->fault);
print $som->result, "\n";
DOCUMENT/LITERAL
SOAP web services using the document/literal message encoding are
usually described by some Web Service Definition. Our web service has
the following WSDL description:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HelloWorld"
targetNamespace="urn:HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:HelloWorld">
INTEROPERABILITY
Microsoft .NET client with SOAP::Lite Server
In order to use a .NET client with a SOAP::Lite server, be sure you use
fully qualified names for your return values. For example:
return SOAP::Data->name('myname')
->type('string')
->uri($MY_NAMESPACE)
->value($output);
In addition see comment about default encoding in .NET Web Services
below.
SOAP::Lite client with a .NET server
If experiencing problems when using a SOAP::Lite client to call a .NET
Web service, it is recommended you check, or adhere to all of the
following recommendations:
Declare a proper soapAction in your call
For example, use "on_action( sub {
'http://www.myuri.com/WebService.aspx#someMethod'; } )".
<SOAP-ENV:Envelope ...attributes skipped>
<SOAP-ENV:Body>
<mymethod xmlns="urn:MyURI" />
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Modify your .NET server, if possible
Stefan Pharies <stefanph@microsoft.com>:
SOAP::Lite uses the SOAP encoding (section 5 of the soap 1.1 spec),
and the default for .NET Web Services is to use a literal encoding.
So elements in the request are unqualified, but your service expects
them to be qualified. .Net Web Services has a way for you to change
the expected message format, which should allow you to get your
interop working. At the top of your class in the asmx, add this
attribute (for Beta 1):
[SoapService(Style=SoapServiceStyle.RPC)]
Another source said it might be this attribute (for Beta 2):
which are encoded as base64Binary, don't have this problem and
difference in processing time can be significant. For XML encoded
string that has about 20 lines and 30 tags, number of call could be
about 100 instead of one for the same string encoded as
base64Binary.
Since it is parser's feature there is NO fix for this behavior (let
me know if you find one), especially because you need to parse
message you already got (and you cannot control content of this
message), however, if your are in charge for both ends of processing
you can switch encoding to base64 on sender's side. It will
definitely work with SOAP::Lite and it may work with other
toolkits/implementations also, but obviously I cannot guarantee
that.
If you want to encode specific string as base64, just do
"SOAP::Data->type(base64 => $string)" either on client or on server
side. If you want change behavior for specific instance of
SOAP::Lite, you may subclass "SOAP::Serializer", override
"as_string()" method that is responsible for string encoding (take a
look into "as_base64Binary()") and specify new serializer class for
your SOAP::Lite object with:
my $soap = new SOAP::Lite
serializer => My::Serializer->new,
..... other parameters
or on server side:
my $server = new SOAP::Transport::HTTP::Daemon # or any other server
ReleaseNotes.txt view on Meta::CPAN
NO ENTITY DECODING
SOAP::Lite uses XML::Parser::Lite which relies on Unicode support in Perl and
doesn't perform XML ENTITY decoding.
LIMITED SUPPORT FOR MUSTUNDERSTAND and ACTOR ATTRIBUTES
SOAP::Lite does not currently heed the soap:mustUnderstand XML attribute, or
SOAP actor attributes.
DOCUMENT-LITERAL SUPPORT
All literal encoding support for SOAP::Lite is marked EXPERIMENTAL, and it is
incomplete. Developers are encouraged to use this capability but should be
fore-warned.
As an alternative, SOAP::WSDL or XML::Compiled::SOAP may be used for
document/literal bindings derived from WSDL definitions.
CLIENT SIDE WSDL SUPPORT
SOAP::Lites ability to consume a WSDL and generate the necessary message based
on that WSDL is improving, but it does not work with complex types.
As an alternative, SOAP::WSDL or XML::Compiled::SOAP may be used for
document/literal bindings derived from WSDL definitions.
bin/SOAPsh.pl view on Meta::CPAN
perl SOAPsh.pl http://soap.4s4c.com/ssss4c/soap.asp http://simon.fell.com/calc doubler([10,20,30])
> Ctrl-D (Ctrl-Z on Windows)
=head1 DESCRIPTION
SOAPsh.pl is a shell for making SOAP calls. It takes two parameters:
mandatory endpoint and optional uri (actually it will tell you about it
if you try to run it). Additional commands can follow.
After that you'll be able to run any methods of SOAP::Lite, like autotype,
readable, encoding, etc. You can run it the same way as you do it in
your Perl script. You'll see output from method, result of SOAP call,
detailed info on SOAP faulure or transport error.
For full list of available methods see documentation for SOAP::Lite.
Along with methods of SOAP::Lite you'll be able (and that's much more
interesting) run any SOAP methods you know about on remote server and
see processed results. You can even switch on debugging (with call
something like: C<on_debug(sub{print@_})>) and see SOAP code with
headers sent and received.
examples/WSDL/say_hello_rpcenc.wsdl view on Meta::CPAN
<output message="s0:sayHelloResponse" />
</operation>
</portType>
<binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<operation name="sayHello">
<soap:operation soapAction="urn:HelloWorld#sayHello"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="HelloWorld">
<port name="HelloWorldSoap" binding="s0:Service1Soap">
<soap:address location="http://localhost:80/soap-wsdl-test/helloworld.pl" />
</port>
</service>
</definitions>
examples/XML/customxml.pl view on Meta::CPAN
-> valueof('/Envelope/Body');
foreach my $portfolio ($d->Report->Request->Composition->PortfolioDistribution) {
print $portfolio->type, " ", $portfolio->date, "\n";
foreach my $row ($portfolio->Row) {
print " ", $row->Element, " ", $row->Value, "\n";
}
}
__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<Envelope version="1.1">
<Header />
<Body>
<Report>
<Header>
<ClientRef />
<FundCusip>61744J366</FundCusip>
<SepAcctDesc />
</Header>
<Request>
examples/customschema.pl view on Meta::CPAN
sub as_TickDirection { $_[1] }
sub as_Exchanges { $_[1] }
package main;
use SOAP::Lite;
$d = SOAP::Deserializer->new;
$d->xmlschemas->{'http://marketdata.earthconnect.net/encodedTypes'} = 'EncodedTypes';
$r = $d->deserialize(q!<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://marketdata.earthconnect.net/"
xmlns:types="http://marketdata.earthconnect.net/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:GetProfessionalQuoteResponse>
<GetProfessionalQuoteResult href="#id1" />
</tns:GetProfessionalQuoteResponse>
<soapenc:Array id="id1" soapenc:arrayType="types:ProfessionalQuote[1]">
<Item href="#id2" />
</soapenc:Array>
<types:ProfessionalQuote id="id2" xsi:type="types:ProfessionalQuote">
<CompanyName xsi:type="xsd:string">EarthConnect Corporation</CompanyName>
examples/forms/style.html view on Meta::CPAN
<html>
<head><title>SOAP::Lite POST Examples</title></head>
<body>
<h1>SOAP::Lite Examples</h1>
<hr>
<form action="http://services.soaplite.com/style.cgi" method="POST" enctype="multipart/form-data">
<input type="hidden" name="payload" value='<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3...
<input name="echo" value="37.5">
<input type="submit">
</form>
</html>
examples/oo-apache.pl view on Meta::CPAN
# connect to service that described by Graham Glass:
# http://www-106.ibm.com/developerworks/library/ws-peer3/?dwzone=ws
# ---------------------------------------------------------------------
use SOAP::Lite;
my $invoice = bless {name => 'My invoice', amount => 41} => 'Invoice';
my $soap = SOAP::Lite
-> proxy('http://localhost:8080/soap/servlet/rpcrouter')
-> maptype({Invoice => 'urn:my_encoding'})
-> uri('urn:demo2:purchasing');
$a = $soap->receive($invoice)->result;
print 'type: ', ref $a, "\n";
print ' name: ', $a->{name}, "\n";
print ' amount: ', $a->{amount}, "\n";
lib/SOAP/Constants.pm view on Meta::CPAN
our $VERSION = '1.27'; # VERSION
use constant URI_1999_SCHEMA_XSD => "http://www.w3.org/1999/XMLSchema";
use constant URI_1999_SCHEMA_XSI => "http://www.w3.org/1999/XMLSchema-instance";
use constant URI_2000_SCHEMA_XSD => "http://www.w3.org/2000/10/XMLSchema";
use constant URI_2000_SCHEMA_XSI => "http://www.w3.org/2000/10/XMLSchema-instance";
use constant URI_2001_SCHEMA_XSD => "http://www.w3.org/2001/XMLSchema";
use constant URI_2001_SCHEMA_XSI => "http://www.w3.org/2001/XMLSchema-instance";
use constant URI_LITERAL_ENC => "";
use constant URI_SOAP11_ENC => "http://schemas.xmlsoap.org/soap/encoding/";
use constant URI_SOAP11_ENV => "http://schemas.xmlsoap.org/soap/envelope/";
use constant URI_SOAP11_NEXT_ACTOR => "http://schemas.xmlsoap.org/soap/actor/next";
use constant URI_SOAP12_ENC => "http://www.w3.org/2003/05/soap-encoding";
use constant URI_SOAP12_ENV => "http://www.w3.org/2003/05/soap-envelope";
use constant URI_SOAP12_NOENC => "http://www.w3.org/2003/05/soap-envelope/encoding/none";
use constant URI_SOAP12_NEXT_ACTOR => "http://www.w3.org/2003/05/soap-envelope/role/next";
use vars qw($NSMASK $ELMASK);
$NSMASK = '[a-zA-Z_:][\w.\-:]*';
$ELMASK = '^(?![xX][mM][lL])[a-zA-Z_][\w.\-]*$';
use vars qw($NEXT_ACTOR $NS_ENV $NS_ENC $NS_APS
$FAULT_CLIENT $FAULT_SERVER $FAULT_VERSION_MISMATCH
$HTTP_ON_FAULT_CODE $HTTP_ON_SUCCESS_CODE $FAULT_MUST_UNDERSTAND
lib/SOAP/Constants.pm view on Meta::CPAN
A number of "constant" values are provided by means of this namespace. The values aren't constants in the strictest sense; the purpose of the values detailed here is to allow the application to change them if it desires to alter the specific behavior...
=head1 CONSTANTS
=head2 $DO_NOT_USE_XML_PARSER
The SOAP::Lite package attempts to locate and use the L<XML::Parser> package, falling back on an internal, pure-Perl parser in its absence. This package is a fast parser, based on the Expat parser developed by James Clark. If the application sets thi...
=head2 $DO_NOT_USE_CHARSET
Unless this parameter is set to 1, outgoing Content-Type headers will include specification of the character set used in encoding the message itself. Not all endpoints (client or server) may be able to properly deal with that data on the content head...
=head2 $DO_NOT_CHECK_CONTENT_TYPE
The content-type itself for a SOAP message is rather clearly defined, and in most cases, an application would have no reason to disable the testing of that header. This having been said, the content-type for SOAP 1.2 is still only a recommended draft...
=head2 $PATCH_HTTP_KEEPALIVE
SOAP::Lite's HTTP Transport module attempts to provide a simple patch to
LWP::Protocol to enable HTTP Keep Alive. By default, this patch is turned
off, if however you would like to turn on the experimental patch change the
lib/SOAP/Data.pod view on Meta::CPAN
$obj->actor($new_actor_name);
Gets or sets the value of the actor attribute; useful only when the object generates an entity for the message header.
=item mustUnderstand(boolean, optional value)
$obj->mustUnderstand(0);
Manipulates the mustUnderstand attribute, which tells the SOAP processor whether it is required to understand the entity in question.
=item encodingStyle(new encoding URN, optional value)
$obj->encodingStyle($soap_11_encoding);
This method is most likely to be used in places outside the header creation. Sets encodingStyle, which specifies an encoding that differs from the one that would otherwise be defaulted to.
=item root(boolean, optional value)
$obj->root(1);
When the application must explicitly specify which data element is to be regarded as the root element for the sake of generating the object model, this method provides the access to the root attribute.
=back
=head1 TYPE DETECTION
lib/SOAP/Data.pod view on Meta::CPAN
SOAP::Data->name("someArrayItem" => @array)
->type("SomeObject"))
)->type("ArrayOf_SomeObject") ))
->type("SomeObject");
$response = $client->someMethod($temp_elements);
Will produce the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:namesp2="http://namespaces.soaplite.com/perl"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp1:someMethod xmlns:namesp1="urn:TemperatureService">
<CallDetails xsi:type="namesp2:SomeObject">
<elem1 xsi:type="xsd:string">foo</elem1>
<elem2 xsi:type="xsd:string">baz</elem2>
<someArray xsi:type="namesp2:ArrayOf_SomeObject">
<item xsi:type="namesp2:SomeObject">123</bar>
<item xsi:type="namesp2:SomeObject">456</bar>
</someArray>
</CallDetails>
lib/SOAP/Lite.pm view on Meta::CPAN
$self->{_attr}->{$attr} = $self->{$field} = shift() ? 1 : 0;
$self->value(@_) if @_;
return $self;
}
$self->{$field} = SOAP::Lite::Deserializer::XMLSchemaSOAP1_2->as_boolean($self->{_attr}->{$attr})
if !defined $self->{$field} && defined $self->{_attr}->{$attr};
return $self->{$field};
}
}
for my $method (qw(actor encodingStyle)) {
my $field = '_' . $method;
*$method = sub {
my $attr = "{$SOAP::Constants::NS_ENV}$method";
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new()
: __PACKAGE__->new();
if (@_) {
$self->{_attr}->{$attr} = $self->{$field} = shift;
$self->value(@_) if @_;
return $self;
lib/SOAP/Lite.pm view on Meta::CPAN
my $prefix = 'c-';
sub gen_ns { 'namesp' . ++$ns }
sub gen_name { join '', $prefix, 'gensym', ++$name }
sub prefix { $prefix =~ s/^[^\-]+-/$_[1]-/; $_[0]; }
}
sub BEGIN {
no strict 'refs';
__PACKAGE__->__mk_accessors(qw(readable level seen autotype attr maptype
namespaces multirefinplace encoding signature on_nonserialized context
ns_uri ns_prefix use_default_ns));
for my $method (qw(method fault freeform)) { # aliases for envelope
*$method = sub { shift->envelope($method => @_) }
}
# Is this necessary? Seems like work for nothing when a user could just use
# SOAP::Utils directly.
# for my $method (qw(qualify overqualify disqualify)) { # import from SOAP::Utils
# *$method = \&{'SOAP::Utils::'.$method};
lib/SOAP/Lite.pm view on Meta::CPAN
my $class = $self;
$self = bless {
_level => 0,
_autotype => 1,
_readable => 0,
_ns_uri => '',
_ns_prefix => '',
_use_default_ns => 1,
_multirefinplace => 0,
_seen => {},
_encoding => 'UTF-8',
_objectstack => {},
_signature => [],
_maptype => {},
_bodyattr => {},
_headerattr => {},
_on_nonserialized => sub {Carp::carp "Cannot marshall @{[ref shift]} reference" if $^W; return},
_encodingStyle => $SOAP::Constants::NS_ENC,
_attr => {
"{$SOAP::Constants::NS_ENV}encodingStyle" => $SOAP::Constants::NS_ENC,
},
_namespaces => {},
_soapversion => SOAP::Lite->soapversion,
} => $class;
$self->typelookup({
'base64Binary' =>
[10, sub { $_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/ }, 'as_base64Binary'],
'zerostring' =>
[12, sub { $_[0] =~ /^0\d+$/ }, 'as_string'],
# int (and actually long too) are subtle: the negative range is one greater...
lib/SOAP/Lite.pm view on Meta::CPAN
else {
$self->ns($ns);
}
# $self->{'_ns_uri'} = $ns;
# $self->register_ns($self->{'_ns_uri'}) if (!$self->{_use_default_ns});
return $self;
}
return $self->{'_ns_uri'};
}
sub encodingStyle {
my $self = shift;
$self = $self->new() if not ref $self;
return $self->{'_encodingStyle'} unless @_;
my $cur_style = $self->{'_encodingStyle'};
delete($self->{'_namespaces'}->{$cur_style});
my $new_style = shift;
if ($new_style eq "") {
delete($self->{'_attr'}->{"{$SOAP::Constants::NS_ENV}encodingStyle"});
}
else {
$self->{'_attr'}->{"{$SOAP::Constants::NS_ENV}encodingStyle"} = $new_style;
$self->{'_namespaces'}->{$new_style} = $SOAP::Constants::PREFIX_ENC;
}
}
# TODO - changing SOAP version can affect previously set encodingStyle
sub soapversion {
my $self = shift;
return $self->{_soapversion} unless @_;
return $self if $self->{_soapversion} eq SOAP::Lite->soapversion;
$self->{_soapversion} = shift;
$self->attr({
"{$SOAP::Constants::NS_ENV}encodingStyle" => $SOAP::Constants::NS_ENC,
});
$self->namespaces({
$SOAP::Constants::NS_ENC => $SOAP::Constants::PREFIX_ENC,
$SOAP::Constants::PREFIX_ENV ? ($SOAP::Constants::NS_ENV => $SOAP::Constants::PREFIX_ENV) : (),
});
$self->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA);
return $self;
}
lib/SOAP/Lite.pm view on Meta::CPAN
return $encoded if ref $encoded;
# return only if handled, otherwise handle with default handlers
}
}
if (UNIVERSAL::isa($object => 'REF') || UNIVERSAL::isa($object => 'SCALAR')) {
return $self->encode_scalar($object, $name, $type, $attr);
}
elsif (UNIVERSAL::isa($object => 'ARRAY')) {
# Added in SOAP::Lite 0.65_6 to fix an XMLRPC bug
return $self->encodingStyle eq ""
|| $self->isa('XMLRPC::Serializer')
? $self->encode_array($object, $name, $type, $attr)
: $self->encode_literal_array($object, $name, $type, $attr);
}
elsif (UNIVERSAL::isa($object => 'HASH')) {
return $self->encode_hash($object, $name, $type, $attr);
}
else {
return $self->on_nonserialized->($object);
}
lib/SOAP/Lite.pm view on Meta::CPAN
if $tag !~ /^(?![Xx][Mm][Ll])/;
my $prolog = $readable ? "\n" : "";
my $epilog = $readable ? "\n" : "";
my $tagjoiner = " ";
if ($self->{ _level } == 1) {
my $namespaces = $self->namespaces;
foreach (keys %$namespaces) {
$attrs->{SOAP::Utils::qualify(xmlns => $namespaces->{$_})} = $_
}
$prolog = qq!<?xml version="1.0" encoding="@{[$self->encoding]}"?>!
if defined $self->encoding;
$prolog .= "\n" if $readable;
$tagjoiner = " \n".(' ' x 4 ) if $readable;
}
my $tagattrs = join($tagjoiner, '',
map { sprintf '%s="%s"', $_, SOAP::Utils::encode_attribute($attrs->{$_}) }
grep { $_ && defined $attrs->{$_} && ($_ ne 'xsi:type' || $attrs->{$_} ne '') }
sort keys %$attrs);
if ($value gt '') {
return sprintf("$prolog$indent<%s%s>%s%s</%s>$epilog",$tag,$tagattrs,$value,($value =~ /^\s*</ ? $indent : ""),$tag);
lib/SOAP/Lite.pm view on Meta::CPAN
? SOAP::Data->name(SOAP::Utils::qualify($self->envprefix => 'Body') => \$body)
: SOAP::Data->name(SOAP::Utils::qualify($self->envprefix => 'Body'))
)->attr( $self->bodyattr),
)
)->attr($self->attr)
);
$self->signature($parameters->signature) if ref $parameters;
# IMHO multirefs should be encoded after Body, but only some
# toolkits understand this encoding, so we'll keep them for now (04/15/2001)
# as the last element inside the Body
# v -------------- subelements of Envelope
# vv -------- last of them (Body)
# v --- subelements
push(@{$encoded->[2]->[-1]->[2]}, $self->encode_multirefs) if ref $encoded->[2]->[-1]->[2];
# Sometimes SOAP::Serializer is invoked statically when there is no context.
# So first check to see if a context exists.
# TODO - a context needs to be initialized by a constructor?
if ($self->context && $self->context->packager->parts) {
lib/SOAP/Lite.pm view on Meta::CPAN
my $self = shift;
my($name, $attrs, $children, $value) = @{ $_[0] };
# check SOAP version if applicable
use vars '$level'; local $level = $level || 0;
if (++$level == 1) {
my($namespace, $envelope) = SOAP::Utils::splitlongname($name);
SOAP::Lite->soapversion($namespace) if $envelope eq 'Envelope' && $namespace;
}
if (exists $attrs->{"{$SOAP::Constants::NS_ENV}encodingStyle"}) {
# check encodingStyle
# future versions may bind deserializer to encodingStyle
my $encodingStyle = $attrs->{"{$SOAP::Constants::NS_ENV}encodingStyle"};
# TODO - SOAP 1.2 and 1.1 have different rules about valid encodingStyle values
# For example, in 1.1 - any http://schemas.xmlsoap.org/soap/encoding/*
# value is valid
if (defined $encodingStyle && length($encodingStyle)) {
my %styles = map { $_ => undef } @SOAP::Constants::SUPPORTED_ENCODING_STYLES;
my $found = 0;
foreach my $e (split(/ +/,$encodingStyle)) {
if (exists $styles{$e}) {
$found ++;
}
}
die "Unrecognized/unsupported value of encodingStyle attribute '$encodingStyle'"
if (! $found) && !(SOAP::Lite->soapversion == 1.1 && $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/);
}
}
use vars '$arraytype'; # type of Array element specified on Array itself
# either specified with xsi:type, or <enc:name/> or array element
my ($type) = grep { defined }
map($attrs->{$_}, sort grep {/^\{$SOAP::Constants::NS_XSI_ALL\}type$/o} keys %$attrs),
$name =~ /^\{$SOAP::Constants::NS_ENC\}/ ? $name : $arraytype;
local $arraytype; # it's used only for one level, we don't need it anymore
# $name is not used here since type should be encoded as type, not as name
lib/SOAP/Lite.pm view on Meta::CPAN
# is this a SOAP binding?
next unless grep { $_->uri eq 'http://schemas.xmlsoap.org/wsdl/soap/' } $_->binding;
next unless $_->name eq $binding;
my $default_style = $_->binding->style;
my $porttype = SOAP::Utils::disqualify($_->type);
foreach ($_->operation) {
my $opername = $_->name;
$services{$opername} = {}; # should be initialized in 5.7 and after
my $soapaction = $_->operation->soapAction;
my $invocationStyle = $_->operation->style || $default_style || "rpc";
my $encodingStyle = $_->input->body->use || "encoded";
my $namespace = $_->input->body->namespace || $tns;
my @parts;
foreach ($s->portType) {
next unless $_->name eq $porttype;
foreach ($_->operation) {
next unless $_->name eq $opername;
my $inputmessage = SOAP::Utils::disqualify($_->input->message);
foreach my $msg ($s->message) {
next unless $msg->name eq $inputmessage;
if ($invocationStyle eq "document" && $encodingStyle eq "literal") {
# warn "document/literal support is EXPERIMENTAL in SOAP::Lite"
# if !$has_warned && ($has_warned = 1);
my ($input_ns,$input_name) = SOAP::Utils::splitqname($msg->part->element);
if ($input_name) {
foreach my $schema ($s->types->schema) {
foreach my $element ($schema->element) {
next unless $element->name eq $input_name;
push @parts,parse_schema_element($element);
}
$services{$opername}->{parameters} = [ @parts ];
}
}
}
else {
# TODO - support all combinations of doc|rpc/lit|enc.
#warn "$invocationStyle/$encodingStyle is not supported in this version of SOAP::Lite";
@parts = $msg->part;
$services{$opername}->{parameters} = [ @parts ];
}
}
}
for ($services{$opername}) {
$_->{endpoint} = $endpoint;
$_->{soapaction} = $soapaction;
$_->{namespace} = $namespace;
lib/SOAP/Lite.pm view on Meta::CPAN
# TODO - deprecate proxy() in favor of new language endpoint_url()
no strict qw(refs);
for my $method (qw(proxy)) {
*$method = sub {
my $self = shift->new;
@_ ? ($self->transport->$method(@_), return $self) : return $self->transport->$method();
}
}
# SOAP::Seriailizer Shortcuts
for my $method (qw(autotype readable envprefix encodingStyle
bodyattr headerattr
encprefix multirefinplace encoding
typelookup header maptype xmlschema
uri ns_prefix ns_uri use_prefix use_default_ns
ns default_ns)) {
*$method = sub {
my $self = shift->new;
@_ ? ($self->serializer->$method(@_), return $self) : return $self->serializer->$method();
}
}
# SOAP::Schema Shortcuts
lib/SOAP/Lite.pm view on Meta::CPAN
my $serializer = $self->serializer;
$serializer->on_nonserialized($self->on_nonserialized);
my $response = $self->transport->send_receive(
context => $self, # this is provided for context
endpoint => $self->endpoint,
action => scalar($self->on_action->($serializer->uriformethod($_[0]))),
# leave only parameters so we can later update them if required
envelope => $serializer->envelope(method => shift, @_),
encoding => $serializer->encoding,
parts => @{$self->packager->parts} ? $self->packager->parts : undef,
);
return $response if $self->outputxml;
my $result = eval { $self->deserializer->deserialize($response) }
if $response;
if (!$self->transport->is_success || # transport fault
$@ || # not deserializible
lib/SOAP/Lite.pm view on Meta::CPAN
explicitly to denote different versions of SOAP or the like.
=item encprefix(QName)
$client->encprefix('enc');
This method is a shortcut for:
$client->serializer->encprefix(QName);
Gets or sets the namespace prefix for the encoding rules namespace.
The default value is SOAP-ENC.
=back
While it may seem to be an unnecessary operation to set a value that isn't
relevant to the message, such as the namespace labels for the envelope and
encoding URNs, the ability to set these labels explicitly can prove to be a
great aid in distinguishing and debugging messages on the server side of
operations.
=over
=item encoding(encoding URN)
$client->encoding($soap_12_encoding_URN);
This method is a shortcut for:
$client->serializer->encoding(args);
Where the earlier method dealt with the label used for the attributes related
to the SOAP encoding scheme, this method actually sets the URN to be specified
as the encoding scheme for the message. The default is to specify the encoding
for SOAP 1.1, so this is handy for applications that need to encode according
to SOAP 1.2 rules.
=item typelookup
$client->typelookup;
This method is a shortcut for:
$client->serializer->typelookup;
lib/SOAP/Lite.pm view on Meta::CPAN
=item call(arguments)
$client->call($method => @arguments);
As has been illustrated in previous chapters, the C<SOAP::Lite> client objects
can manage remote calls with auto-dispatching using some of Perl's more
elaborate features. call is used when the application wants a greater degree
of control over the details of the call itself. The method may be built up
from a L<SOAP::Data> object, so as to allow full control over the namespace
associated with the tag, as well as other attributes like encoding. This is
also important for calling methods that contain characters not allowable in
Perl function names, such as A.B.C.
=back
The next four methods used in the C<SOAP::Lite> class are geared towards
handling the types of events than can occur during the message lifecycle. Each
of these sets up a callback for the event in question:
=over
lib/SOAP/Lite.pm view on Meta::CPAN
We will use "Martin Kutter" as the name for the call, so all variants will
print the following message on success:
Hello Martin Kutter!
=head2 SOAP message styles
There are three common (and one less common) variants of SOAP messages.
These address the message style (positional parameters vs. specified message
documents) and encoding (as-is vs. typed).
The different message styles are:
=over
=item * rpc/encoded
Typed, positional parameters. Widely used in scripting languages.
The type of the arguments is included in the message.
Arrays and the like may be encoded using SOAP encoding rules (or others).
=item * rpc/literal
As-is, positional parameters. The type of arguments is defined by some
pre-exchanged interface definition.
=item * document/encoded
Specified message with typed elements. Rarely used.
lib/SOAP/Lite.pm view on Meta::CPAN
</operation>
</portType>
<binding name="Service1Soap" type="s0:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc" />
<operation name="sayHello">
<soap:operation soapAction="urn:HelloWorld#sayHello"/>
<input>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="HelloWorld">
<port name="HelloWorldSoap" binding="s0:Service1Soap">
<soap:address location="http://localhost:81/soap-wsdl-test/helloworld.pl" />
</port>
</service>
</definitions>
lib/SOAP/Lite.pm view on Meta::CPAN
$soap->default_ns('urn:HelloWorld');
my $som = $soap->call('sayHello',
SOAP::Data->name('name')->value('Kutter'),
SOAP::Data->name('givenName')->value('Martin')
);
die $som->faultstring if ($som->fault);
print $som->result, "\n";
=head3 RPC/LITERAL
SOAP web services using the document/literal message encoding are usually
described by some Web Service Definition. Our web service has the following
WSDL description:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HelloWorld"
targetNamespace="urn:HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:HelloWorld">
lib/SOAP/Lite.pm view on Meta::CPAN
SOAP::Data->name('name')->value( 'Kutter' ),
SOAP::Data->name('givenName')->value('Martin'),
]))
);
die $som->fault->{ faultstring } if ($som->fault);
print $som->result, "\n";
=head3 DOCUMENT/LITERAL
SOAP web services using the document/literal message encoding are usually
described by some Web Service Definition. Our web service has the following
WSDL description:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="urn:HelloWorld"
targetNamespace="urn:HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema targetNamespace="urn:HelloWorld">
lib/SOAP/Lite.pm view on Meta::CPAN
=head2 Microsoft .NET client with SOAP::Lite Server
In order to use a .NET client with a SOAP::Lite server, be sure you use fully
qualified names for your return values. For example:
return SOAP::Data->name('myname')
->type('string')
->uri($MY_NAMESPACE)
->value($output);
In addition see comment about default encoding in .NET Web Services below.
=head2 SOAP::Lite client with a .NET server
If experiencing problems when using a SOAP::Lite client to call a .NET Web
service, it is recommended you check, or adhere to all of the following
recommendations:
=over 4
=item Declare a proper soapAction in your call
lib/SOAP/Lite.pm view on Meta::CPAN
<SOAP-ENV:Envelope ...attributes skipped>
<SOAP-ENV:Body>
<mymethod xmlns="urn:MyURI" />
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
=item Modify your .NET server, if possible
Stefan Pharies <stefanph@microsoft.com>:
SOAP::Lite uses the SOAP encoding (section 5 of the soap 1.1 spec), and
the default for .NET Web Services is to use a literal encoding. So
elements in the request are unqualified, but your service expects them to
be qualified. .Net Web Services has a way for you to change the expected
message format, which should allow you to get your interop working.
At the top of your class in the asmx, add this attribute (for Beta 1):
[SoapService(Style=SoapServiceStyle.RPC)]
Another source said it might be this attribute (for Beta 2):
[SoapRpcService]
lib/SOAP/Lite.pm view on Meta::CPAN
every processed entity or newline. It can lead to lot of calls and additional
memory manager expenses even for small messages. By contrast, XML messages
which are encoded as base64Binary, don't have this problem and difference in
processing time can be significant. For XML encoded string that has about 20
lines and 30 tags, number of call could be about 100 instead of one for
the same string encoded as base64Binary.
Since it is parser's feature there is NO fix for this behavior (let me know
if you find one), especially because you need to parse message you already
got (and you cannot control content of this message), however, if your are
in charge for both ends of processing you can switch encoding to base64 on
sender's side. It will definitely work with SOAP::Lite and it B<may> work with
other toolkits/implementations also, but obviously I cannot guarantee that.
If you want to encode specific string as base64, just do
C<< SOAP::Data->type(base64 => $string) >> either on client or on server
side. If you want change behavior for specific instance of SOAP::Lite, you
may subclass C<SOAP::Serializer>, override C<as_string()> method that is
responsible for string encoding (take a look into C<as_base64Binary()>) and
specify B<new> serializer class for your SOAP::Lite object with:
my $soap = new SOAP::Lite
serializer => My::Serializer->new,
..... other parameters
or on server side:
my $server = new SOAP::Transport::HTTP::Daemon # or any other server
serializer => My::Serializer->new,
lib/SOAP/Lite/Packager.pm view on Meta::CPAN
# ======================================================================
package SOAP::Lite::Packager::MIME;
use strict;
use vars qw(@ISA);
@ISA = qw(SOAP::Lite::Packager);
sub BEGIN {
no strict 'refs';
for my $method ( qw(transfer_encoding env_id env_location) ) {
my $field = '_' . $method;
*$method = sub {
my $self = shift;
if (@_) {
$self->{$field} = shift;
return $self
}
return $self->{$field};
}
}
}
sub new {
my ($classname) = @_;
my $self = SOAP::Lite::Packager::new(@_);
$self->{'_content_encoding'} = '8bit';
$self->{'_env_id'} = '<main_envelope>';
$self->{'_env_location'} = '/main_envelope';
bless $self, $classname;
$SOAP::Lite::Packager::SUPPORTED_TYPES->{"MIME::Entity"} = 1;
return $self;
}
sub initialize_parser {
my $self = shift;
eval "require MIME::Parser;";
lib/SOAP/Lite/Packager.pm view on Meta::CPAN
sub package {
my $self = shift;
my ($envelope,$context) = @_;
return $envelope if (!$self->parts); # if there are no parts,
# then there is nothing to do
require MIME::Entity;
local $MIME::Entity::BOUNDARY_DELIMITER = "\r\n";
my $top = MIME::Entity->build('Type' => "Multipart/Related");
my $soapversion = defined($context) ? $context->soapversion : '1.1';
$top->attach('Type' => $soapversion == 1.1 ? "text/xml" : "application/soap+xml",
'Content-Transfer-Encoding' => $self->transfer_encoding(),
'Content-Location' => $self->env_location(),
'Content-ID' => $self->env_id(),
'Data' => $envelope );
# consume the attachments that come in as input by 'shift'ing
no strict 'refs';
while (my $part = shift(@{$self->parts})) {
$top->add_part($part);
}
# determine MIME boundary
my $boundary = $top->head->multipart_boundary;
lib/SOAP/Lite/Packager.pm view on Meta::CPAN
C<SOAP::Lite::Packager::MIME> utilizes L<MIME::Tools> to provides the ability to send
and receive Multipart/Related and Multipart/Form-Data formatted requests and
responses.
=head3 MIME METHODS
The following methods are used when composing a MIME formatted message.
=over
=item transfer_encoding
The value of the root part's Content-Transfer-Encoding MIME Header. Default is: 8bit.
=item env_id
The value of the root part's Content-Id MIME Header. Default is: <main_envelope>.
=item env_location
The value of the root part's Content-Location MIME Header. Default is: /main_envelope.
lib/SOAP/Packager.pm view on Meta::CPAN
# ======================================================================
package SOAP::Packager::MIME;
use strict;
use vars qw(@ISA);
@ISA = qw(SOAP::Packager);
sub BEGIN {
no strict 'refs';
for my $method ( qw(transfer_encoding env_id env_location) ) {
my $field = '_' . $method;
*$method = sub {
my $self = shift;
if (@_) { $self->{$field} = shift; return $self }
return $self->{$field};
}
}
}
sub new {
my ($classname) = @_;
my $self = SOAP::Packager::new(@_);
$self->{'_content_encoding'} = '8bit';
$self->{'_env_id'} = '<main_envelope>';
$self->{'_env_location'} = '/main_envelope';
bless $self, $classname;
$SOAP::Packager::SUPPORTED_TYPES->{"MIME::Entity"} = 1;
return $self;
}
sub initialize_parser {
my $self = shift;
eval "require MIME::Parser;";
lib/SOAP/Packager.pm view on Meta::CPAN
sub package {
my $self = shift;
my ($envelope,$context) = @_;
return $envelope if (!$self->parts); # if there are no parts,
# then there is nothing to do
require MIME::Entity;
local $MIME::Entity::BOUNDARY_DELIMITER = "\r\n";
my $top = MIME::Entity->build('Type' => "Multipart/Related");
my $soapversion = defined($context) ? $context->soapversion : '1.1';
$top->attach('Type' => $soapversion == 1.1 ? "text/xml" : "application/soap+xml",
'Content-Transfer-Encoding' => $self->transfer_encoding(),
'Content-Location' => $self->env_location(),
'Content-ID' => $self->env_id(),
'Data' => $envelope );
# consume the attachments that come in as input by 'shift'ing
no strict 'refs';
while (my $part = shift(@{$self->parts})) {
$top->add_part($part);
}
# determine MIME boundary
my $boundary = $top->head->multipart_boundary;
lib/SOAP/Packager.pm view on Meta::CPAN
C<SOAP::Packager::MIME> utilizes L<MIME::Tools> to provides the ability to send
and receive Multipart/Related and Multipart/Form-Data formatted requests and
responses.
=head3 MIME METHODS
The following methods are used when composing a MIME formatted message.
=over
=item transfer_encoding
The value of the root part's Content-Transfer-Encoding MIME Header. Default is: 8bit.
=item env_id
The value of the root part's Content-Id MIME Header. Default is: <main_envelope>.
=item env_location
The value of the root part's Content-Location MIME Header. Default is: /main_envelope.
lib/SOAP/SOM.pod view on Meta::CPAN
=item valueof(node)
$res = $som->valueof('[1]');
When the SOAP::SOM object has matched a path internally with the match method, this method allows retrieval of the data within any of the matched nodes. The data comes back as native Perl data, not a class instance (see dataof). In a scalar context, ...
=item dataof(node)
$resobj = $som->dataof('[1]');
Performs the same operation as the earlier valueof method, except that the data is left in its L<SOAP::Data> form, rather than being deserialized. This allows full access to all the attributes that were serialized along with the data, such as namespa...
=item headerof(node)
$resobj = $som->headerof('[1]');
Acts much like dataof, except that it returns an object of the L<SOAP::Header> class (covered later in this chapter), rather than SOAP::Data. This is the preferred interface for manipulating the header entities in a message.
=item namespaceuriof(node)
$ns = $som->namespaceof('[1]');
lib/SOAP/Serializer.pod view on Meta::CPAN
=item response
The message being created is that of a response stemming from a RPC-style method call.
=item fault
For this specifier, the envelope being created is to transmit a fault.
=item freeform
This identifier is used as a general-case encoding style for messages that
don't fit into any of the previous cases. The arguments are encoded into the
envelope's Body tag without any sort of context sensitivity.
=back
Any value other than these four results in an error.
=item envprefix(optional value)
$serialize->envprefix('env');
Gets or sets the prefix that labels the SOAP envelope namespace. This defaults to SOAP-ENV.
=item encprefix(optional value)
$serialize->envprefix('enc');
Gets or sets the prefix that labels the SOAP encoding namespace. Defaults to SOAP-ENC.
=item soapversion(optional value)
$serialize->soapversion('1.2');
If no parameter is given, returns the current version of SOAP that is being used as the basis for serializing messages. If a parameter is given, attempts to set that as the version of SOAP being used. The value should be either 1.1 or 1.2. When the S...
=item xmlschema(optional value)
$serialize->xmlschema($xml_schema_1999);
Gets or sets the URN for the schema being used to express the structure of the XML generated by the serializer. If setting the value, the input must be the full URN for the new schema and is checked against the list of known SOAP schemas.
=item register_ns
The register_ns subroutine allows users to register a global namespace
lib/SOAP/Serializer.pod view on Meta::CPAN
$foo = MyModule::MyPackage->new;
my $client = SOAP::Lite
->uri($NS)
->proxy($HOST);
$som = $client->someMethod($foo);
Then the second and third parameters will be the class name of the value/object being encoded (e.g. "MyModule::MyPackage" in the example above), and the fourth parameter will be an empty hash.
=item Output
The encoding subroutine must return an array containing three elements: 1) the name of the XML element, 2) a hash containing the attributes to be placed into the element, and 3) the value of the element.
=back
=head1 AUTOTYPING
When the type of an element has not been declared explicitly, SOAP::Lite must "guess" at the object's type. That is due to the fact that the only form of introspection that Perl provides (through the use of the C<ref> subroutine) does not provide eno...
To work around this limitation, the C<SOAP::Serializer::typelookup> hash was created. This hash is populated with all the data types that the current C<SOAP::Serializer> can auto detect. Users and developers are free to modify the contents of this ha...
When C<SOAP::Serializer> is asked to encode an object into XML, it goes through the following steps. First, C<SOAP::Serializer> checks to see if a type has been explicitly stated for the current object. If a type has been provided C<SOAP::Serializer>...
To do so, C<SOAP::Serializer> runs in sequence a set of tests stored in the C<SOAP::Serializer::typelookup> hash. C<SOAP::Serializer> continues to run each test until one of the tests returns true, indicating that the type of the object has been dete...
The following table contains the set of data types detectable by C<SOAP::Lite> by default and the order in which their corresponding test subroutine will be run, according to their precedence value.
Table 1 - Autotyping Precedence
TYPENAME PRECEDENCE VALUE
----------------------------
base64 10
int 20
long 25
lib/SOAP/Serializer.pod view on Meta::CPAN
The test subroutine will have passed to it by C<SOAP::Serializer> a value to be tested. The test subroutine must return 1 if the value passed to it is of the corresponding type, or else it must return 0.
sub SOAP::Serializer::uriReferenceTest {
my ($value) = @_;
return 1 if ($value =~ m!^http://!);
return 0;
}
B<Step 2: Write an Encoding Subroutine>
The encoding subroutine provides C<SOAP::Serializer> with the data necessary to encode the value passed to it into XML. The encoding subroutine name's should be of the following format: C<as_><Type Name>.
The encoding subroutine will have passed to it by C<SOAP::Serializer> four parameters: the value to be encoded, the name of the element being encoded, the assumed type of the element being encoded, and a reference to a hash containing the attributes ...
sub SOAP::Serializer::as_uriReference {
my $self = shift;
my($value, $name, $type, $attr) = @_;
return [$name, {'xsi:type' => 'xsd:uriReference', %$attr}, $value];
}
B<Step 3: Register the New Data Type>
To register the new data type, simply add the type to the C<SOAP::Serializer::typelookup> hash using the type name as the key, and an array containing the precedence value, the test subroutine, and the encoding subroutine.
$s->typelookup->{uriReference}
= [11, \&uriReferenceTest, 'as_uriReference'];
I<Tip: As a short hand, you could just as easily use an anonymous test subroutine when registering the new datatype in place of the C<urlReferenceTest> subroutine above. For example:>
$s->typelookup->{uriReference}
= [11, sub { $_[0] =~ m!^http://! }, 'as_uriReference'];
Once complete, C<SOAP::Serializer> will be able to serialize the following C<SOAP::Data> object into XML:
lib/SOAP/Server.pod view on Meta::CPAN
=item name
The name of the method to call.
=back
=item handle
$server->handle($request_text);
Implements the main functionality of the serving process, in which the server takes an incoming request and dispatches it to the correct server-side subroutine. The parameter taken as input is either plain XML or MIME-encoded content (if MIME-encodin...
=item make_fault
return $server->makefault($code, $message);
Creates a SOAP::Fault object from the data passed in. The order of arguments is: code, message, detail, actor. The first two are required (because they must be present in all faults), but the last two may be omitted unless needed.
=back
=head2 SOAP::Server::Parameters
lib/SOAP/Transport.pod view on Meta::CPAN
$client->send_recieve(%hash_table);
(Required for client classes only) When the SOAP::Lite objects attempt to send out requests, the means for doing so is to attempt to call this method on the object held within the SOAP::Transport object contained within the client itself. All clients...
=over
=item action
The URI specifying the action being performed, usually the result from the on_action hook on the client object.
=item encoding
The URI of the encoding scheme that governs the message being sent.
=item endpoint
The URI specifying the endpoint to which the message is being sent.
=item envelope
The XML content of the message to be sent. It is generally the return value of the envelope method from the L<SOAP::Serializer> object instance that the client object maintains.
=item parts
lib/SOAP/Transport.pod view on Meta::CPAN
Those who would like to use encrypted keys may find the following thread in the SOAP::Lite newsgroup helpful:
http://groups.yahoo.com/group/soaplite/message/729
=head3 COMPRESSION
SOAP::Lite provides you with the option for enabling compression over the wire using HTTP I<only> in both the server and client contexts, provided that you have L<Compress::Zlib> installed. Compression and decompression is done transparently to your ...
A server will respond with an encoded/compressed message only if the client has asserted that it can accept it (indicated by client sending an C<Accept-Encoding> HTTP header with a 'deflate' or '*' value).
C<SOAP::Lite> clients all have fallback logic implemented so that if a server doesn't understand the specified encoding (i.e. "Content-Encoding: deflate") and returns the proper HTTP status code (415 NOT ACCEPTABLE), the client will repeat the reques...
Compression is enabled on the client side by specifying the C<compress_threshold> option, and if the size of the current request exceeds that threshold.
B<Client Code Sample>
print SOAP::Lite
->uri('http://localhost/My/Parameters')
->proxy('http://localhost/', options => {compress_threshold => 10000})
->echo(1 x 10000)
->result;
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
SOAP::Trace::objects('()');
$self->setDebugLogger(\&SOAP::Trace::debug);
return $self;
}
sub send_receive {
my ( $self, %parameters ) = @_;
my ( $context, $envelope, $endpoint, $action, $encoding, $parts ) =
@parameters{qw(context envelope endpoint action encoding parts)};
$encoding ||= 'UTF-8';
$endpoint ||= $self->endpoint;
my $method = 'POST';
$COMPRESS = 'gzip';
$self->options->{is_compress} ||=
exists $self->options->{compress_threshold}
&& eval { require Compress::Zlib };
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
# TODO - DIME support
}
COMPRESS: {
my $compressed =
!exists $nocompress{$endpoint}
&& $self->options->{is_compress}
&& ( $self->options->{compress_threshold} || 0 ) < length $envelope;
my $original_encoding = $http_request->content_encoding;
while (1) {
# check cache for redirect
$endpoint = $redirect{$endpoint} if exists $redirect{$endpoint};
# check cache for M-POST
$method = 'M-POST' if exists $mpost{$endpoint};
# what's this all about?
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
# what to do? we calculate proper content-length (using
# bytelength() function from SOAP::Utils) and then drop utf8 mark
# from string (doing pack with 'C0A*' modifier) if length and
# bytelength are not the same
my $bytelength = SOAP::Utils::bytelength($envelope);
if ($] < 5.008) {
$envelope = pack( 'C0A*', $envelope );
}
else {
require Encode;
$envelope = Encode::encode($encoding, $envelope);
$bytelength = SOAP::Utils::bytelength($envelope);
}
# if !$SOAP::Constants::DO_NOT_USE_LWP_LENGTH_HACK
# && length($envelope) != $bytelength;
# compress after encoding
# doing it before breaks the compressed content (#74577)
$envelope = Compress::Zlib::memGzip($envelope) if $compressed;
$http_request->content($envelope);
$http_request->protocol('HTTP/1.1');
$http_request->proxy_authorization_basic( $ENV{'HTTP_proxy_user'},
$ENV{'HTTP_proxy_pass'} )
if ( $ENV{'HTTP_proxy_user'} && $ENV{'HTTP_proxy_pass'} );
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
if defined $action;
}
# $http_request->header(Expect => '100-Continue');
# allow compress if present and let server know we could handle it
$http_request->header( 'Accept-Encoding' =>
[$SOAP::Transport::HTTP::Client::COMPRESS] )
if $self->options->{is_compress};
$http_request->content_encoding(
$SOAP::Transport::HTTP::Client::COMPRESS)
if $compressed;
if ( !$http_request->content_type ) {
$http_request->content_type(
join '; ',
$SOAP::Constants::DEFAULT_HTTP_CONTENT_TYPE,
!$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding
? 'charset=' . lc($encoding)
: () );
}
elsif ( !$SOAP::Constants::DO_NOT_USE_CHARSET && $encoding ) {
my $tmpType = $http_request->headers->header('Content-type');
# $http_request->content_type($tmpType.'; charset=' . lc($encoding));
my $addition = '; charset=' . lc($encoding);
$http_request->content_type( $tmpType . $addition )
if ( $tmpType !~ /$addition/ );
}
$http_request->content_length($bytelength) unless $compressed;
SOAP::Trace::transport($http_request);
&{$self->{debug_logger}}($http_request->as_string);
$self->SUPER::env_proxy if $ENV{'HTTP_proxy'};
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
$self->code( $self->http_response->code );
$self->message( $self->http_response->message );
$self->is_success( $self->http_response->is_success );
$self->status( $self->http_response->status_line );
# Pull out any cookies from the response headers
$self->{'_cookie_jar'}->extract_cookies( $self->http_response )
if $self->{'_cookie_jar'};
my $content =
( $self->http_response->content_encoding || '' ) =~
/\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o
&& $self->options->{is_compress}
? Compress::Zlib::memGunzip( $self->http_response->content )
: ( $self->http_response->content_encoding || '' ) =~ /\S/ ? die
"Can't understand returned Content-Encoding (@{[$self->http_response->content_encoding]})\n"
: $self->http_response->content;
return $self->http_response->content_type =~ m!^multipart/!i
? join( "\n", $self->http_response->headers_as_string, $content )
: $content;
}
# ======================================================================
package SOAP::Transport::HTTP::Server;
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
if $self->request->header('Man') !~
/^"$SOAP::Constants::NS_ENV";\s*ns\s*=\s*(\d+)/;
$self->action( $self->request->header("$1-SOAPAction") || undef );
}
else {
return $self->response(
HTTP::Response->new(405) ) # METHOD NOT ALLOWED
}
my $compressed =
( $self->request->content_encoding || '' ) =~ /\b$COMPRESS\b/;
$self->options->{is_compress} ||=
$compressed && eval { require Compress::Zlib };
# signal error if content-encoding is 'deflate', but we don't want it OR
# something else, so we don't understand it
return $self->response(
HTTP::Response->new(415) ) # UNSUPPORTED MEDIA TYPE
if $compressed && !$self->options->{is_compress}
|| !$compressed
&& ( $self->request->content_encoding || '' ) =~ /\S/;
my $content_type = $self->request->content_type || '';
# in some environments (PerlEx?) content_type could be empty, so allow it also
# anyway it'll blow up inside ::Server::handle if something wrong with message
# TBD: but what to do with MIME encoded messages in THOSE environments?
return $self->make_fault( $SOAP::Constants::FAULT_CLIENT,
"Content-Type must be 'text/xml,' 'multipart/*,' "
. "'application/soap+xml,' 'or 'application/dime' instead of '$content_type'"
)
lib/SOAP/Transport/HTTP.pm view on Meta::CPAN
my $self = shift;
$self->make_response(
$SOAP::Constants::HTTP_ON_FAULT_CODE => $self->SUPER::make_fault(@_)
);
return;
}
sub make_response {
my ( $self, $code, $response ) = @_;
my $encoding = $1
if $response =~ /^<\?xml(?: version="1.0"| encoding="([^\"]+)")+\?>/;
$response =~ s!(\?>)!$1<?xml-stylesheet type="text/css"?>!
if $self->request->content_type eq 'multipart/form-data';
$self->options->{is_compress} ||=
exists $self->options->{compress_threshold}
&& eval { require Compress::Zlib };
my $compressed = $self->options->{is_compress}
&& grep( /\b($COMPRESS|\*)\b/,
$self->request->header('Accept-Encoding') )
&& ( $self->options->{compress_threshold} || 0 ) <
SOAP::Utils::bytelength $response;
if ($] > 5.007 && $encoding) {
require Encode;
$response = Encode::encode( $encoding, $response );
}
$response = Compress::Zlib::compress($response) if $compressed;
# this next line does not look like a good test to see if something is multipart
# perhaps a /content-type:.*multipart\//gi is a better regex?
my ($is_multipart) =
( $response =~ /^content-type:.* boundary="([^\"]*)"/im );
$self->response(
HTTP::Response->new(
$code => undef,
HTTP::Headers->new(
'SOAPServer' => $self->product_tokens,
$compressed ? ( 'Content-Encoding' => $COMPRESS ) : (),
'Content-Type' => join( '; ',
'text/xml',
!$SOAP::Constants::DO_NOT_USE_CHARSET
&& $encoding ? 'charset=' . lc($encoding) : () ),
'Content-Length' => SOAP::Utils::bytelength $response
),
$response,
) );
$self->response->headers->header( 'Content-Type' =>
'Multipart/Related; type="text/xml"; start="<main_envelope>"; boundary="'
. $is_multipart
. '"' )
if $is_multipart;
lib/SOAP/Utils.pod view on Meta::CPAN
# ======================================================================
=pod
=head1 NAME
SOAP::Utils - a utility package for SOAP::Lite
=head1 DESCRIPTION
This class gives you access to a number of subroutines to assist in data formatting, encoding, etc. Many of the subroutines are private, and are not documented here, but a few are made public.
=head1 METHODS
=over
=item format_datetime
Returns a valid xsd:datetime string given a time object returned by Perl's localtime function. Usage:
print SOAP::Utils::format_datetime(localtime);
t/01-core.t view on Meta::CPAN
$SIG{__WARN__} = sub { ; }; # turn off deprecation warnings
$serialized = SOAP::Serializer->use_prefix(1)->uri("urn:Test")->method(
'testMethod', SOAP::Data->name(test => 123)
);
ok($serialized =~ m!<soap:Body><namesp(\d):testMethod><test xsi:type="xsd:int">123</test></namesp\1:testMethod></soap:Body>!);
# test 3 - turn ON default namespace
$serialized = SOAP::Serializer->use_prefix(0)->uri("urn:Test")->method(
'testMethod', SOAP::Data->name(test => 123)
);
ok($serialized =~ m!<soap:Envelope(?: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsd="http://www.w3.org/2001/XMLSchema"| soap:encodingStyle="http://schemas.xmlsoap.org/soa...
}
{ # check use of default_ns, ns, and use_prefix
# test 4
$serialized = SOAP::Serializer->ns("urn:Test")->method(
'testMethod', SOAP::Data->name(test => 123)
);
ok($serialized =~ m!<namesp(\d):testMethod><test xsi:type="xsd:int">123</test></namesp\1:testMethod>!);
t/01-core.t view on Meta::CPAN
'testMethod', SOAP::Data->name(test => 123)
);
ok($serialized =~ m!<soap:Body><testMethod xmlns="urn:Test"><test xsi:type="xsd:int">123</test></testMethod></soap:Body>!);
}
{ # check serialization
print "Arrays, structs, refs serialization test(s)...\n";
$serialized = SOAP::Serializer->serialize(
SOAP::Data->name(test => \SOAP::Data->value(1, [1,2], {a=>3}, \4))
);
ok($serialized =~ m!<test(?: xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:xsd="http://www.w3.org/2001/XMLSchema"){4}>...
}
{ # check simple circular references
print "Simple circular references (\$a=\\\$a) serialization test(s)...\n";
$a = \$a;
$serialized = SOAP::Serializer->namespaces({})->serialize($a);
ok($serialized =~ m!<c-gensym(\d+) id="ref-(\w+)"><c-gensym(\d+) href="#ref-\2" /></c-gensym\1>!);
t/01-core.t view on Meta::CPAN
{ # check multirefs
print "Multireferences serialization test(s)...\n";
$a = 1; my $b = \$a;
$serialized = SOAP::Serializer->new(multirefinplace=>1)->serialize(
SOAP::Data->name(test => \SOAP::Data->value($b, $b))
);
ok($serialized =~ m!<test(?: xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:xsd="http://www.w3.org/2001/XMLSchema"){4}>...
$serialized = SOAP::Serializer->namespaces({})->serialize(
SOAP::Data->name(test => \SOAP::Data->value($b, $b))
);
print $serialized, "\n";
ok($serialized =~ m!<c-gensym\d+ href="#ref-(\w+)" /><c-gensym\d+ href="#ref-\1" /><c-gensym(\d+) id="ref-\1"><c-gensym(\d+) xsi:type="xsd:int">1</c-gensym\3></c-gensym\2>!);
}
{ # check base64, XML encoding of elements and attributes
print "base64, XML encoding of elements and attributes test(s)...\n";
$serialized = SOAP::Serializer->serialize(
SOAP::Data->name(test => \SOAP::Data->value("\0\1\2\3 \4\5\6", "<123>&\015</123>"))
);
ok($serialized =~ m!<c-gensym(\d+) xsi:type="xsd:base64Binary">AAECAyAgIAQFBg==</c-gensym\1><c-gensym(\d+) xsi:type="xsd:string"><123>&amp;
</123></c-gensym\2>!);
$serialized = SOAP::Serializer->namespaces({})->serialize(
SOAP::Data->name(name=>'value')->attr({attr => '<123>"&"</123>'})
);
ok($serialized =~ m!^<\?xml version="1.0" encoding="UTF-8"\?><name(?: xsi:type="xsd:string"| attr="<123>"&amp"</123>"){2}>value</name>$!);
}
{ # check objects and SOAP::Data
print "Blessed references and SOAP::Data encoding test(s)...\n";
$serialized = SOAP::Serializer->serialize(SOAP::Data->uri('some_urn' => bless {a => 1} => 'ObjectType'));
ok($serialized =~ m!<namesp(\d+):c-gensym(\d+)(:? xsi:type="namesp\d+:ObjectType"| xmlns:namesp\d+="http://namespaces.soaplite.com/perl"| xmlns:namesp\1="some_urn"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3...
}
{ # check serialization/deserialization of simple types
print "Serialization/deserialization of simple types test(s)...\n";
$a = 'abc234xyz';
$serialized = SOAP::Serializer->serialize(SOAP::Data->type(hex => $a));
ok($serialized =~ m!<c-gensym(\d+)(?: xsi:type="xsd:hexBinary"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:xsd="htt...
ok(SOAP::Deserializer->deserialize($serialized)->root eq $a);
$a = <<"EOBASE64";
qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?`1234567890-=\~!@#$%^&*()_+|
EOBASE64
$serialized = SOAP::Serializer->serialize($a);
ok(index($serialized, quotemeta(q!qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?`1234567890-=~\!@#0^&*()_+|!)));
t/01-core.t view on Meta::CPAN
{
print "Test SOAP:: prefix with no +autodispatch option...\n";
eval { A->SOAP::b };
ok($@ =~ /^SOAP:: prefix/);
}
{
# check deserialization of an array of multiple elements
# nested within a complex type
print "Deserialization of document/literal arrays nested in complex types...\n";
my $input = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><soap:Body><getFooResponse ...
my $deserializer = SOAP::Deserializer->new;
my $ret = $deserializer->deserialize($input);
my @arr = @{$ret->result->{'complexFoo'}{'arrayFoo'}};
ok($#arr == 1);
ok("one" eq $arr[0]);
ok("two" eq $arr[1]);
ok(100 == $ret->result->{"id"});
# If only one araryFoo tag is found, it's deserialized as a scalar.
$input = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><soap:Body><getFooResponse xml...
$ret = $deserializer->deserialize($input);
ok("one" eq $ret->result->{'complexFoo'}{'arrayFoo'});
}
{
print "Serialization of document/literal arrays\n";
# check array serialization with autotyping disabled
my $serializer = SOAP::Serializer->new;
$serializer->autotype(0);
t/010-serializer.t view on Meta::CPAN
$enc = SOAP::XMLSchema1999::Serializer->as_undef(1, 'test', 'boolean', {});
ok $enc eq '1';
$enc = SOAP::XMLSchema1999::Serializer->as_undef(0, 'test', 'boolean', {});
ok $enc eq '0';
$enc = SOAP::XMLSchema1999::Serializer->as_base64(0, 'test', 'string', {});
ok ($enc->[2] eq 'MA==');
print "# encoding/decoding Euro symbol in base64\n";
if ($] < 5.008) {
print "# Skippng unicode test on perl <5.8 ($])\n";
ok(1);
ok(1);
}
else {
eval {
# may fail on old perls
my $str = chr(8364);
utf8::encode($str);
t/013-array-deserialization.t view on Meta::CPAN
my $som = SOAP::Deserializer->new->deserialize($xml);
my $result = $som->result();
ok (@$result == 2);
ok $result->[0]->isa('outer');
ok $result->[1]->isa('outer');
ok $result->[1]->{ kids }->[0]->isa('inner');
ok $result->[1]->{ kids }->[1]->isa('inner');
__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="urn:MyNamespace"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Body>
<my:response>
<my:return href="#id0"/>
</my:response>
<multiRef id="id0" soapenc:root="0" xsi:type="apachesoap:Vector">
<item href="#id1"/>
<item href="#id5"/>
</multiRef>
<multiRef id="id1" soapenc:root="0" xsi:type="my:outer">
<name xsi:type="xsd:string">a</name>
t/02-payload.t view on Meta::CPAN
use SOAP::Lite;
$SIG{__WARN__} = sub { ; }; # turn off deprecation warnings
my($a, $s, $r, $serialized, $deserialized);
{ # check root, mustUnderstand
print "root and mustUnderstand attributes with SOAP::Data test(s)...\n";
$serialized = SOAP::Serializer->serialize(SOAP::Data->root(1 => 1)->name('rootandunderstand')->mustUnderstand(1));
ok($serialized =~ m!<rootandunderstand( xsi:type="xsd:int"| soap:mustUnderstand="1"| soapenc:root="1"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.org/2...
}
{ # check deserialization of envelope with result
print "Deserialization of envelope with result test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:doublerResponse xmlns:m="http://simon.fell.com/calc">
<nums xsi:type="soapenc:Array" soapenc:arrayType="xsd:int[5]">
<item xsi:type="xsd:int">20</item>
<item xsi:type="xsd:int">40</item>
<item xsi:type="xsd:int">60</item>
<item xsi:type="xsd:int">100</item>
<item xsi:type="xsd:int">200</item>
</nums>
</m:doublerResponse>
t/02-payload.t view on Meta::CPAN
ok($deserialized->result->[2] == 60);
ok((my @array = $deserialized->paramsall) == 1);
ok(ref $deserialized->body eq 'HASH'); # not blessed anymore since 0.51
}
{ # check deserialization of envelope with fault
print "Deserialization of envelope with fault test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="htt...
<soap:Body>
<soap:Fault><faultcode>soap:Client</faultcode><faultstring>Application Error</faultstring><detail>Invalid Password</detail></soap:Fault></soap:Body></soap:Envelope>
');
ok($deserialized->faultcode eq 'soap:Client');
ok($deserialized->faultstring eq 'Application Error');
ok($deserialized->faultdetail eq 'Invalid Password');
}
{ # check deserialization of circular references
t/02-payload.t view on Meta::CPAN
ok($deserialized->dataof('/Struct')->attr->{'{aaa}id'} == 123);
ok(exists $deserialized->dataof('/Struct')->attr->{'id'});
}
{ # check SOAP::SOM
print "SOM test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:doublerResponse xmlns:m="http://simon.fell.com/calc">
<nums>
<item1 xsi:type="xsd:int">20</item1>
<item1 xsi:type="xsd:int">40</item1>
<item2 xsi:type="xsd:int">60</item2>
<item2 xsi:type="xsd:int">100</item2>
<item3 xsi:type="xsd:int">200</item3>
<item3 xsi:type="xsd:int">200</item3>
<item4 xsi:type="xsd:int">200</item4>
t/02-payload.t view on Meta::CPAN
ok($deserialized->valueof('[1]') == 20);
ok($deserialized->valueof('[3]') == 60);
ok($deserialized->valueof('[5]') == 200);
}
{ # check output parameters
print "Output parameters test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<mehodResponse>
<res1>name1</res1>
<res2>name2</res2>
<res3>name3</res3>
</mehodResponse>
</soap:Body>
</soap:Envelope>
');
my @paramsout = $deserialized->paramsout;
ok($paramsout[0] eq 'name2' && $paramsout[1] eq 'name3');
}
{ # check nonqualified namespace
print "Nonqualified namespace test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<doublerResponse xmlns="http://simon.fell.com/calc">
<nums xsi:type="soapenc:Array" soapenc:arrayType="xsd:int[5]">
<item xsi:type="xsd:int">20</item>
<item xsi:type="xsd:int">40</item>
<item xsi:type="xsd:int">60</item>
<item xsi:type="xsd:int">100</item>
<item xsi:type="xsd:int">200</item>
</nums>
</doublerResponse>
t/02-payload.t view on Meta::CPAN
$serialized = SOAP::Serializer->method( # same as ->envelope(method =>
SOAP::Data->name('mymethod')->attr({something => 'value'}), 1, 2, 3,
);
ok($serialized =~ /<mymethod something="value">/);
$serialized = SOAP::Serializer
-> envprefix('')
-> method('mymethod');
ok($serialized =~ m!<Envelope(?: xmlns:namesp\d+="http://schemas.xmlsoap.org/soap/envelope/"| namesp\d+:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.o...
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3....
ok(! defined $deserialized->namespaceuriof('//getStateName'));
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns="a" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http...
ok($deserialized->namespaceuriof('//getStateName') eq 'a');
}
{ # Map type serialization/deserialization
print "Map type serialization/deserialization test(s)...\n";
my $key = "\0\1";
$serialized = SOAP::Serializer->method(aa => SOAP::Data->type(map => {a => 123, $key => 456})->name('maaap'));
{ local $^W; # disable warning on implicit map encoding
my $implicit = SOAP::Serializer->method(aa => SOAP::Data->name(maaap => {a => 123, $key => 456}));
ok($implicit eq $serialized);
}
ok($serialized =~ /apachens:Map/);
ok($serialized =~ m!xmlns:apachens="http://xml.apache.org/xml-soap"!);
$deserialized = SOAP::Deserializer->deserialize($serialized);
$a = $deserialized->valueof('//maaap');
ok(UNIVERSAL::isa($a => 'HASH'));
ok(ref $a && $a->{$key} == 456);
}
{ # Stringified type serialization
print "Stringified type serialization test(s)...\n";
$serialized = SOAP::Serializer->serialize(bless { a => 1, _current => [] } => 'SOAP::SOM');
my $test = $serialized;
ok $test =~s{
<\?xml \s version="1.0" \s encoding="UTF-8"\?>
<SOAP__SOM
(?:
\sxsi:type="namesp(\d+):SOAP__SOM"
| \sxmlns:namesp\d+="http://namespaces.soaplite.com/perl"
| \sxmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
| \sxmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
| \sxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| \sxmlns:xsd="http://www.w3.org/2001/XMLSchema"){6}>
}{}xms;
ok $test =~s{
</SOAP__SOM> \z
}{}xms;
ok $test =~s{ <a \s xsi:type="xsd:int">1</a> }{}xms;
ok $test =~s{ <_current (:?
\s soapenc:arrayType="xsd:anyType\[0\]"
| \s xsi:type="soapenc:Array" ){2}
\s/>
}{}xms;
ok length $test == 0;
# Replaced complex regex by several simpler (see above).
# ok($serialized =~ m!<SOAP__SOM(?: xsi:type="namesp(\d+):SOAP__SOM"| xmlns:namesp\d+="http://namespaces.soaplite.com/perl"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xs...
# ok( ($serialized =~ m!<SOAP__SOM(?: xsi:type="namesp(\d+):SOAP__SOM"| xmlns:namesp\d+="http://namespaces.soaplite.com/perl"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:...
# || ($serialized =~ m!<SOAP__SOM(?: xsi:type="namesp(\d+):SOAP__SOM"| xmlns:namesp\d+="http://namespaces.soaplite.com/perl"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:...
#print $serialized;
# exit;
$serialized =~ s/__/./g; # check for SOAP.SOM instead of SOAP__SOM
ok(ref SOAP::Deserializer->deserialize($serialized)->root eq 'SOAP::SOM');
}
{ # Serialization of non-allowed element
print "Serialization of non-allowed element test(s)...\n";
t/02-payload.t view on Meta::CPAN
eval q!
sub SOAP::Serializer::as_My__Own__Class {
my $self = shift;
my($value, $name, $type, $attr) = @_;
return [$name, {%{$attr || {}}, 'xsi:type' => 'xsd:string'}, join ', ', map {"$_ => $value->{$_}"} sort keys %$value];
}
1;
! or die;
$serialized = SOAP::Serializer->serialize(bless {a => 1, b => 2} => 'My::Own::Class');
ok($serialized =~ m!<My__Own__Class( xsi:type="xsd:string"| xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"| xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"| xmlns:xsd="http://...
}
{ # Multirefs serialization
print "Multirefs serialization test(s)...\n";
my $b = { b => 2 };
my $a = { a => $b };
my $c = { c1 => $a, c2 => $a };
$serialized = SOAP::Serializer->autotype(0)->method(a => $c);
t/02-payload.t view on Meta::CPAN
return;
};
1;
} or die;
$deserialized = MyDeserializer->deserialize('<a><b>1</b><c>2</c></a>');
ok($desc eq 'a 2'); #! fix "if $name eq 'a'", because $name is QName now ('{}a')
ok($typecasts == 5);
}
{ # Deserialization with wrong encodingStyle
print "Deserialization with wrong encodingStyle test(s)...\n";
eval { $deserialized = SOAP::Deserializer->deserialize(
'<a
soap:encodingStyle="http://schemas.microsoft.com/soap/encoding/clr/1.0 http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>1</a>') };
ok(!$@ && $deserialized);
eval { $deserialized = SOAP::Deserializer->deserialize(
'<a
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>1</a>') };
ok(!$@ && $deserialized);
eval { $deserialized = SOAP::Deserializer->deserialize(
'<a
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/something"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>1</a>') };
ok(!$@ && $deserialized);
eval { $deserialized = SOAP::Deserializer->deserialize(
'<a>1</a>') };
ok(!$@ && $deserialized);
eval { $deserialized = SOAP::Deserializer->deserialize(
'<a
soap:encodingStyle=""
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>1</a>') };
ok(!$@ && $deserialized);
}
{ # Deserialization with root attribute
print "Deserialization with root attribute test(s)...\n";
# root="0", should skip
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:doublerResponse1 soapenc:root="0" xmlns:m="http://soaplite.com/">
<nums>1</nums>
</m:doublerResponse1>
<m:doublerResponse2 xmlns:m="http://soaplite.com/">
<nums>2</nums>
</m:doublerResponse2>
</soap:Body>
</soap:Envelope>
');
ok($deserialized->result == 2);
# root="0", but in wrong namespace
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:doublerResponse1 root="0" xmlns:m="http://soaplite.com/">
<nums>1</nums>
</m:doublerResponse1>
<m:doublerResponse2 xmlns:m="http://soaplite.com/">
<nums>2</nums>
</m:doublerResponse2>
</soap:Body>
</soap:Envelope>
');
ok($deserialized->result == 1);
# root="1"
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<m:doublerResponse1 soapenc:root="1" xmlns:m="http://soaplite.com/">
<nums>1</nums>
</m:doublerResponse1>
<m:doublerResponse2 xmlns:m="http://www.soaplite.com/2">
<nums>2</nums>
</m:doublerResponse2>
<m:doublerResponse2 xmlns:m="http://www.soaplite.com/3">
<nums>3</nums>
</m:doublerResponse2>
t/02-payload.t view on Meta::CPAN
ok(@nums == 3);
ok($nums[0] == 2 && $nums[1] == 3);
my $body = $deserialized->body;
ok(ref $body->{doublerResponse1} && ref $body->{doublerResponse2});
}
{
print "Deserialization with null elements test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="htt...
<soap:Body>
<namesp23:object_infoResponse xmlns:namesp23="http://localhost/Test">
<soapenc:Array xsi:type="soapenc:Array" soapenc:arrayType="xsd:integer[]">
<item xsi:type="xsd:string">1</item>
<item xsi:type="xsd:string">2</item>
<item xsi:null="1"/>
<item xsi:null="1"/>
<item xsi:type="xsd:string">5</item>
<item xsi:type="xsd:string"/>
<item xsi:type="xsd:string">7</item>
t/02-payload.t view on Meta::CPAN
$serialized = SOAP::Serializer->method(a => undef, 1, undef, 2);
my(@r) = SOAP::Deserializer->deserialize($serialized)->paramsall;
ok(2 == grep {!defined} @r);
}
{
print "Deserialization with xsi:type='string' test(s)...\n";
$a = 'SOAP::Lite';
$deserialized = SOAP::Deserializer->deserialize(qq!<inputString xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:type="string" xmlns="http://schemas.xmlsoap.org/soap/encoding/">$a</inputString>!)->root;
ok($deserialized eq $a);
}
{
print "Deserialization with typing inherited from Array element test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<soapenc:Array xsi:type="soapenc:Array" soapenc:arrayType="soapenc:base64[]" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" soap:encodingSty...
<item xsi:type="xsd:string">MTIz</item>
<item>MTIz</item>
<item xsi:type="xsd:string"/>
</soapenc:Array>')->root;
ok(scalar @$deserialized == 3);
ok($deserialized->[0] eq 'MTIz');
ok($deserialized->[1] eq 123);
ok($deserialized->[2] eq '');
}
t/02-payload.t view on Meta::CPAN
ok(defined $uri ? defined $data->uri && $data->uri eq $uri
: !defined $data->uri);
}
}
{
print "Deserialization for different SOAP versions test(s)...\n";
my $version = SOAP::Lite->soapversion;
$a = q!<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<namesp9:echoIntegerArray xmlns:namesp9="http://soapinterop.org/">
<inputIntegerArray soapenc:arrayType="xsd:int[3]" xsi:type="soapenc:Array">
<item xsi:type="xsd:int">1</item>
<item xsi:type="xsd:int">3</item>
<item xsi:type="xsd:int">5</item>
</inputIntegerArray>
t/02-payload.t view on Meta::CPAN
SOAP::Lite->soapversion(1.2);
$deserialized = SOAP::Deserializer->deserialize($a);
ok(ref $deserialized->result eq 'ARRAY');
SOAP::Lite->soapversion($version);
}
{
print "Deserialization of multidimensional array of array test(s)...\n";
$a = q!<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:E='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:a='http://foo.bar.org/'
xmlns:b='http://www.w3.org/2001/XMLSchema'
xmlns:c='http://www.w3.org/2001/XMLSchema-instance'>
<S:Body><a:SomeMethod>
<nums E:arrayType='b:anyType[2,2]'>
<i E:arrayType='b:anyType[3]'>
<i c:type='b:short'>1</i><i c:type='b:short'>2</i><i c:type='b:short'>3</i>
</i>
<i E:arrayType='b:anyType[3]'>
<i c:type='b:short'>4</i><i c:type='b:short'>5</i><i c:type='b:short'>6</i>
t/02-payload.t view on Meta::CPAN
}
{
print "Serialization without specified typemapping test(s)...\n";
$serialized = SOAP::Serializer->method(a => bless {a => 1} => 'A');
ok($serialized =~ m!<A xsi:type="namesp\d+:A">!);
ok($serialized =~ m!^<\?xml!); # xml declaration
# higly questionably, but that's how it is
$serialized = SOAP::Serializer->encoding(undef)->method(a => bless {a => 1} => 'A');
ok($serialized =~ m!<A(?: xsi:type="namesp\d+:A"| xmlns:namesp\d+="http://namespaces.soaplite.com/perl")>!);
ok($serialized !~ m!^<\?xml!); # no xml declaration
}
{
print "Deserialization with different XML Schemas on one element test(s)...\n";
my $deserializer = SOAP::Deserializer->new;
$deserializer->deserialize(q!<soap:Envelope
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi1="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi0="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsi9="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd9="http://www.w3.org/1999/XMLSchema"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:xsd0="http://www.w3.org/2000/10/XMLSchema" >
<soap:Body>
<ns0:echoString xmlns:ns0="http://soapinterop.org/" >
<inputString xsi0:type="xsd0:string" xsi1:type="xsd1:string"
xsi9:type="xsd9:string">Simple Test String</inputString>
</ns0:echoString>
</soap:Body>
</soap:Envelope>!);
ok($deserializer->xmlschema eq 'http://www.w3.org/1999/XMLSchema');
$deserializer->deserialize(q!<soap:Envelope
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi1="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi0="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsi9="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd9="http://www.w3.org/1999/XMLSchema"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:xsd0="http://www.w3.org/2000/10/XMLSchema" >
<soap:Body>
<ns0:echoString xmlns:ns0="http://soapinterop.org/" >
<inputString xsi0:type="xsd1:string" xsi1:type="xsd1:string"
xsi9:type="xsd1:string">Simple Test String</inputString>
t/03-server.t view on Meta::CPAN
use Test;
BEGIN { plan tests => 32 }
use SOAP::Lite;
my($a, $s, $r, $serialized, $deserialized);
my %tests = (
'XML only' => <<'EOM',
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:add xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
<c-gensym7 xsi:type="xsd:int">5</c-gensym7>
</namesp1:add>
</soap:Body>
</soap:Envelope>
EOM
'message with headers' => <<'EOM',
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:add xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
<c-gensym7 xsi:type="xsd:int">5</c-gensym7>
</namesp1:add>
</soap:Body>
</soap:Envelope>
EOM
'singlepart MIME' => <<'EOM',
Content-Type: Multipart/Related; boundary=MIME_boundary; type="text/xml"; start="<calc061400a.xml@soaplite.com>"
--MIME_boundary
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <calc061400a.xml@soaplite.com>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:add xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
<c-gensym7 xsi:type="xsd:int">5</c-gensym7>
</namesp1:add>
</soap:Body>
</soap:Envelope>
t/03-server.t view on Meta::CPAN
EOM
'multipart MIME' => <<'EOM',
Content-Type: Multipart/Related; boundary=MIME_boundary; type="text/xml"; start="<calc061400a.xml@soaplite.com>"
--MIME_boundary
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <calc061400a.xml@soaplite.com>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:add xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
<c-gensym7 xsi:type="xsd:int">5</c-gensym7>
</namesp1:add>
</soap:Body>
</soap:Envelope>
t/03-server.t view on Meta::CPAN
EOM
'multipart MIME w/multiref' => <<'EOM',
Content-Type: Multipart/Related; boundary=MIME_boundary; type="text/xml"; start="<calc061400a.xml@soaplite.com>"
--MIME_boundary
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <calc061400a.xml@soaplite.com>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:add xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 href="cid:calc061400a.a@soaplite.com"/>
<c-gensym7 href="cid:calc061400a.b@soaplite.com"/>
</namesp1:add>
</soap:Body>
</soap:Envelope>
t/03-server.t view on Meta::CPAN
$a = SOAP::Server->handle('<a></a>');
ok($a =~ /Can't find root/);
$a = SOAP::Server->handle('<Envelope></Envelope>');
ok($a =~ /Can't find method/);
$a = SOAP::Server->handle('<Envelope><Body><Add><a>1</a><b>1</b></Add></Body></Envelope>');
ok($a =~m{Denied \s access \s to \s method}x);
$a = SOAP::Server->handle('<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body></soap:Body></soap:Envelope>');
ok($a =~ /Can't find method/);
}
{
print "Envelope with no namespaces test(s)...\n";
eval 'sub add { $_[1] + $_[2] }; 1' or die;
my $result = SOAP::Deserializer->deserialize(SOAP::Server->dispatch_to('add')->handle('<Envelope><Body><add><a>3</a><b>4</b></add></Body></Envelope>'));
ok(($result->result || 0) == 7);
}
{
print "Different XML Schemas test(s)...\n";
my $server = SOAP::Server->dispatch_to('Calculator');
$a = $server->handle('<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soap:Body>
<namesp1:schema xmlns:namesp1="http://www.soaplite.com/Calculator"/>
</soap:Body></soap:Envelope>');
ok($a =~ m!xsi="http://www.w3.org/2001/XMLSchema-instance"!);
ok($a =~ m!xsd="http://www.w3.org/2001/XMLSchema"!);
ok($a =~ m!>http://www.w3.org/2001/XMLSchema<!);
$a = $server->handle('<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<namesp1:schema xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
</namesp1:schema>
</soap:Body></soap:Envelope>');
ok($a =~ m!xsi="http://www.w3.org/2001/XMLSchema-instance"!);
ok($a =~ m!xsd="http://www.w3.org/2001/XMLSchema"!);
ok($a =~ m!>http://www.w3.org/2001/XMLSchema<!);
$a = $server->handle('<soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<namesp1:schema xmlns:namesp1="http://www.soaplite.com/Calculator">
<c-gensym5 xsi:type="xsd:int">2</c-gensym5>
</namesp1:schema>
</soap:Body></soap:Envelope>');
ok($a =~ m!xsi="http://www.w3.org/2001/XMLSchema-instance"!);
t/05-customxml.t view on Meta::CPAN
print $portfolio->type, " ", $portfolio->date, "\n";
ok($portfolio->type && $portfolio->date);
foreach my $row ($portfolio->Row) {
# test elements
print " ", $row->Element, " ", $row->Value, "\n";
ok($row->Element && $row->Value);
}
}
__DATA__
<?xml version="1.0" encoding="UTF-8"?>
<Envelope version="1.1">
<Header />
<Body>
<Report>
<Header>
<ClientRef />
<FundCusip>61744J366</FundCusip>
<SepAcctDesc />
</Header>
<Request>
t/08-schema.t view on Meta::CPAN
use SOAP::Lite;
my($a, $s, $r, $serialized, $deserialized);
{ # check deserialization of envelope with result
print "Deserialization of envelope with result test(s)...\n";
$deserialized = SOAP::Deserializer->deserialize('<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:doublerResponse xmlns:m="http://simon.fell.com/calc">
<nums xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:int[5]">
<item xsi:type="xsd:int">20</item>
<item xsi:type="xsd:int">40</item>
<item xsi:type="xsd:int">60</item>
<item xsi:type="xsd:int">100</item>
<item xsi:type="xsd:int">200</item>
</nums>
</m:doublerResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
');
ok($deserialized->result->[2] == 60);
ok((my @array = $deserialized->paramsall) == 1);
ok(ref $deserialized->body eq 'HASH'); # not blessed anymore since 0.51
}
{
print "hex encoding test(s)...\n";
$a = "\0 {a}\1";
$serialized = SOAP::Serializer->serialize(SOAP::Data->type(hex => $a));
ok($serialized =~ />00207B617D01</);
ok(SOAP::Deserializer->deserialize($serialized)->root eq $a);
}
{
print "Deserialization of 1999/2001 schemas test(s)...\n";
foreach (split "\n", <<EOX) {
<i xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SOAP-ENC:integer">12</i>
<i xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:nonNegativeInteger">12</i>
<i xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:anySimpleType">12</i>
<i xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:anyType">12</i>
<i xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:type="xsd:ur-type">12</i>
<SOAP-ENC:integer xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">12</SOAP-ENC:integer>
<i>12</i>
EOX
$deserialized = SOAP::Deserializer->deserialize($_);
ok($deserialized->root == 12);
}
eval { SOAP::Deserializer->deserialize('<i xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:type="xsd:something">12</i>') };
ok($@ =~ m!Unrecognized type '\{http://www.w3.org/1999/XMLSchema\}something'!);
eval { SOAP::Deserializer->deserialize('<i xmlns:xsd="http://some.thing.else/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:type="xsd:something">12</i>') };
t/Issues/rt53375.t view on Meta::CPAN
use XML::Parser::Lite;
my $comment = '';
my $parser = new XML::Parser::Lite(
Handlers => {
Comment => sub { $comment .= $_[1]; },
}
);
my $xml = <<'EOT';
<?xml version="1.0" encoding="UTF-8"?>
<!-- seed-viewer -->
<test>
</test>
EOT
eval {
$parser->parse($xml);
};
ok(! $@);
is($comment, ' seed-viewer ');
$comment = '';
$xml = <<'EOT';
<?xml version="1.0" encoding="UTF-8"?>
<!-- seed_viewer -->
<test>
</test>
EOT
eval {
$parser->parse($xml);
};
ok(! $@);
is($comment, ' seed_viewer ');
t/Issues/rt72836.t view on Meta::CPAN
sub new {
my ( $class ) = @_;
my $self = bless {}, ref($class) || $class;
$self;
}
sub do_something {
my $self = shift;
my $som = pop;
#$som->context->serializer->encodingStyle(""); # does adding this affect the fix?
return SOAP::Data->name(wotsit => "doofer");
}
package main;
use Test::More;
use SOAP::Lite;
eval { require Test::XML }
or plan skip_all => 'Cannot test without Test::XML';
my $req11 = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Something"><soapenv:Header/><soapenv:Body><urn:do_something><stuff>things</stuff></urn:do_something></soapenv:Body></soapenv:Envelope>';
my $req12 = '<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:Something"><soapenv:Header/><soapenv:Body><urn:do_something><stuff>things</stuff></urn:do_something></soapenv:Body></soapenv:Envelope>';
my $expected_11 = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="h...
my $expected_12 = '<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="htt...
my $t = DoThingsWithStuff->new;
my $s = SOAP::Server->new;
$s->dispatch_with({
"urn:Something" => $t
});
my $res_11_1 = $s->handle($req11);
Test::XML::is_xml($res_11_1, $expected_11, "Got correct SOAP 1.1 response");