.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SOAP::Lite 3pm" .TH SOAP::Lite 3pm "2023-03-01" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SOAP::Lite \- Perl's Web Services Toolkit .SH "DESCRIPTION" .IX Header "DESCRIPTION" SOAP::Lite is a collection of Perl modules which provides a simple and lightweight interface to the Simple Object Access Protocol (\s-1SOAP\s0) both on client and server side. .SH "PERL VERSION WARNING" .IX Header "PERL VERSION WARNING" As of version SOAP::Lite version 1.05, no perl versions before 5.8 will be supported. .PP SOAP::Lite 0.71 will be the last version of SOAP::Lite running on perl 5.005 .PP Future versions of SOAP::Lite will require at least perl 5.6.0 .PP If you have not had the time to upgrade your perl, you should consider this now. .SH "OVERVIEW OF CLASSES AND PACKAGES" .IX Header "OVERVIEW OF CLASSES AND PACKAGES" .IP "\fIlib/SOAP/Lite.pm\fR" 4 .IX Item "lib/SOAP/Lite.pm" SOAP::Lite \- Main class provides all logic .Sp SOAP::Transport \- Transport backend .Sp SOAP::Data \- Data objects .Sp SOAP::Header \- Header Data Objects .Sp SOAP::Serializer \- Serializes data structures to \s-1SOAP\s0 messages .Sp SOAP::Deserializer \- Deserializes \s-1SOAP\s0 messages into \s-1SOAP::SOM\s0 objects .Sp \&\s-1SOAP::SOM\s0 \- \s-1SOAP\s0 Message objects .Sp SOAP::Constants \- Provides access to common constants and defaults .Sp SOAP::Trace \- Tracing facilities .Sp SOAP::Schema \- Provides access and stub(s) for schema(s) .Sp SOAP::Schema::WSDL \- \s-1WSDL\s0 implementation for SOAP::Schema .Sp SOAP::Server \- Handles requests on server side .Sp SOAP::Server::Object \- Handles objects-by-reference .Sp SOAP::Fault \- Provides support for Faults on server side .Sp SOAP::Utils \- A set of private and public utility subroutines .IP "\fIlib/SOAP/Packager.pm\fR" 4 .IX Item "lib/SOAP/Packager.pm" SOAP::Packager \- Provides an abstract class for implementing custom packagers. .Sp SOAP::Packager::MIME \- Provides \s-1MIME\s0 support to SOAP::Lite .Sp SOAP::Packager::DIME \- Provides \s-1DIME\s0 support to SOAP::Lite .IP "\fIlib/SOAP/Transport/HTTP.pm\fR" 4 .IX Item "lib/SOAP/Transport/HTTP.pm" SOAP::Transport::HTTP::Client \- Client interface to \s-1HTTP\s0 transport .Sp SOAP::Transport::HTTP::Server \- Server interface to \s-1HTTP\s0 transport .Sp SOAP::Transport::HTTP::CGI \- \s-1CGI\s0 implementation of server interface .Sp SOAP::Transport::HTTP::Daemon \- Daemon implementation of server interface .Sp SOAP::Transport::HTTP::Apache \- mod_perl implementation of server interface .IP "\fIlib/SOAP/Transport/POP3.pm\fR" 4 .IX Item "lib/SOAP/Transport/POP3.pm" SOAP::Transport::POP3::Server \- Server interface to \s-1POP3\s0 protocol .IP "\fIlib/SOAP/Transport/MAILTO.pm\fR" 4 .IX Item "lib/SOAP/Transport/MAILTO.pm" SOAP::Transport::MAILTO::Client \- Client interface to SMTP/sendmail .IP "\fIlib/SOAP/Transport/LOCAL.pm\fR" 4 .IX Item "lib/SOAP/Transport/LOCAL.pm" SOAP::Transport::LOCAL::Client \- Client interface to local transport .IP "\fIlib/SOAP/Transport/TCP.pm\fR" 4 .IX Item "lib/SOAP/Transport/TCP.pm" SOAP::Transport::TCP::Server \- Server interface to \s-1TCP\s0 protocol .Sp SOAP::Transport::TCP::Client \- Client interface to \s-1TCP\s0 protocol .IP "\fIlib/SOAP/Transport/IO.pm\fR" 4 .IX Item "lib/SOAP/Transport/IO.pm" SOAP::Transport::IO::Server \- Server interface to \s-1IO\s0 transport .SH "METHODS" .IX Header "METHODS" All accessor methods return the current value when called with no arguments, while returning the object reference itself when called with a new value. This allows the set-attribute calls to be chained together. .IP "new(optional key/value pairs)" 4 .IX Item "new(optional key/value pairs)" .Vb 1 \& $client = SOAP::Lite\->new(proxy => $endpoint) .Ve .Sp Constructor. Many of the accessor methods defined here may be initialized at creation by providing their name as a key, followed by the desired value. The example provides the value for the proxy element of the client. .IP "transport(optional transport object)" 4 .IX Item "transport(optional transport object)" .Vb 1 \& $transp = $client\->transport( ); .Ve .Sp Gets or sets the transport object used for sending/receiving \s-1SOAP\s0 messages. .Sp See SOAP::Transport for details. .IP "serializer(optional serializer object)" 4 .IX Item "serializer(optional serializer object)" .Vb 1 \& $serial = $client\->serializer( ) .Ve .Sp Gets or sets the serializer object used for creating \s-1XML\s0 messages. .Sp See SOAP::Serializer for details. .IP "packager(optional packager object)" 4 .IX Item "packager(optional packager object)" .Vb 1 \& $packager = $client\->packager( ) .Ve .Sp Provides access to the \f(CW\*(C`SOAP::Packager\*(C'\fR object that the client uses to manage the use of attachments. The default packager is a \s-1MIME\s0 packager, but unless you specify parts to send, no \s-1MIME\s0 formatting will be done. .Sp See also: SOAP::Packager. .IP "proxy(endpoint, optional extra arguments)" 4 .IX Item "proxy(endpoint, optional extra arguments)" .Vb 1 \& $client\->proxy(\*(Aqhttp://soap.xml.info/ endPoint\*(Aq); .Ve .Sp The proxy is the server or endpoint to which the client is going to connect. This method allows the setting of the endpoint, along with any extra information that the transport object may need when communicating the request. .Sp This method is actually an alias to the proxy method of SOAP::Transport. It is the same as typing: .Sp .Vb 1 \& $client\->transport( )\->proxy(...arguments); .Ve .Sp Extra parameters can be passed to \fBproxy()\fR \- see below. .RS 4 .IP "compress_threshold" 4 .IX Item "compress_threshold" See \s-1COMPRESSION\s0 in HTTP::Transport. .IP "All initialization options from the underlying transport layer" 4 .IX Item "All initialization options from the underlying transport layer" The options for \s-1HTTP\s0(S) are the same as for LWP::UserAgent's \fBnew()\fR method. .Sp A common option is to create a instance of HTTP::Cookies and pass it as cookie_jar option: .Sp .Vb 4 \& my $cookie_jar = HTTP::Cookies\->new() \& $client\->proxy(\*(Aqhttp://www.example.org/webservice\*(Aq, \& cookie_jar => $cookie_jar, \& ); .Ve .RE .RS 4 .Sp For example, if you wish to set the \s-1HTTP\s0 timeout for a SOAP::Lite client to 5 seconds, use the following code: .Sp .Vb 3 \& my $soap = SOAP::Lite \& \->uri($uri) \& \->proxy($proxyUrl, timeout => 5 ); .Ve .Sp See LWP::UserAgent. .RE .IP "endpoint(optional new endpoint address)" 4 .IX Item "endpoint(optional new endpoint address)" .Vb 1 \& $client\->endpoint(\*(Aqhttp://soap.xml.info/ newPoint\*(Aq) .Ve .Sp It may be preferable to set a new endpoint without the additional work of examining the new address for protocol information and checking to ensure the support code is loaded and available. This method allows the caller to change the endpoint that the client is currently set to connect to, without reloading the relevant transport code. Note that the proxy method must have been called before this method is used. .IP "service(service \s-1URL\s0)" 4 .IX Item "service(service URL)" .Vb 1 \& $client\->service(\*(Aqhttp://svc.perl.org/Svc.wsdl\*(Aq); .Ve .Sp \&\f(CW\*(C`SOAP::Lite\*(C'\fR offers some support for creating method stubs from service descriptions. At present, only \s-1WSDL\s0 support is in place. This method loads the specified \s-1WSDL\s0 schema and uses it as the basis for generating stubs. .IP "outputxml(boolean)" 4 .IX Item "outputxml(boolean)" .Vb 1 \& $client\->outputxml(\*(Aqtrue\*(Aq); .Ve .Sp When set to a true value, the raw \s-1XML\s0 is returned by the call to a remote method. .Sp The default is to return a \s-1SOAP::SOM\s0 object (false). .IP "autotype(boolean)" 4 .IX Item "autotype(boolean)" .Vb 1 \& $client\->autotype(0); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->autotype(boolean); .Ve .Sp By default, the serializer tries to automatically deduce types for the data being sent in a message. Setting a false value with this method disables the behavior. .IP "readable(boolean)" 4 .IX Item "readable(boolean)" .Vb 1 \& $client\->readable(1); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->readable(boolean); .Ve .Sp When this is used to set a true value for this property, the generated \s-1XML\s0 sent to the endpoint has extra characters (spaces and new lines) added in to make the \s-1XML\s0 itself more readable to human eyes (presumably for debugging). The default is to not send any additional characters. .IP "headerattr(hash reference of attributes)" 4 .IX Item "headerattr(hash reference of attributes)" .Vb 1 \& $obj\->headerattr({ attr1 => \*(Aqvalue\*(Aq }); .Ve .Sp Allows for the setting of arbitrary attributes on the header object. Keep in mind the requirement that any attributes not natively known to \s-1SOAP\s0 must be namespace-qualified. If using \f(CW$session\fR\->call ($method, \f(CW$callData\fR, \f(CW$callHeader\fR), SOAP::Lite serializes information as .Sp .Vb 11 \& \& \& xxxxx \& yyyyy \& \& \& \& \& \& \& .Ve .Sp The attributes, given to headerattr are placed into the Header as .Sp .Vb 1 \& .Ve .IP "bodyattr(hash reference of attributes)" 4 .IX Item "bodyattr(hash reference of attributes)" .Vb 1 \& $obj\->bodyattr({ attr1 => \*(Aqvalue\*(Aq }); .Ve .Sp Allows for the setting of arbitrary attributes on the body object. Keep in mind the requirement that any attributes not natively known to \s-1SOAP\s0 must be namespace-qualified. See headerattr .IP "default_ns($uri)" 4 .IX Item "default_ns($uri)" Sets the default namespace for the request to the specified uri. This overrides any previous namespace declaration that may have been set using a previous call to \f(CW\*(C`ns()\*(C'\fR or \f(CW\*(C`default_ns()\*(C'\fR. Setting the default namespace causes elements to be serialized without a namespace prefix, like this: .Sp .Vb 7 \& \& \& \& \& \& \& .Ve .Sp Some .NET web services have been reported to require this \s-1XML\s0 namespace idiom. .IP "ns($uri,$prefix=undef)" 4 .IX Item "ns($uri,$prefix=undef)" Sets the namespace uri and optionally the namespace prefix for the request to the specified values. This overrides any previous namespace declaration that may have been set using a previous call to \f(CW\*(C`ns()\*(C'\fR or \f(CW\*(C`default_ns()\*(C'\fR. .Sp If a prefix is not specified, one will be generated for you automatically. Setting the namespace causes elements to be serialized with a declared namespace prefix, like this: .Sp .Vb 7 \& \& \& \& \& \& \& .Ve .IP "use_prefix(boolean)" 4 .IX Item "use_prefix(boolean)" Deprecated. Use the \f(CW\*(C`ns()\*(C'\fR and \f(CW\*(C`default_ns\*(C'\fR methods described above. .Sp Shortcut for \f(CW\*(C`serializer\->use_prefix()\*(C'\fR. This lets you turn on/off the use of a namespace prefix for the children of the /Envelope/Body element. Default is 'true'. .Sp When use_prefix is set to 'true', serialized \s-1XML\s0 will look like this: .Sp .Vb 5 \& \& \& \& \& .Ve .Sp When use_prefix is set to 'false', serialized \s-1XML\s0 will look like this: .Sp .Vb 5 \& \& \& \& \& .Ve .Sp Some .NET web services have been reported to require this \s-1XML\s0 namespace idiom. .IP "soapversion(optional value)" 4 .IX Item "soapversion(optional value)" .Vb 1 \& $client\->soapversion(\*(Aq1.2\*(Aq); .Ve .Sp If no parameter is given, returns the current version of \s-1SOAP\s0 that is being used by the client object to encode requests. If a parameter is given, the method attempts to set that as the version of \s-1SOAP\s0 being used. .Sp The value should be either 1.1 or 1.2. .IP "envprefix(QName)" 4 .IX Item "envprefix(QName)" .Vb 1 \& $client\->envprefix(\*(Aqenv\*(Aq); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->envprefix(QName); .Ve .Sp Gets or sets the namespace prefix for the \s-1SOAP\s0 namespace. The default is \&\s-1SOAP.\s0 .Sp The prefix itself has no meaning, but applications may wish to chose one explicitly to denote different versions of \s-1SOAP\s0 or the like. .IP "encprefix(QName)" 4 .IX Item "encprefix(QName)" .Vb 1 \& $client\->encprefix(\*(Aqenc\*(Aq); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->encprefix(QName); .Ve .Sp Gets or sets the namespace prefix for the encoding rules namespace. The default value is SOAP-ENC. .PP 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. .IP "encoding(encoding \s-1URN\s0)" 4 .IX Item "encoding(encoding URN)" .Vb 1 \& $client\->encoding($soap_12_encoding_URN); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->encoding(args); .Ve .Sp Where the earlier method dealt with the label used for the attributes related to the \s-1SOAP\s0 encoding scheme, this method actually sets the \s-1URN\s0 to be specified as the encoding scheme for the message. The default is to specify the encoding for \s-1SOAP 1.1,\s0 so this is handy for applications that need to encode according to \s-1SOAP 1.2\s0 rules. .IP "typelookup" 4 .IX Item "typelookup" .Vb 1 \& $client\->typelookup; .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->typelookup; .Ve .Sp Gives the application access to the type-lookup table from the serializer object. See the section on SOAP::Serializer. .IP "uri(service specifier)" 4 .IX Item "uri(service specifier)" Deprecated \- the \f(CW\*(C`uri\*(C'\fR subroutine is deprecated in order to provide a more intuitive naming scheme for subroutines that set namespaces. In the future, you will be required to use either the \f(CW\*(C`ns()\*(C'\fR or \f(CW\*(C`default_ns()\*(C'\fR subroutines instead of \f(CW\*(C`uri()\*(C'\fR. .Sp .Vb 1 \& $client\->uri($service_uri); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->uri(service); .Ve .Sp The \s-1URI\s0 associated with this accessor on a client object is the service-specifier for the request, often encoded for HTTP-based requests as the SOAPAction header. While the names may seem confusing, this method doesn't specify the endpoint itself. In most circumstances, the \f(CW\*(C`uri\*(C'\fR refers to the namespace used for the request. .Sp Often times, the value may look like a valid \s-1URL.\s0 Despite this, it doesn't have to point to an existing resource (and often doesn't). This method sets and retrieves this value from the object. Note that no transport code is triggered by this because it has no direct effect on the transport of the object. .IP "multirefinplace(boolean)" 4 .IX Item "multirefinplace(boolean)" .Vb 1 \& $client\->multirefinplace(1); .Ve .Sp This method is a shortcut for: .Sp .Vb 1 \& $client\->serializer\->multirefinplace(boolean); .Ve .Sp Controls how the serializer handles values that have multiple references to them. Recall from previous \s-1SOAP\s0 chapters that a value may be tagged with an identifier, then referred to in several places. When this is the case for a value, the serializer defaults to putting the data element towards the top of the message, right after the opening tag of the method-specification. It is serialized as a standalone entity with an \s-1ID\s0 that is then referenced at the relevant places later on. If this method is used to set a true value, the behavior is different. When the multirefinplace attribute is true, the data is serialized at the first place that references it, rather than as a separate element higher up in the body. This is more compact but may be harder to read or trace in a debugging environment. .IP "parts( \s-1ARRAY\s0 )" 4 .IX Item "parts( ARRAY )" Used to specify an array of MIME::Entity's to be attached to the transmitted \s-1SOAP\s0 message. Attachments that are returned in a response can be accessed by \f(CW\*(C`SOAP::SOM::parts()\*(C'\fR. .IP "self" 4 .IX Item "self" .Vb 1 \& $ref = SOAP::Lite\->self; .Ve .Sp Returns an object reference to the default global object the \f(CW\*(C`SOAP::Lite\*(C'\fR package maintains. This is the object that processes many of the arguments when provided on the use line. .PP The following method isn't an accessor style of method but neither does it fit with the group that immediately follows it: .IP "call(arguments)" 4 .IX Item "call(arguments)" .Vb 1 \& $client\->call($method => @arguments); .Ve .Sp As has been illustrated in previous chapters, the \f(CW\*(C`SOAP::Lite\*(C'\fR 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. .PP The next four methods used in the \f(CW\*(C`SOAP::Lite\*(C'\fR 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: .IP "on_action(callback)" 4 .IX Item "on_action(callback)" .Vb 1 \& $client\->on_action(sub { qq("$_[0]") }); .Ve .Sp Triggered when the transport object sets up the SOAPAction header for an HTTP-based call. The default is to set the header to the string, uri#method, in which \s-1URI\s0 is the value set by the uri method described earlier, and method is the name of the method being called. When called, the routine referenced (or the closure, if specified as in the example) is given two arguments, uri and method, in that order. .Sp \&.NET web services usually expect \f(CW\*(C`/\*(C'\fR as separator for \f(CW\*(C`uri\*(C'\fR and \f(CW\*(C`method\*(C'\fR. To change SOAP::Lite's behaviour to use uri/method as SOAPAction header, use the following code: .Sp .Vb 1 \& $client\->on_action( sub { join \*(Aq/\*(Aq, @_ } ); .Ve .IP "on_fault(callback)" 4 .IX Item "on_fault(callback)" .Vb 1 \& $client\->on_fault(sub { popup_dialog($_[1]) }); .Ve .Sp Triggered when a method call results in a fault response from the server. When it is called, the argument list is first the client object itself, followed by the object that encapsulates the fault. In the example, the fault object is passed (without the client object) to a hypothetical \s-1GUI\s0 function that presents an error dialog with the text of fault extracted from the object (which is covered shortly under the \s-1SOAP::SOM\s0 methods). .IP "on_nonserialized(callback)" 4 .IX Item "on_nonserialized(callback)" .Vb 1 \& $client\->on_nonserialized(sub { die "$_[0]?!?" }); .Ve .Sp Occasionally, the serializer may be given data it can't turn into SOAP-savvy \&\s-1XML\s0; for example, if a program bug results in a code reference or something similar being passed in as a parameter to method call. When that happens, this callback is activated, with one argument. That argument is the data item that could not be understood. It will be the only argument. If the routine returns, the return value is pasted into the message as the serialization. Generally, an error is in order, and this callback allows for control over signaling that error. .IP "on_debug(callback)" 4 .IX Item "on_debug(callback)" .Vb 1 \& $client\->on_debug(sub { print @_ }); .Ve .Sp Deprecated. Use the global +debug and +trace facilities described in SOAP::Trace .Sp Note that this method will not work as expected: Instead of affecting the debugging behaviour of the object called on, it will globally affect the debugging behaviour for all objects of that class. .SH "WRITING A SOAP CLIENT" .IX Header "WRITING A SOAP CLIENT" This chapter guides you to writing a \s-1SOAP\s0 client by example. .PP The \s-1SOAP\s0 service to be accessed is a simple variation of the well-known hello world program. It accepts two parameters, a name and a given name, and returns \*(L"Hello \f(CW$given_name\fR \f(CW$name\fR\*(R". .PP We will use \*(L"Martin Kutter\*(R" as the name for the call, so all variants will print the following message on success: .PP .Vb 1 \& Hello Martin Kutter! .Ve .SS "\s-1SOAP\s0 message styles" .IX Subsection "SOAP message styles" There are three common (and one less common) variants of \s-1SOAP\s0 messages. .PP These address the message style (positional parameters vs. specified message documents) and encoding (as-is vs. typed). .PP The different message styles are: .IP "\(bu" 4 rpc/encoded .Sp 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 \s-1SOAP\s0 encoding rules (or others). .IP "\(bu" 4 rpc/literal .Sp As-is, positional parameters. The type of arguments is defined by some pre-exchanged interface definition. .IP "\(bu" 4 document/encoded .Sp Specified message with typed elements. Rarely used. .IP "\(bu" 4 document/literal .Sp Specified message with as-is elements. The message specification and element types are defined by some pre-exchanged interface definition. .PP As of 2008, document/literal has become the predominant \s-1SOAP\s0 message variant. rpc/literal and rpc/encoded are still in use, mainly with scripting languages, while document/encoded is hardly used at all. .PP You will see clients for the rpc/encoded and document/literal \s-1SOAP\s0 variants in this section. .SS "Example implementations" .IX Subsection "Example implementations" \fI\s-1RPC/ENCODED\s0\fR .IX Subsection "RPC/ENCODED" .PP Rpc/encoded is most popular with scripting languages like perl, php and python without the use of a \s-1WSDL.\s0 Usual method descriptions look like this: .PP .Vb 4 \& Method: sayHello(string, string) \& Parameters: \& name: string \& givenName: string .Ve .PP Such a description usually means that you can call a method named \*(L"sayHello\*(R" with two positional parameters, \*(L"name\*(R" and \*(L"givenName\*(R", which both are strings. .PP The message corresponding to this description looks somewhat like this: .PP .Vb 4 \& \& Kutter \& Martin \& .Ve .PP Any \s-1XML\s0 tag names may be used instead of the \*(L"s\-gensym01\*(R" stuff \- parameters are positional, the tag names have no meaning. .PP A client producing such a call is implemented like this: .PP .Vb 6 \& use SOAP::Lite; \& my $soap = SOAP::Lite\->new( proxy => \*(Aqhttp://localhost:81/soap\-wsdl\-test/helloworld.pl\*(Aq); \& $soap\->default_ns(\*(Aqurn:HelloWorld\*(Aq); \& my $som = $soap\->call(\*(AqsayHello\*(Aq, \*(AqKutter\*(Aq, \*(AqMartin\*(Aq); \& die $som\->faultstring if ($som\->fault); \& print $som\->result, "\en"; .Ve .PP You can of course use a one-liner, too... .PP Sometimes, rpc/encoded interfaces are described with \s-1WSDL\s0 definitions. A \s-1WSDL\s0 accepting \*(L"named\*(R" parameters with rpc/encoded looks like this: .PP .Vb 10 \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& .Ve .PP The message corresponding to this schema looks like this: .PP .Vb 4 \& \& Kutter \& Martin \& .Ve .PP A web service client using this schema looks like this: .PP .Vb 7 \& use SOAP::Lite; \& my $soap = SOAP::Lite\->service("file:say_hello_rpcenc.wsdl"); \& eval { my $result = $soap\->sayHello(\*(AqKutter\*(Aq, \*(AqMartin\*(Aq); }; \& if ($@) { \& die $@; \& } \& print $som\->result(); .Ve .PP You may of course also use the following one-liner: .PP .Vb 2 \& perl \-MSOAP::Lite \-e \*(Aqprint SOAP::Lite\->service("file:say_hello_rpcenc.wsdl")\e \& \->sayHello(\*(AqKutter\*(Aq, \*(AqMartin\*(Aq), "\en";\*(Aq .Ve .PP A web service client (without a service description) looks like this. .PP .Vb 9 \& use SOAP::Lite; \& my $soap = SOAP::Lite\->new( proxy => \*(Aqhttp://localhost:81/soap\-wsdl\-test/helloworld.pl\*(Aq); \& $soap\->default_ns(\*(Aqurn:HelloWorld\*(Aq); \& my $som = $soap\->call(\*(AqsayHello\*(Aq, \& SOAP::Data\->name(\*(Aqname\*(Aq)\->value(\*(AqKutter\*(Aq), \& SOAP::Data\->name(\*(AqgivenName\*(Aq)\->value(\*(AqMartin\*(Aq) \& ); \& die $som\->faultstring if ($som\->fault); \& print $som\->result, "\en"; .Ve .PP \fI\s-1RPC/LITERAL\s0\fR .IX Subsection "RPC/LITERAL" .PP \&\s-1SOAP\s0 web services using the document/literal message encoding are usually described by some Web Service Definition. Our web service has the following \&\s-1WSDL\s0 description: .PP .Vb 10 \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& .Ve .PP The \s-1XML\s0 message (inside the \s-1SOAP\s0 Envelope) look like this: .PP .Vb 6 \& \& \& Kutter \& Martin \& \& \& \& \& \& Hello Martin Kutter! \& \& .Ve .PP This is the SOAP::Lite implementation for the web service client: .PP .Vb 2 \& use SOAP::Lite +trace; \& my $soap = SOAP::Lite\->new( proxy => \*(Aqhttp://localhost:80/helloworld.pl\*(Aq); \& \& $soap\->on_action( sub { "urn:HelloWorld#sayHello" }); \& $soap\->autotype(0)\->readable(1); \& $soap\->default_ns(\*(Aqurn:HelloWorld\*(Aq); \& \& my $som = $soap\->call(\*(AqsayHello\*(Aq, SOAP::Data\->name(\*(Aqparameters\*(Aq)\->value( \& \eSOAP::Data\->value([ \& SOAP::Data\->name(\*(Aqname\*(Aq)\->value( \*(AqKutter\*(Aq ), \& SOAP::Data\->name(\*(AqgivenName\*(Aq)\->value(\*(AqMartin\*(Aq), \& ])) \&); \& \& die $som\->fault\->{ faultstring } if ($som\->fault); \& print $som\->result, "\en"; .Ve .PP \fI\s-1DOCUMENT/LITERAL\s0\fR .IX Subsection "DOCUMENT/LITERAL" .PP \&\s-1SOAP\s0 web services using the document/literal message encoding are usually described by some Web Service Definition. Our web service has the following \&\s-1WSDL\s0 description: .PP .Vb 10 \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& \& .Ve .PP The \s-1XML\s0 message (inside the \s-1SOAP\s0 Envelope) look like this: .PP .Vb 4 \& \& Kutter \& Martin \& \& \& \& Hello Martin Kutter! \& .Ve .PP You can call this web service with the following client code: .PP .Vb 2 \& use SOAP::Lite; \& my $soap = SOAP::Lite\->new( proxy => \*(Aqhttp://localhost:80/helloworld.pl\*(Aq); \& \& $soap\->on_action( sub { "urn:HelloWorld#sayHello" }); \& $soap\->autotype(0); \& $soap\->default_ns(\*(Aqurn:HelloWorld\*(Aq); \& \& my $som = $soap\->call("sayHello", \& SOAP::Data\->name(\*(Aqname\*(Aq)\->value( \*(AqKutter\*(Aq ), \& SOAP::Data\->name(\*(AqgivenName\*(Aq)\->value(\*(AqMartin\*(Aq), \&); \& \& die $som\->fault\->{ faultstring } if ($som\->fault); \& print $som\->result, "\en"; .Ve .SS "Differences between the implementations" .IX Subsection "Differences between the implementations" You may have noticed that there's little difference between the rpc/encoded, rpc/literal and the document/literal example's implementation. In fact, from SOAP::Lite's point of view, the only differences between rpc/literal and document/literal that parameters are always named. .PP In our example, the rpc/encoded variant already used named parameters (by using two messages), so there's no difference at all. .PP You may have noticed the somewhat strange idiom for passing a list of named parameters in the rpc/literal example: .PP .Vb 6 \& my $som = $soap\->call(\*(AqsayHello\*(Aq, SOAP::Data\->name(\*(Aqparameters\*(Aq)\->value( \& \eSOAP::Data\->value([ \& SOAP::Data\->name(\*(Aqname\*(Aq)\->value( \*(AqKutter\*(Aq ), \& SOAP::Data\->name(\*(AqgivenName\*(Aq)\->value(\*(AqMartin\*(Aq), \& ])) \& ); .Ve .PP While SOAP::Data provides full control over the \s-1XML\s0 generated, passing hash-like structures require additional coding. .SH "WRITING A SOAP SERVER" .IX Header "WRITING A SOAP SERVER" See SOAP::Server, or SOAP::Transport. .SH "FEATURES" .IX Header "FEATURES" .SS "\s-1ATTACHMENTS\s0" .IX Subsection "ATTACHMENTS" \&\f(CW\*(C`SOAP::Lite\*(C'\fR features support for the \s-1SOAP\s0 with Attachments specification. Currently, SOAP::Lite only supports \s-1MIME\s0 based attachments. \s-1DIME\s0 based attachments are yet to be fully functional. .PP \fI\s-1EXAMPLES\s0\fR .IX Subsection "EXAMPLES" .PP Client sending an attachment .IX Subsection "Client sending an attachment" .PP \&\f(CW\*(C`SOAP::Lite\*(C'\fR clients can specify attachments to be sent along with a request by using the \f(CW\*(C`SOAP::Lite::parts()\*(C'\fR method, which takes as an argument an \&\s-1ARRAY\s0 of \f(CW\*(C`MIME::Entity\*(C'\fR's. .PP .Vb 10 \& use SOAP::Lite; \& use MIME::Entity; \& my $ent = build MIME::Entity \& Type => "image/gif", \& Encoding => "base64", \& Path => "somefile.gif", \& Filename => "saveme.gif", \& Disposition => "attachment"; \& my $som = SOAP::Lite \& \->uri($SOME_NAMESPACE) \& \->parts([ $ent ]) \& \->proxy($SOME_HOST) \& \->some_method(SOAP::Data\->name("foo" => "bar")); .Ve .PP Client retrieving an attachment .IX Subsection "Client retrieving an attachment" .PP A client accessing attachments that were returned in a response by using the \&\f(CW\*(C`SOAP::SOM::parts()\*(C'\fR accessor. .PP .Vb 9 \& use SOAP::Lite; \& use MIME::Entity; \& my $soap = SOAP::Lite \& \->uri($NS) \& \->proxy($HOST); \& my $som = $soap\->foo(); \& foreach my $part (${$som\->parts}) { \& print $part\->stringify; \& } .Ve .PP Server receiving an attachment .IX Subsection "Server receiving an attachment" .PP Servers, like clients, use the \s-1SOAP::SOM\s0 module to access attachments transmitted to it. .PP .Vb 10 \& package Attachment; \& use SOAP::Lite; \& use MIME::Entity; \& use strict; \& use vars qw(@ISA); \& @ISA = qw(SOAP::Server::Parameters); \& sub someMethod { \& my $self = shift; \& my $envelope = pop; \& foreach my $part (@{$envelope\->parts}) { \& print "AttachmentService: attachment found! (".ref($part).")\en"; \& } \& # do something \& } .Ve .PP Server responding with an attachment .IX Subsection "Server responding with an attachment" .PP Servers wishing to return an attachment to the calling client need only return \&\f(CW\*(C`MIME::Entity\*(C'\fR objects along with SOAP::Data elements, or any other data intended for the response. .PP .Vb 10 \& package Attachment; \& use SOAP::Lite; \& use MIME::Entity; \& use strict; \& use vars qw(@ISA); \& @ISA = qw(SOAP::Server::Parameters); \& sub someMethod { \& my $self = shift; \& my $envelope = pop; \& my $ent = build MIME::Entity \& \*(AqId\*(Aq => "<1234>", \& \*(AqType\*(Aq => "text/xml", \& \*(AqPath\*(Aq => "some.xml", \& \*(AqFilename\*(Aq => "some.xml", \& \*(AqDisposition\*(Aq => "attachment"; \& return SOAP::Data\->name("foo" => "blah blah blah"),$ent; \& } .Ve .SS "\s-1DEFAULT SETTINGS\s0" .IX Subsection "DEFAULT SETTINGS" Though this feature looks similar to autodispatch they have (almost) nothing in common. This capability allows you specify default settings so that all objects created after that will be initialized with the proper default settings. .PP If you wish to provide common \f(CW\*(C`proxy()\*(C'\fR or \f(CW\*(C`uri()\*(C'\fR settings for all \&\f(CW\*(C`SOAP::Lite\*(C'\fR objects in your application you may do: .PP .Vb 3 \& use SOAP::Lite \& proxy => \*(Aqhttp://localhost/cgi\-bin/soap.cgi\*(Aq, \& uri => \*(Aqhttp://my.own.com/My/Examples\*(Aq; \& \& my $soap1 = new SOAP::Lite; # will get the same proxy()/uri() as above \& print $soap1\->getStateName(1)\->result; \& \& my $soap2 = SOAP::Lite\->new; # same thing as above \& print $soap2\->getStateName(2)\->result; \& \& # or you may override any settings you want \& my $soap3 = SOAP::Lite\->proxy(\*(Aqhttp://localhost/\*(Aq); \& print $soap3\->getStateName(1)\->result; .Ve .PP \&\fBAny\fR \f(CW\*(C`SOAP::Lite\*(C'\fR properties can be propagated this way. Changes in object copies will not affect global settings and you may still change global settings with \f(CW\*(C`SOAP::Lite\->self\*(C'\fR call which returns reference to global object. Provided parameter will update this object and you can even set it to \&\f(CW\*(C`undef\*(C'\fR: .PP .Vb 1 \& SOAP::Lite\->self(undef); .Ve .PP The \f(CW\*(C`use SOAP::Lite\*(C'\fR syntax also lets you specify default event handlers for your code. If you have different \s-1SOAP\s0 objects and want to share the same \&\f(CW\*(C`on_action()\*(C'\fR (or \f(CW\*(C`on_fault()\*(C'\fR for that matter) handler. You can specify \&\f(CW\*(C`on_action()\*(C'\fR during initialization for every object, but you may also do: .PP .Vb 2 \& use SOAP::Lite \& on_action => sub {sprintf \*(Aq%s#%s\*(Aq, @_}; .Ve .PP and this handler will be the default handler for all your \s-1SOAP\s0 objects. You can override it if you specify a handler for a particular object. See \fIt/*.t\fR for example of \fBon_fault()\fR handler. .PP Be warned, that since \f(CW\*(C`use ...\*(C'\fR is executed at compile time \fBall\fR \f(CW\*(C`use\*(C'\fR statements will be executed \fBbefore\fR script execution that can make unexpected results. Consider code: .PP .Vb 2 \& use SOAP::Lite proxy => \*(Aqhttp://localhost/\*(Aq; \& print SOAP::Lite\->getStateName(1)\->result; \& \& use SOAP::Lite proxy => \*(Aqhttp://localhost/cgi\-bin/soap.cgi\*(Aq; \& print SOAP::Lite\->getStateName(1)\->result; .Ve .PP \&\fBBoth\fR \s-1SOAP\s0 calls will go to \f(CW\*(Aqhttp://localhost/cgi\-bin/soap.cgi\*(Aq\fR. If you want to execute \f(CW\*(C`use\*(C'\fR at run-time, put it in \f(CW\*(C`eval\*(C'\fR: .PP .Vb 1 \& eval "use SOAP::Lite proxy => \*(Aqhttp://localhost/cgi\-bin/soap.cgi\*(Aq; 1" or die; .Ve .PP Or alternatively, .PP .Vb 1 \& SOAP::Lite\->self\->proxy(\*(Aqhttp://localhost/cgi\-bin/soap.cgi\*(Aq); .Ve .SS "\s-1SETTING MAXIMUM MESSAGE SIZE\s0" .IX Subsection "SETTING MAXIMUM MESSAGE SIZE" One feature of \f(CW\*(C`SOAP::Lite\*(C'\fR is the ability to control the maximum size of a message a SOAP::Lite server will be allowed to process. To control this feature simply define \f(CW$SOAP::Constants::MAX_CONTENT_SIZE\fR in your code like so: .PP .Vb 6 \& use SOAP::Transport::HTTP; \& use MIME::Entity; \& $SOAP::Constants::MAX_CONTENT_SIZE = 10000; \& SOAP::Transport::HTTP::CGI \& \->dispatch_to(\*(AqTemperatureService\*(Aq) \& \->handle; .Ve .SS "\s-1IN/OUT, OUT PARAMETERS AND AUTOBINDING\s0" .IX Subsection "IN/OUT, OUT PARAMETERS AND AUTOBINDING" \&\f(CW\*(C`SOAP::Lite\*(C'\fR gives you access to all parameters (both in/out and out) and also does some additional work for you. Lets consider following example: .PP .Vb 5 \& \& name1 \& name2 \& name3 \& .Ve .PP In that case: .PP .Vb 4 \& $result = $r\->result; # gives you \*(Aqname1\*(Aq \& $paramout1 = $r\->paramsout; # gives you \*(Aqname2\*(Aq, because of scalar context \& $paramout1 = ($r\->paramsout)[0]; # gives you \*(Aqname2\*(Aq also \& $paramout2 = ($r\->paramsout)[1]; # gives you \*(Aqname3\*(Aq .Ve .PP or .PP .Vb 3 \& @paramsout = $r\->paramsout; # gives you ARRAY of out parameters \& $paramout1 = $paramsout[0]; # gives you \*(Aqres2\*(Aq, same as ($r\->paramsout)[0] \& $paramout2 = $paramsout[1]; # gives you \*(Aqres3\*(Aq, same as ($r\->paramsout)[1] .Ve .PP Generally, if server returns \f(CW\*(C`return (1,2,3)\*(C'\fR you will get \f(CW1\fR as the result and \f(CW2\fR and \f(CW3\fR as out parameters. .PP If the server returns \f(CW\*(C`return [1,2,3]\*(C'\fR you will get an \s-1ARRAY\s0 reference from \&\f(CW\*(C`result()\*(C'\fR and \f(CW\*(C`undef\*(C'\fR from \f(CW\*(C`paramsout()\*(C'\fR. .PP Results can be arbitrary complex: they can be an array references, they can be objects, they can be anything and still be returned by \f(CW\*(C`result()\*(C'\fR . If only one parameter is returned, \f(CW\*(C`paramsout()\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR. .PP Furthermore, if you have in your output parameters a parameter with the same signature (name+type) as in the input parameters this parameter will be mapped into your input automatically. For example: .PP \&\fBServer Code\fR: .PP .Vb 6 \& sub mymethod { \& shift; # object/class reference \& my $param1 = shift; \& my $param2 = SOAP::Data\->name(\*(Aqmyparam\*(Aq => shift() * 2); \& return $param1, $param2; \& } .Ve .PP \&\fBClient Code\fR: .PP .Vb 3 \& $a = 10; \& $b = SOAP::Data\->name(\*(Aqmyparam\*(Aq => 12); \& $result = $soap\->mymethod($a, $b); .Ve .PP After that, \f(CW\*(C`$result == 10 and $b\->value == 24\*(C'\fR! Magic? Sort of. .PP Autobinding gives it to you. That will work with objects also with one difference: you do not need to worry about the name and the type of object parameter. Consider the \f(CW\*(C`PingPong\*(C'\fR example (\fIexamples/My/PingPong.pm\fR and \fIexamples/pingpong.pl\fR): .PP \&\fBServer Code\fR: .PP .Vb 1 \& package My::PingPong; \& \& sub new { \& my $self = shift; \& my $class = ref($self) || $self; \& bless {_num=>shift} => $class; \& } \& \& sub next { \& my $self = shift; \& $self\->{_num}++; \& } .Ve .PP \&\fBClient Code\fR: .PP .Vb 3 \& use SOAP::Lite +autodispatch => \& uri => \*(Aqurn:\*(Aq, \& proxy => \*(Aqhttp://localhost/\*(Aq; \& \& my $p = My::PingPong\->new(10); # $p\->{_num} is 10 now, real object returned \& print $p\->next, "\en"; # $p\->{_num} is 11 now!, object autobinded .Ve .SS "\s-1STATIC AND DYNAMIC SERVICE DEPLOYMENT\s0" .IX Subsection "STATIC AND DYNAMIC SERVICE DEPLOYMENT" Let us scrutinize the deployment process. When designing your \s-1SOAP\s0 server you can consider two kind of deployment: \fBstatic\fR and \fBdynamic\fR. For both, static and dynamic, you should specify \f(CW\*(C`MODULE\*(C'\fR, \f(CW\*(C`MODULE::method\*(C'\fR, \&\f(CW\*(C`method\*(C'\fR or \f(CW\*(C`PATH/\*(C'\fR when creating \f(CW\*(C`use\*(C'\fRing the SOAP::Lite module. The difference between static and dynamic deployment is that in case of 'dynamic', any module which is not present will be loaded on demand. See the \&\*(L"\s-1SECURITY\*(R"\s0 section for detailed description. .PP When statically deploying a \s-1SOAP\s0 Server, you need to know all modules handling \&\s-1SOAP\s0 requests before. .PP Dynamic deployment allows extending your \s-1SOAP\s0 Server's interface by just installing another module into the dispatch_to path (see below). .PP \fI\s-1STATIC DEPLOYMENT EXAMPLE\s0\fR .IX Subsection "STATIC DEPLOYMENT EXAMPLE" .PP .Vb 2 \& use SOAP::Transport::HTTP; \& use My::Examples; # module is preloaded \& \& SOAP::Transport::HTTP::CGI \& # deployed module should be present here or client will get \& # \*(Aqaccess denied\*(Aq \& \-> dispatch_to(\*(AqMy::Examples\*(Aq) \& \-> handle; .Ve .PP For static deployment you should specify the \s-1MODULE\s0 name directly. .PP You should also use static binding when you have several different classes in one file and want to make them available for \s-1SOAP\s0 calls. .PP \fI\s-1DYNAMIC DEPLOYMENT EXAMPLE\s0\fR .IX Subsection "DYNAMIC DEPLOYMENT EXAMPLE" .PP .Vb 2 \& use SOAP::Transport::HTTP; \& # name is unknown, module will be loaded on demand \& \& SOAP::Transport::HTTP::CGI \& # deployed module should be present here or client will get \*(Aqaccess denied\*(Aq \& \-> dispatch_to(\*(Aq/Your/Path/To/Deployed/Modules\*(Aq, \*(AqMy::Examples\*(Aq) \& \-> handle; .Ve .PP For dynamic deployment you can specify the name either directly (in that case it will be \f(CW\*(C`require\*(C'\fRd without any restriction) or indirectly, with a \s-1PATH.\s0 In that case, the \s-1ONLY\s0 path that will be available will be the \s-1PATH\s0 given to the \&\fBdispatch_to()\fR method). For information how to handle this situation see \&\*(L"\s-1SECURITY\*(R"\s0 section. .PP \fI\s-1SUMMARY\s0\fR .IX Subsection "SUMMARY" .PP .Vb 6 \& dispatch_to( \& # dynamic dispatch that allows access to ALL modules in specified directory \& PATH/TO/MODULES \& # 1. specifies directory \& # \-\- AND \-\- \& # 2. gives access to ALL modules in this directory without limits \& \& # static dispatch that allows access to ALL methods in particular MODULE \& MODULE \& # 1. gives access to particular module (all available methods) \& # PREREQUISITES: \& # module should be loaded manually (for example with \*(Aquse ...\*(Aq) \& # \-\- OR \-\- \& # you can still specify it in PATH/TO/MODULES \& \& # static dispatch that allows access to particular method ONLY \& MODULE::method \& # same as MODULE, but gives access to ONLY particular method, \& # so there is not much sense to use both MODULE and MODULE::method \& # for the same MODULE \& ); .Ve .PP In addition to this \f(CW\*(C`SOAP::Lite\*(C'\fR also supports an experimental syntax that allows you to bind a specific \s-1URL\s0 or SOAPAction to a \s-1CLASS/MODULE\s0 or object. .PP For example: .PP .Vb 5 \& dispatch_with({ \& URI => MODULE, # \*(Aqhttp://www.soaplite.com/\*(Aq => \*(AqMy::Class\*(Aq, \& SOAPAction => MODULE, # \*(Aqhttp://www.soaplite.com/method\*(Aq => \*(AqAnother::Class\*(Aq, \& URI => object, # \*(Aqhttp://www.soaplite.com/obj\*(Aq => My::Class\->new, \& }) .Ve .PP \&\f(CW\*(C`URI\*(C'\fR is checked before \f(CW\*(C`SOAPAction\*(C'\fR. You may use both the \f(CW\*(C`dispatch_to()\*(C'\fR and \f(CW\*(C`dispatch_with()\*(C'\fR methods in the same server, but note that \&\f(CW\*(C`dispatch_with()\*(C'\fR has a higher order of precedence. \f(CW\*(C`dispatch_to()\*(C'\fR will be checked only after \f(CW\*(C`URI\*(C'\fR and \f(CW\*(C`SOAPAction\*(C'\fR has been checked. .PP See also: \&\s-1EXAMPLE APACHE::REGISTRY USAGE\s0, \&\*(L"\s-1SECURITY\*(R"\s0 .SS "\s-1COMPRESSION\s0" .IX Subsection "COMPRESSION" \&\f(CW\*(C`SOAP::Lite\*(C'\fR provides you option to enable transparent compression over the wire. Compression can be enabled by specifying a threshold value (in the form of kilobytes) for compression on both the client and server sides: .PP \&\fINote: Compression currently only works for \s-1HTTP\s0 based servers and clients.\fR .PP \&\fBClient Code\fR .PP .Vb 5 \& print SOAP::Lite \& \->uri(\*(Aqhttp://localhost/My/Parameters\*(Aq) \& \->proxy(\*(Aqhttp://localhost/\*(Aq, options => {compress_threshold => 10000}) \& \->echo(1 x 10000) \& \->result; .Ve .PP \&\fBServer Code\fR .PP .Vb 4 \& my $server = SOAP::Transport::HTTP::CGI \& \->dispatch_to(\*(AqMy::Parameters\*(Aq) \& \->options({compress_threshold => 10000}) \& \->handle; .Ve .PP For more information see \s-1COMPRESSION\s0 in HTTP::Transport. .SH "SECURITY" .IX Header "SECURITY" For security reasons, the existing path for Perl modules (\f(CW@INC\fR) will be disabled once you have chosen dynamic deployment and specified your own \&\f(CW\*(C`PATH/\*(C'\fR. If you wish to access other modules in your included package you have several options: .IP "1." 4 Switch to static linking: .Sp .Vb 2 \& use MODULE; \& $server\->dispatch_to(\*(AqMODULE\*(Aq); .Ve .Sp Which can also be useful when you want to import something specific from the deployed modules: .Sp .Vb 1 \& use MODULE qw(import_list); .Ve .IP "2." 4 Change \f(CW\*(C`use\*(C'\fR to \f(CW\*(C`require\*(C'\fR. The path is only unavailable during the initialization phase. It is available once more during execution. Therefore, if you utilize \f(CW\*(C`require\*(C'\fR somewhere in your package, it will work. .IP "3." 4 Wrap \f(CW\*(C`use\*(C'\fR in an \f(CW\*(C`eval\*(C'\fR block: .Sp .Vb 1 \& eval \*(Aquse MODULE qw(import_list)\*(Aq; die if $@; .Ve .IP "4." 4 Set your include path in your package and then specify \f(CW\*(C`use\*(C'\fR. Don't forget to put \f(CW@INC\fR in a \f(CW\*(C`BEGIN{}\*(C'\fR block or it won't work. For example, .Sp .Vb 1 \& BEGIN { @INC = qw(my_directory); use MODULE } .Ve .SH "INTEROPERABILITY" .IX Header "INTEROPERABILITY" .SS "Microsoft .NET client with SOAP::Lite Server" .IX Subsection "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: .PP .Vb 4 \& return SOAP::Data\->name(\*(Aqmyname\*(Aq) \& \->type(\*(Aqstring\*(Aq) \& \->uri($MY_NAMESPACE) \& \->value($output); .Ve .PP In addition see comment about default encoding in .NET Web Services below. .SS "SOAP::Lite client with a .NET server" .IX Subsection "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: .IP "Declare a proper soapAction in your call" 4 .IX Item "Declare a proper soapAction in your call" For example, use \&\f(CW\*(C`on_action( sub { \*(Aqhttp://www.myuri.com/WebService.aspx#someMethod\*(Aq; } )\*(C'\fR. .IP "Disable charset definition in Content-type header" 4 .IX Item "Disable charset definition in Content-type header" Some users have said that Microsoft .NET prefers the value of the Content-type header to be a mimetype exclusively, but SOAP::Lite specifies a character set in addition to the mimetype. This results in an error similar to: .Sp .Vb 2 \& Server found request content type to be \*(Aqtext/xml; charset=utf\-8\*(Aq, \& but expected \*(Aqtext/xml\*(Aq .Ve .Sp To turn off this behavior specify use the following code: .Sp .Vb 3 \& use SOAP::Lite; \& $SOAP::Constants::DO_NOT_USE_CHARSET = 1; \& # The rest of your code .Ve .IP "Use fully qualified name for method parameters" 4 .IX Item "Use fully qualified name for method parameters" For example, the following code is preferred: .Sp .Vb 2 \& SOAP::Data\->name(Query => \*(Aqbiztalk\*(Aq) \& \->uri(\*(Aqhttp://tempuri.org/\*(Aq) .Ve .Sp As opposed to: .Sp .Vb 1 \& SOAP::Data\->name(\*(AqQuery\*(Aq => \*(Aqbiztalk\*(Aq) .Ve .IP "Place method in default namespace" 4 .IX Item "Place method in default namespace" For example, the following code is preferred: .Sp .Vb 3 \& my $method = SOAP::Data\->name(\*(Aqadd\*(Aq) \& \->attr({xmlns => \*(Aqhttp://tempuri.org/\*(Aq}); \& my @rc = $soap\->call($method => @parms)\->result; .Ve .Sp As opposed to: .Sp .Vb 3 \& my @rc = $soap\->call(add => @parms)\->result; \& # \-\- OR \-\- \& my @rc = $soap\->add(@parms)\->result; .Ve .IP "Disable use of explicit namespace prefixes" 4 .IX Item "Disable use of explicit namespace prefixes" Some user's have reported that .NET will simply not parse messages that use namespace prefixes on anything but \s-1SOAP\s0 elements themselves. For example, the following \s-1XML\s0 would not be parsed: .Sp .Vb 5 \& \& \& \& \& .Ve .Sp SOAP::Lite allows users to disable the use of explicit namespaces through the \&\f(CW\*(C`use_prefix()\*(C'\fR method. For example, the following code: .Sp .Vb 4 \& $som = SOAP::Lite\->uri(\*(Aqurn:MyURI\*(Aq) \& \->proxy($HOST) \& \->use_prefix(0) \& \->myMethod(); .Ve .Sp Will result in the following \s-1XML,\s0 which is more palatable by .NET: .Sp .Vb 5 \& \& \& \& \& .Ve .IP "Modify your .NET server, if possible" 4 .IX Item "Modify your .NET server, if possible" Stefan Pharies : .Sp SOAP::Lite uses the \s-1SOAP\s0 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): .Sp .Vb 1 \& [SoapService(Style=SoapServiceStyle.RPC)] .Ve .Sp Another source said it might be this attribute (for Beta 2): .Sp .Vb 1 \& [SoapRpcService] .Ve .Sp Full Web Service text may look like: .Sp .Vb 4 \& <%@ WebService Language="C#" Class="Test" %> \& using System; \& using System.Web.Services; \& using System.Xml.Serialization; \& \& [SoapService(Style=SoapServiceStyle.RPC)] \& public class Test : WebService { \& [WebMethod] \& public int add(int a, int b) { \& return a + b; \& } \& } .Ve .Sp Another example from Kirill Gavrylyuk : .Sp \&\*(L"You can insert [\fBSoapRpcService()\fR] attribute either on your class or on operation level\*(R". .Sp .Vb 1 \& <%@ WebService Language=CS class="DataType.StringTest"%> \& \& namespace DataType { \& \& using System; \& using System.Web.Services; \& using System.Web.Services.Protocols; \& using System.Web.Services.Description; \& \& [SoapRpcService()] \& public class StringTest: WebService { \& [WebMethod] \& [SoapRpcMethod()] \& public string RetString(string x) { \& return(x); \& } \& } \& } .Ve .Sp Example from Yann Christensen : .Sp .Vb 3 \& using System; \& using System.Web.Services; \& using System.Web.Services.Protocols; \& \& namespace Currency { \& [WebService(Namespace="http://www.yourdomain.com/example")] \& [SoapRpcService] \& public class Exchange { \& [WebMethod] \& public double getRate(String country, String country2) { \& return 122.69; \& } \& } \& } .Ve .PP Special thanks goes to the following people for providing the above description and details on .NET interoperability issues: .PP Petr Janata , .PP Stefan Pharies , .PP Brian Jepson , and others .SH "TROUBLESHOOTING" .IX Header "TROUBLESHOOTING" .ie n .IP "SOAP::Lite serializes ""18373"" as an integer, but I want it to be a string!" 4 .el .IP "SOAP::Lite serializes ``18373'' as an integer, but I want it to be a string!" 4 .IX Item "SOAP::Lite serializes 18373 as an integer, but I want it to be a string!" SOAP::Lite guesses datatypes from the content provided, using a set of common-sense rules. These rules are not 100% reliable, though they fit for most data. .Sp You may force the type by passing a SOAP::Data object with a type specified: .Sp .Vb 4 \& my $proxy = SOAP::Lite\->proxy(\*(Aqhttp://www.example.org/soapservice\*(Aq); \& my $som = $proxy\->myMethod( \& SOAP::Data\->name(\*(Aqfoo\*(Aq)\->value(12345)\->type(\*(Aqstring\*(Aq) \& ); .Ve .Sp You may also change the precedence of the type-guessing rules. Note that this means fiddling with SOAP::Lite's internals \- this may not work as expected in future versions. .Sp The example above forces everything to be encoded as string (this is because the string test is normally last and always returns true): .Sp .Vb 6 \& my @list = qw(\-1 45 foo bar 3838); \& my $proxy = SOAP::Lite\->uri($uri)\->proxy($proxyUrl); \& my $lookup = $proxy\->serializer\->typelookup; \& $lookup\->{string}\->[0] = 0; \& $proxy\->serializer\->typelookup($lookup); \& $proxy\->myMethod(\e@list); .Ve .Sp See SOAP::Serializer for more details. .ie n .IP """+autodispatch"" doesn't work in Perl 5.8" 4 .el .IP "\f(CW+autodispatch\fR doesn't work in Perl 5.8" 4 .IX Item "+autodispatch doesn't work in Perl 5.8" There is a bug in Perl 5.8's \f(CW\*(C`UNIVERSAL::AUTOLOAD\*(C'\fR functionality that prevents the \f(CW\*(C`+autodispatch\*(C'\fR functionality from working properly. The workaround is to use \f(CW\*(C`dispatch_from\*(C'\fR instead. Where you might normally do something like this: .Sp .Vb 4 \& use Some::Module; \& use SOAP::Lite +autodispatch => \& uri => \*(Aqurn:Foo\*(Aq \& proxy => \*(Aqhttp://...\*(Aq; .Ve .Sp You would do something like this: .Sp .Vb 3 \& use SOAP::Lite dispatch_from(Some::Module) => \& uri => \*(Aqurn:Foo\*(Aq \& proxy => \*(Aqhttp://...\*(Aq; .Ve .IP "Problems using SOAP::Lite's \s-1COM\s0 Interface" 4 .IX Item "Problems using SOAP::Lite's COM Interface" .RS 4 .PD 0 .ie n .IP "Can't call method ""server"" on undefined value" 4 .el .IP "Can't call method ``server'' on undefined value" 4 .IX Item "Can't call method server on undefined value" .PD You probably did not register \fILite.dll\fR using \f(CW\*(C`regsvr32 Lite.dll\*(C'\fR .IP "Failed to load PerlCtrl Runtime" 4 .IX Item "Failed to load PerlCtrl Runtime" It is likely that you have install Perl in two different locations and the location of ActiveState's Perl is not the first instance of Perl specified in your \s-1PATH.\s0 To rectify, rename the directory in which the non-ActiveState Perl is installed, or be sure the path to ActiveState's Perl is specified prior to any other instance of Perl in your \s-1PATH.\s0 .RE .RS 4 .RE .IP "Dynamic libraries are not found" 4 .IX Item "Dynamic libraries are not found" If you are using the Apache web server, and you are seeing something like the following in your webserver log file: .Sp .Vb 4 \& Can\*(Aqt load \*(Aq/usr/local/lib/perl5/site_perl/.../XML/Parser/Expat/Expat.so\*(Aq \& for module XML::Parser::Expat: dynamic linker: /usr/local/bin/perl: \& libexpat.so.0 is NEEDED, but object does not exist at \& /usr/local/lib/perl5/.../DynaLoader.pm line 200. .Ve .Sp Then try placing the following into your \fIhttpd.conf\fR file and see if it fixes your problem. .Sp .Vb 3 \& \& PassEnv LD_LIBRARY_PATH \& .Ve .IP "\s-1SOAP\s0 client reports ""500 unexpected \s-1EOF\s0 before status line seen" 4 .IX Item "SOAP client reports ""500 unexpected EOF before status line seen" See \*(L"Apache is crashing with segfaults\*(R" .IP "Apache is crashing with segfaults" 4 .IX Item "Apache is crashing with segfaults" Using \f(CW\*(C`SOAP::Lite\*(C'\fR (or XML::Parser::Expat) in combination with mod_perl causes random segmentation faults in httpd processes. To fix, try configuring Apache with the following: .Sp .Vb 1 \& RULE_EXPAT=no .Ve .Sp If you are using Apache 1.3.20 and later, try configuring Apache with the following option: .Sp .Vb 1 \& ./configure \-\-disable\-rule=EXPAT .Ve .Sp See http://archive.covalent.net/modperl/2000/04/0185.xml for more details and lot of thanks to Robert Barta for explaining this weird behavior. .Sp If this doesn't address the problem, you may wish to try \f(CW\*(C`\-Uusemymalloc\*(C'\fR, or a similar option in order to instruct Perl to use the system's own \f(CW\*(C`malloc\*(C'\fR. .Sp Thanks to Tim Bunce . .IP "\s-1CGI\s0 scripts do not work under Microsoft Internet Information Server (\s-1IIS\s0)" 4 .IX Item "CGI scripts do not work under Microsoft Internet Information Server (IIS)" \&\s-1CGI\s0 scripts may not work under \s-1IIS\s0 unless scripts use the \f(CW\*(C`.pl\*(C'\fR extension, opposed to \f(CW\*(C`.cgi\*(C'\fR. .IP "Java \s-1SAX\s0 parser unable to parse message composed by SOAP::Lite" 4 .IX Item "Java SAX parser unable to parse message composed by SOAP::Lite" In some cases \s-1SOAP\s0 messages created by \f(CW\*(C`SOAP::Lite\*(C'\fR may not be parsed properly by a SAX2/Java \s-1XML\s0 parser. This is due to a known bug in \&\f(CW\*(C`org.xml.sax.helpers.ParserAdapter\*(C'\fR. This bug manifests itself when an attribute in an \s-1XML\s0 element occurs prior to the \s-1XML\s0 namespace declaration on which it depends. However, according to the \s-1XML\s0 specification, the order of these attributes is not significant. .Sp http://www.megginson.com/SAX/index.html .Sp Thanks to Steve Alpert (Steve_Alpert@idx.com) for pointing on it. .SH "PERFORMANCE" .IX Header "PERFORMANCE" .IP "Processing of \s-1XML\s0 encoded fragments" 4 .IX Item "Processing of XML encoded fragments" \&\f(CW\*(C`SOAP::Lite\*(C'\fR is based on XML::Parser which is basically wrapper around James Clark's expat parser. Expat's behavior for parsing \s-1XML\s0 encoded string can affect processing messages that have lot of encoded entities, like \s-1XML\s0 fragments, encoded as strings. Providing low-level details, parser will call \&\fBchar()\fR callback for every portion of processed stream, but individually for every processed entity or newline. It can lead to lot of calls and additional memory manager expenses even for small messages. By contrast, \s-1XML\s0 messages which are encoded as base64Binary, don't have this problem and difference in processing time can be significant. For \s-1XML\s0 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. .Sp Since it is parser's feature there is \s-1NO\s0 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 \fBmay\fR work with other toolkits/implementations also, but obviously I cannot guarantee that. .Sp If you want to encode specific string as base64, just do \&\f(CW\*(C`SOAP::Data\->type(base64 => $string)\*(C'\fR either on client or on server side. If you want change behavior for specific instance of SOAP::Lite, you may subclass \f(CW\*(C`SOAP::Serializer\*(C'\fR, override \f(CW\*(C`as_string()\*(C'\fR method that is responsible for string encoding (take a look into \f(CW\*(C`as_base64Binary()\*(C'\fR) and specify \fBnew\fR serializer class for your SOAP::Lite object with: .Sp .Vb 3 \& my $soap = new SOAP::Lite \& serializer => My::Serializer\->new, \& ..... other parameters .Ve .Sp or on server side: .Sp .Vb 3 \& my $server = new SOAP::Transport::HTTP::Daemon # or any other server \& serializer => My::Serializer\->new, \& ..... other parameters .Ve .Sp If you want to change this behavior for \fBall\fR instances of SOAP::Lite, just substitute \f(CW\*(C`as_string()\*(C'\fR method with \f(CW\*(C`as_base64Binary()\*(C'\fR somewhere in your code \fBafter\fR \f(CW\*(C`use SOAP::Lite\*(C'\fR and \fBbefore\fR actual processing/sending: .Sp .Vb 1 \& *SOAP::Serializer::as_string = \e&SOAP::XMLSchema2001::Serializer::as_base64Binary; .Ve .Sp Be warned that last two methods will affect \fBall\fR strings and convert them into base64 encoded. It doesn't make any difference for SOAP::Lite, but it \&\fBmay\fR make a difference for other toolkits. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" .IP "\(bu" 4 No support for multidimensional, partially transmitted and sparse arrays (however arrays of arrays are supported, as well as any other data structures, and you can add your own implementation with SOAP::Data). .IP "\(bu" 4 Limited support for \s-1WSDL\s0 schema. .IP "\(bu" 4 XML::Parser::Lite relies on Unicode support in Perl and doesn't do entity decoding. .IP "\(bu" 4 Limited support for mustUnderstand and Actor attributes. .SH "PLATFORM SPECIFICS" .IX Header "PLATFORM SPECIFICS" .IP "MacOS" 4 .IX Item "MacOS" Information about XML::Parser for MacPerl could be found here: .Sp http://bumppo.net/lists/macperl\-modules/1999/07/msg00047.html .Sp Compiled XML::Parser for MacOS could be found here: .Sp http://www.perl.com/CPAN\-local/authors/id/A/AS/ASANDSTRM/XML\-Parser\-2.27\-bin\-1\-MacOS.tgz .SH "RELATED MODULES" .IX Header "RELATED MODULES" .SS "Transport Modules" .IX Subsection "Transport Modules" SOAP::Lite allows one to add support for additional transport protocols, or server handlers, via separate modules implementing the SOAP::Transport::* interface. The following modules are available from \s-1CPAN:\s0 .IP "\(bu" 4 SOAP-Transport-HTTP-Nginx .Sp SOAP::Transport::HTTP::Nginx provides a transport module for nginx () .SH "AVAILABILITY" .IX Header "AVAILABILITY" You can download the latest version SOAP::Lite for Unix or SOAP::Lite for Win32 from the following sources: .PP .Vb 1 \& * CPAN: http://search.cpan.org/search?dist=SOAP\-Lite .Ve .PP You are welcome to send e\-mail to the maintainers of SOAP::Lite with your comments, suggestions, bug reports and complaints. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" Special thanks to Randy J. Ray, author of \&\fIProgramming Web Services with Perl\fR, who has contributed greatly to the documentation effort of SOAP::Lite. .PP Special thanks to O'Reilly publishing which has graciously allowed SOAP::Lite to republish and redistribute the SOAP::Lite reference manual found in Appendix B of \fIProgramming Web Services with Perl\fR. .PP And special gratitude to all the developers who have contributed patches, ideas, time, energy, and help in a million different forms to the development of this software. .SH "HACKING" .IX Header "HACKING" Latest development takes place on GitHub.com. Come on by and fork it. .PP git@github.com:redhotpenguin/perl\-soaplite.git .PP Also see the \s-1HACKING\s0 file. .PP Actively recruiting maintainers for this module. Come and get it on! .SH "REPORTING BUGS" .IX Header "REPORTING BUGS" Please use rt.cpan.org or github to report bugs. Pull requests are preferred. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2000\-2007 Paul Kulchenko. All rights reserved. .PP Copyright (C) 2007\-2008 Martin Kutter .PP Copyright (C) 2013 Fred Moyer .SH "LICENSE" .IX Header "LICENSE" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP This text and all associated documentation for this library is made available under the Creative Commons Attribution-NoDerivs 2.0 license. http://creativecommons.org/licenses/by\-nd/2.0/ .SH "AUTHORS" .IX Header "AUTHORS" Paul Kulchenko (paulclinger@yahoo.com) .PP Randy J. Ray (rjray@blackperl.com) .PP Byrne Reese (byrne@majordojo.com) .PP Martin Kutter (martin.kutter@fen\-net.de) .PP Fred Moyer (fred@redhotpenguin.com)