Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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 examining the Monastery: (11)
As of 2018-06-25 20:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (128 votes). Check out past polls.