Package to be used : SOAP::Lite
Source : http://soaplite.com/download.html
Client Code:
#!perl -wAs an alternative we can use WSDL file instead of URL, It goes like this.
use strict;
use SOAP::Lite;
use Data::Dumper;
my $service = SOAP::Lite
-> proxy("$URL"); #Target URL
my $result = $serive->methodName(); #Target Methodname
print "Result :".Dumper($result);
#!perl -wThe method we have called here does not have any input parameters. Normally SOAP body will not be empty (target method will always require some input params). Now lets see how we have to pass the parameters to the target method.
use strict;
use SOAP::Lite;
use Data::Dumper;
my $service = SOAP::Lite
my $service = SOAP::Lite->service('http://url?wsdl');
my $result = $serive->methodName(); #Target Methodname
print "Result :".Dumper($result);
#!perl -w
use strict;
use SOAP::Lite;
use Data::Dumper;
my $service = SOAP::Lite
-> proxy("$URL"); #Target URL
my $result = $serive->methodName('param1', 'param2', ...); #Target Methodname
print "Result :".Dumper($result);
The parameter type depends on the value of the parameter. If the value is int, it is by default int. hence if you have to pass the integer value as string, you might have to pass the parameters in a different way.
#!perl -wHere "type" can be string/long/int or anything, that is acceptable by the SOAP:Lite package.
use strict;
use SOAP::Lite;
use Data::Dumper;
my $service = SOAP::Lite
-> proxy("$URL"); #Target URL
my @params = (
SOAP::Data->name("param_name1" => SOAP::Data->type("type" => 'value1'),
SOAP::Data->name("param_name2" => SOAP::Data->type("type" => 'value2'),
my $result = $serive->methodName(@params);
print "Result :".Dumper($result);
Till Now we are able to create SOAP requests, which can have simple parameters in SOAP:Body. What if we have to send the nested parameters? If we have to take an example,
The perl code above is not able to build this nested request. hence we are going to modify it to a little extent to meet our requirements.
#!perl -w
use strict;
use SOAP::Lite;
use Data::Dumper;
my $service = SOAP::Lite
-> proxy("$URL"); #Target URL
my @params = (
SOAP::Data->name("param_name1" => SOAP::Data->type("type" => 'value1'),
SOAP::Data->name("param_name2" => SOAP::Data->type("type" => 'value2'),
my $result = $serive->methodName(@params);
print "Result :".Dumper($result);
