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.

new(optional key/value pairs)

        $client = SOAP::Lite->new(proxy => $endpoint)

    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.
transport(optional transport object)

        $transp = $client->transport( );

    Gets or sets the transport object used for sending/receiving SOAP messages.

    See SOAP::Transport for details.
serializer(optional serializer object)

        $serial = $client->serializer( )

    Gets or sets the serializer object used for creating XML messages.

    See SOAP::Serializer for details.
packager(optional packager object)

        $packager = $client->packager( )

    Provides access to the SOAP::Packager object that the client uses to manage the use of attachments. The default packager is a MIME packager, but unless you specify parts to send, no MIME formatting will be done.

    See also: SOAP::Packager.
proxy(endpoint, optional extra arguments)

        $client->proxy(' endPoint');

    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.

    This method is actually an alias to the proxy method of SOAP::Transport. It is the same as typing:

        $client->transport( )->proxy(...arguments);

    Extra parameters can be passed to proxy() - see below.


        See COMPRESSION in HTTP::Transport.
    All initialization options from the underlying transport layer

        The options for HTTP(S) are the same as for LWP::UserAgent's new() method.

        A common option is to create a instance of HTTP::Cookies and pass it as cookie_jar option:

         my $cookie_jar = HTTP::Cookies->new()
            cookie_jar => $cookie_jar,

    For example, if you wish to set the HTTP timeout for a SOAP::Lite client to 5 seconds, use the following code:

      my $soap = SOAP::Lite
       ->proxy($proxyUrl, timeout => 5 );

    See LWP::UserAgent.
endpoint(optional new endpoint address)

        $client->endpoint(' newPoint')

    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.
service(service URL)


    SOAP::Lite offers some support for creating method stubs from service descriptions. At present, only WSDL support is in place. This method loads the specified WSDL schema and uses it as the basis for generating stubs.


    When set to a true value, the raw XML is returned by the call to a remote method.

    The default is to return the a SOAP::SOM object (false).


    This method is a shortcut for:


    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.


    This method is a shortcut for:


    When this is used to set a true value for this property, the generated XML sent to the endpoint has extra characters (spaces and new lines) added in to make the XML itself more readable to human eyes (presumably for debugging). The default is to not send any additional characters.
headerattr(hash reference of attributes)

        $obj->headerattr({ attr1 => 'value' });

    Allows for the setting of arbitrary attributes on the header object. Keep in mind the requirement that any attributes not natively known to SOAP must be namespace-qualified. If using $session->call ($method, $callData, $callHeader), SOAP::Lite serializes the informations as

          <myMethod xmlns="">
            <foo />

    The attributes, given to headerattr are placed into the Header as

        <soap:Header attr1="value">

bodyattr(hash reference of attributes)

        $obj->bodyattr({ attr1 => 'value' });

    Allows for the setting of arbitrary attributes on the body object. Keep in mind the requirement that any attributes not natively known to SOAP must be namespace-qualified. See headerattr

    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 ns() or default_ns(). Setting the default namespace causes elements to be serialized without a namespace prefix, like this:

          <myMethod xmlns="">
            <foo />

    Some .NET web services have been reported to require this XML namespace idiom.

    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 ns() or default_ns().

    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:

          <my:myMethod xmlns:my="">
            <my:foo />


    Deprecated. Use the ns() and default_ns methods described above.

    Shortcut for serializer->use_prefix(). This lets you turn on/off the use of a namespace prefix for the children of the /Envelope/Body element. Default is 'true'.

    When use_prefix is set to 'true', serialized XML will look like this:

      <SOAP-ENV:Envelope ...attributes skipped>
          <namesp1:mymethod xmlns:namesp1="urn:MyURI" />

    When use_prefix is set to 'false', serialized XML will look like this:

      <SOAP-ENV:Envelope ...attributes skipped>
          <mymethod xmlns="urn:MyURI" />

    Some .NET web services have been reported to require this XML namespace idiom.
soapversion(optional value)


    If no parameter is given, returns the current version of SOAP 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 SOAP being used.

    The value should be either 1.1 or 1.2.


    This method is a shortcut for:


    Gets or sets the namespace prefix for the SOAP namespace. The default is SOAP.

    The prefix itself has no meaning, but applications may wish to chose one explicitly to denote different versions of SOAP or the like.


    This method is a shortcut for:


    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)


    This method is a shortcut for:


    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.


    This method is a shortcut for:


    Gives the application access to the type-lookup table from the serializer object. See the section on SOAP::Serializer.
uri(service specifier)

    Deprecated - the uri 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 ns() or default_ns() subroutines instead of uri().


    This method is a shortcut for:


    The URI 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 uri refers to the namespace used for the request.

    Often times, the value may look like a valid URL. 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.


    This method is a shortcut for:


    Controls how the serializer handles values that have multiple references to them. Recall from previous SOAP 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 ID 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.
parts( ARRAY )

    Used to specify an array of MIME::Entity's to be attached to the transmitted SOAP message. Attachments that are returned in a response can be accessed by SOAP::SOM::parts().

        $ref = SOAP::Lite->self;

    Returns an object reference to the default global object the SOAP::Lite package maintains. This is the object that processes many of the arguments when provided on the use line.

The following method isn't an accessor style of method but neither does it fit with the group that immediately follows it:


        $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:


        $client->on_action(sub { qq("$_[0]") });

    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 URI 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.

    .NET web services usually expect / as separator for uri and method. To change SOAP::Lite's behaviour to use uri/method as SOAPAction header, use the following code:

        $client->on_action( sub { join '/', @_ } );


        $client->on_fault(sub { popup_dialog($_[1]) });

    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 GUI function that presents an error dialog with the text of fault extracted from the object (which is covered shortly under the SOAP::SOM methods).

        $client->on_nonserialized(sub { die "$_[0]?!?" });

    Occasionally, the serializer may be given data it can't turn into SOAP-savvy XML; 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.

        $client->on_debug(sub { print @_ });

    Deprecated. Use the global +debug and +trace facilities described in SOAP::Trace

    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.