Mojo::SOAP::Client - Talk to SOAP Services mojo style
use Mojo::SOAP::Client;
use Mojo::File qw(curfile);
my $client = Mojo::SOAP::Client->new(
wsdl => curfile->sibling('fancy.wsdl'),
xsds => [ curfile->sibling('fancy.xsd')],
port => 'FancyPort'
);
$client->call_p('getFancyInfo',{
color => 'green'
})->then(sub {
my $answer = shift;
my $trace = shift;
});
The Mojo::SOAP::Client is based on the XML::Compile::SOAP family of packages, and especially on XML::Compile::SOAP::Mojolicious.
The module provides the following properties to customize its behavior. Note that setting any properties AFTER using the call
or call_p
methods, will lead to undefined behavior.
a pointer to a Mojo::Log instance
How many seconds to wait for the soap server to respond. Defaults to 5 seconds.
Set this to allow communication with a soap server that uses a self-signed or otherwhise invalid certificate.
Where to load the wsdl file from. At the moment this MUST be a file.
A pointer to an array of xsd files to load for this service.
If the wsdl file defines multiple ports, pick the one to use here.
The endPoint to talk to for reaching the SOAP service. This information is normally encoded in the WSDL file, so you will not have to set this explicitly.
The CA cert of the service. Only for special applications.
The client certificate to use when connecting to the soap service.
The key matching the client cert.
If special properties must be set on the UA you can set them here. For example a special authorization header was required, this would tbe the place to set it up.
my $client = Mojo::SOAP::Client->new(
...
uaProperties => {
header => HTTP::Headers->new(
Authorization => 'Basic '. b64_encode("$user:$password","")
})
}
);
The module provides the following methods.
Call a SOAP operation with parameters and return a Mojo::Promise.
$client->call_p('queryUsers',{
query => {
detailLevels => {
credentialDetailLevel => 'LOW',
userDetailLevel => 'MEDIUM',
userDetailLevel => 'LOW',
defaultDetailLevel => 'EXCLUDE'
},
user => {
loginId => 'aakeret'
}
numRecords => 100,
skipRecords => 0,
}
})->then(sub ($anwser,$trace) {
print Dumper $answer
});
The same as call_p
but for syncronos applications. If there is a problem with the call it will raise a Mojo::SOAP::Exception which is a Mojo::Exception child.
This is really just a very thin layer on top of Mark Overmeers great XML::Compile::SOAP module. Thanks Mark!
Tobias Oetiker, [email protected]
Copyright OETIKER+PARTNER AG 2019
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10 or, at your option, any later version of Perl 5 you may have available.