Reputation: 554
I am trying to make SOAP client in perl for JAX-WS web service with authentication. I am able to communicate with a service without authentication. But when I try to communicate with the actual web Serivce ( who has authentication ) I get authorization error or soap xml unformated error.
Upvotes: 1
Views: 5822
Reputation: 5163
Try this code
my $user="testUser";
my $password="testPassword";
my $service_url='https://api.example.com/services/soap.wsdl';
my $client = SOAP::Lite->service($service_url);
$client->on_fault(
sub { # SOAP fault handler
my $soap = shift;
my $res = shift;
# Map faults to exceptions
if(ref($res) eq '') {
die($res);
} else {
die($res->faultstring);
}
return new SOAP::SOM;
}
);
my @headers = (
SOAP::Header->name('username')->value($user),
SOAP::Header->name('password')->value($password),
);
# make the call
my $result = $client->getVersion(@headers);
print $result . "\n\n";
Upvotes: 2