Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

SOAP::Lite and call behaviour

by DreamT (Pilgrim)
on Mar 13, 2018 at 10:00 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1210790]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found