Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

SOAP::Lite and call behaviour

by DreamT (Pilgrim)
on Mar 13, 2018 at 10:00 UTC ( #1210790=perlquestion: print w/replies, xml ) Need Help??
DreamT has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm using SOAP::Lite for setting up a soap client:
my $service_status = 1; my $client = SOAP::Lite -> uri( $URI ) -> on_action(sub{ qq($on_action) }) -> on_fault(sub { $service_status = 0 }) -> envprefix('soapenv') -> autotype(0) -> proxy( $Proxy ); my $method = SOAP::Data->name($method); my $header = SOAP::Header->type('data'=>SOAP::Data->type('xml' => +'')); my $body = _arrayref_to_soap($body); my $result; eval { $result = $client->call($method,$header,@$body); }; if ( $@ ) { # error handling } if ( !$service_status ) { # error handling }
This works great when the call is successful, the problem is when the web service is responding with an error (for example, when I use the wrong namespace). In that case, $result remains empty, $@ doesn't get set, and $service_status doesn't get set to 0.
This means that I can't collect the error from the web service. Of course, I can evaluate if $result is empty to find out what's wrong, but that doesn't seem correct.

Any ideas? Am I using on_fault the wrong way?

Replies are listed 'Best First'.
Re: SOAP::Lite and call behaviour
by Anonymous Monk on Mar 13, 2018 at 17:28 UTC
    Thks is what docs show
    my $som = $soap->call('sayHello', 'Kutter', 'Martin'); die $som->faultstring if ($som->fault);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1210790]
Approved by marto
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-03-24 06:50 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.