Follows an example perl script snippet structure to build SOAP object to call a web service
- Use the required library
use SOAP::Lite +trace => 'debug';
- Define the SOAP object
my $soap = SOAP::Lite
-> uri('http://localhost:1325/WSImpl/')
-> on_action( sub { return '"http://www.example.com/ws/MaterialService:updateMaterialIn"' } )
-> proxy('http://localhost:1325/WSImpl/MaterialService.asmx')
-> on_fault(sub { my($soap, $res) = @_;
die ref $res ? $res->faultdetail : $soap->transport->status, "\n";
}); - Define the SOAP method
my $method = SOAP::Data->name('UpdateMaterialRequest')
->attr({xmlns => 'http://www.example.com/ws/MaterialService'}); - Build the SOAP query data
my $query = SOAP::Data->value(
SOAP::Data->name(ServiceTags =>
\SOAP::Data->value(
SOAP::Data->name(UserName => ''),
SOAP::Data->name(Pwd => ''))),
SOAP::Data->name(Details =>
\SOAP::Data->value(
SOAP::Data->name(DetailsName => Name )
)
)
); - Make the Call
$result = $soap->call($method => $query);
- Read the resultant data
my $statusmes = $result->valueof('//GetResponse/Status');
Comments
Post a Comment