# perldoc > SOAP::Lite

---
type: CommandReference
command: SOAP::Lite
mode: perldoc
section: 3
source: perldoc
---

## Quick Reference

- `SOAP::Lite->new(proxy => $endpoint)` — create a new SOAP client
- `$client->proxy($url)` — set the endpoint/transport
- `$client->uri($ns)` — set the request namespace (deprecated; use `ns` or `default_ns`)
- `$client->service($wsdl_url)` — load WSDL service description
- `$client->call($method => @args)` — invoke a remote method explicitly
- `$client->autotype(0)` — disable automatic type detection
- `$client->readable(1)` — produce human-readable XML
- `$client->soapversion('1.2')` — set SOAP version

## Name

SOAP::Lite — Perl's Web Services Toolkit

## Synopsis

perl
use SOAP::Lite;
my $client = SOAP::Lite->new(proxy => 'http://endpoint');
$client->default_ns('urn:MyNamespace');
my $som = $client->call('methodName', @args);
die $som->faultstring if $som->fault;
print $som->result;
## Options (Methods)

### Constructor

- `new(key => value, ...)` — create a new instance. Accepts any accessor method name as key.

### Transport

- `proxy($url, %extra)` — set endpoint and transport options (e.g., `timeout`, `compress_threshold`, `cookie_jar`)
- `endpoint($url)` — change endpoint without reloading transport code
- `transport()` — get/set the transport object

### Serialization

- `serializer()` — get/set the serializer object
- `autotype(boolean)` — enable/disable automatic type deduction (default: on)
- `readable(boolean)` — add whitespace for readability (default: off)
- `encoding($urn)` — set encoding URN (e.g., SOAP 1.2 encoding)
- `typelookup()` — access the type‑lookup table (for custom type mapping)
- `multirefinplace(boolean)` — serialize multi‑ref values inline (default: off)
- `use_prefix(boolean)` — control namespace prefix usage (default: true)
- `ns($uri, $prefix?)` — set namespace URI and optional prefix
- `default_ns($uri)` — set default namespace (no prefix)
- `soapversion($version)` — set SOAP version (1.1 or 1.2)
- `envprefix($prefix)` — envelope namespace prefix
- `encprefix($prefix)` — encoding namespace prefix
- `outputxml(boolean)` — return raw XML instead of SOAP::SOM object

### WSDL

- `service($wsdl_url)` — load WSDL and create stubs

### Headers and Attributes

- `headerattr(\%attr)` — set arbitrary attributes on the SOAP Header element
- `bodyattr(\%attr)` — set arbitrary attributes on the SOAP Body element

### Attachments

- `parts(\@mime_entities)` — attach MIME parts to the request

### Event Callbacks

- `on_action(sub { ... })` — customize SOAPAction header
- `on_fault(sub { ... })` — handle server faults
- `on_nonserialized(sub { ... })` — handle unserializable data

### Utility

- `self()` — return the global default SOAP::Lite object

## Examples

### RPC/Encoded Client

perl
use SOAP::Lite;
my $soap = SOAP::Lite->new(proxy => 'http://localhost:81/helloworld.pl');
$soap->default_ns('urn:HelloWorld');
my $som = $soap->call('sayHello', 'Kutter', 'Martin');
die $som->faultstring if $som->fault;
print $som->result, "\n";
### Document/Literal Client

perl
use SOAP::Lite;
my $soap = SOAP::Lite->new(proxy => 'http://localhost/helloworld.pl');
$soap->on_action( sub { "urn:HelloWorld#sayHello" });
$soap->autotype(0);
$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";
### Client with Attachments

perl
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"));
### Server CGI (dynamic dispatch)

perl
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
    ->dispatch_to('/Your/Path/To/Modules', 'My::Examples')
    ->handle;
## See Also

- [SOAP::Transport](https://metacpan.org/pod/SOAP::Transport)
- [SOAP::Data](https://metacpan.org/pod/SOAP::Data)
- [SOAP::Serializer](https://metacpan.org/pod/SOAP::Serializer)
- [SOAP::SOM](https://metacpan.org/pod/SOAP::SOM)
- [SOAP::Server](https://metacpan.org/pod/SOAP::Server)
- [SOAP::Trace](https://metacpan.org/pod/SOAP::Trace)
- [SOAP::Constants](https://metacpan.org/pod/SOAP::Constants)
- [LWP::UserAgent](https://metacpan.org/pod/LWP::UserAgent)
- [MIME::Entity](https://metacpan.org/pod/MIME::Entity)

## Exit Codes

Not documented.