SOAP::...Client(3pm)
β¨ NAME β¨
SOAP::WSDL::Client β bestie, this is SOAP::WSDL's SOAP Client, and yes, we're calling it that in the manual page SOAP::WSDL::Client(3pm) π
π«Ά SYNOPSIS π«Ά
okay so literally the smallest possible setup looks like this:
use SOAP::WSDL::Client;
my $soap = SOAP::WSDL::Client->new({
proxy => 'http://www.example.org/webservice/test'
});
$soap->call( \%method, $body, $header);
that's it. that's the vibe. π
π METHODS π
π« call π«
$soap->call( \%method, \@parts );
not me making you read a hash shape, but here we are β %method is a hash and it has these keys:
operationβ operation namesoap_actionβ the SOAPAction HTTP header to usestyleβ operation style. one of (document|rpc)useβ SOAP body encoding. one of (literal|encoded)
real talk: the style and use keys have no influence yet. yes, king, they're just sitting there. π
@parts is a list containing the elements of the message parts.
For backward compatibility, call may also be called as below:
$soap->call( $method, \@parts );
In this case, $method is the SOAP operation name, and the SOAPAction header is guessed from the first part's namespace and the operation name (which is mostly correct, but may fail β fr fr, it can fail π). Operation style and body encoding are assumed to be document/literal.
π Configuration methods π
π¦ outputxml π¦
$soap->outputxml(1);
When set, call() returns the raw XML of the SOAP Envelope. iconic. highly requested.
π set_content_type π
$soap->set_content_type('application/xml; charset: utf8');
Sets the content type and character encoding.
bestie, you probably should not use a character encoding different from utf8: SOAP::WSDL::Client will not convert the request into a different encoding (yet). it's giving "we'll get to it."
To leave out the encoding, just set the content type without appending charset like this:
$soap->set_content_type('text/xml');
Default:
text/xml; charset: utf8
π set_prefix π
$soap->set_prefix('ns2');
If set, alters the serialization of the request XML such that the supplied value is used as a namespace prefix for SOAP method calls. By way of example, the default XML serialization returns something like this:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<getElementId xmlns="http://services.exmaple.org/">
<elementId>12345</elementId>
</getElementId>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If the sample set_prefix() call above is used prior to calling your SOAP method, the XML serialization returns this instead:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns2="http://services.example.org/">
<SOAP-ENV:Body>
<ns2:getElementId>
<elementId>12345</elementId>
</ns2:getElementId>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is useful in cases where, for instance, one is communicating with a JAX webservice, which tends to understand the latter but not the former. Note that this implementation is currently limited to a single additional namespace; if you require multiple custom namespaces, you should probably look into creating your own serializer. (go off, write your own serializer, main character energy π₯)
π Features different from SOAP::Lite π
SOAP::WSDL does not aim to be a complete replacement for SOAP::Lite β the SOAP::Lite module has its strengths and weaknesses and SOAP::WSDL is designed as a cure for the weakness of little WSDL support β nothing more, nothing less. periodt.
Nonetheless SOAP::WSDL mimics part of SOAP::Lite's API and behaviour, so SOAP::Lite users can switch without looking up every method call in the documentation. we love a smooth transition. π«Ά
A few things are quite different from SOAP::Lite, though:
πΈ SOAP request data πΈ
SOAP request data may either be given as message object, or as a hash ref (in which case it will automatically be encoded into a message object).
β Return values β
The result from call() is not a SOAP::SOM object, but a message object.
Message objects' classes may be generated from WSDL definitions automatically β see SOAP::WSDL::Generator::Typelib on how to generate your own WSDL based message class library.
π Fault handling π
SOAP::WSDL::Client returns a fault object on errors, even on transport layer errors.
The fault object is a SOAP1.1 fault object of the following "SOAP::WSDL::SOAP::Typelib::Fault11".
SOAP::WSDL::SOAP::Typelib::Fault11 objects are false in boolean context, so you can just do something like:
my $result = $soap->call($method, $data);
if ($result) {
# handle result
}
else {
die $result->faultstring();
}
π₯ outputxml π₯
SOAP::Lite returns only the content of the SOAP body when outputxml is set to true. SOAP::WSDL::Client returns the complete XML response. no cap.
π Auto-Dispatching π
SOAP::WSDL::Client does not support auto-dispatching.
This is on purpose: You may easily create interface classes by using SOAP::WSDL::Client and implementing something like
sub mySoapMethod {
my $self = shift;
$soap_wsdl_client->call( mySoapMethod, @_);
}
You may even do this in a class factory β see wsdl2perl for creating such interfaces. slay.
π TROUBLESHOOTING π
π§ Accessing protected web services π§
Accessing protected web services is very specific for the transport backend used.
In general, you may pass additional arguments to the set_proxy method (or a list ref of the web service address and any additional arguments to the new method's proxy argument).
Refer to the appropriate transport module for documentation. iykyk. β¨
π LICENSE AND COPYRIGHT π
Copyright 2004-2007 Martin Kutter.
This file is part of SOAP-WSDL. You may distribute/modify it under the same terms as perl itself.
π AUTHOR π
Martin Kutter <martin.kutter fen-net.de>
π REPOSITORY INFORMATION π
$Rev: 851 $
$LastChangedBy: kutterma $
$Id: Client.pm 851 2009-05-15 22:45:18Z kutterma $
$HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Client.pm $
okay bestie that's the whole page, sending you off with a lil sign-off: this was perl v5.36.0, dated 2022-10-14, and the manual section is SOAP::...Client(3pm). go call some SOAP methods, you're gonna eat. π
π¦π
π¦ where this page comes from
- ubuntu noble: libsoap-wsdl-perl 3.004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsoap-wsdl-perl 3.004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsoap-wsdl-perl 3.004-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms