Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

SOAP::Lite -- transport vs SOAP faults

by Bill.Costa (Acolyte)
on Jul 02, 2013 at 19:42 UTC ( #1042085=perlquestion: print w/replies, xml ) Need Help??

Bill.Costa has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE: This is apparently a known bug which is fixed in github but that version is not in CPAN as of yet. https://rt.cpan.org/Public/Bug/Display.html?id=85713

I'm new to SOAP and SOAP::Lite, so I'm still trying to wrap my head around SOAP::Lite's view of the world. Under certain circumstances SOAP::Lite is receiving valuable fault information from the server, but I can't figure out how to cleanly retrieve it. Consider the following example.

use warnings; use strict; use SOAP::Lite; my $sObj = SOAP::Lite->new(uri => $NAME_SPACE, proxy => $END_POINT); my $rObj; eval { $rObj = $sObj->fooBar('here','there'); ### line 29 }; if (not defined($rObj) or $@) { warn($sObj->transport->http_response->content()); ### line 34 warn("? $0: $@"); warn("? $0: ", $sObj->transport->status(), "\n_ "); ### line 36 warn("? $0: ", $sObj->faultstring(), "\n_ "); ### line 37 }

When we run this we get the following output:

<?xml .... </S:Envelope> at ./demo4 line 34. ? ./demo4: 500 Internal Server Error at ./demo4 line 29 ? ./demo4: 500 Internal Server Error _ at ./demo4 line 36. 500 Internal Server Error at ./demo4 line 37

So we can catch the error, which if we believe line 36, is a transport error. And if we try to examine the SOAP fault in line 37, we die because we're doing a method call after apparently ignoring a transport error. Nice touch.

But the problem is that the reported error message is not very informative and if we look at the content of the http response we can see the very helpful fault string message...

"Cannot find dispatch method".

So I don't understand why this is being treated as a transport error when there is an actual SOAP response, and I don't understand how I am suppose to cleanly retrieve this response.

Replies are listed 'Best First'.
Re: SOAP::Lite -- transport vs SOAP faults
by Loops (Curate) on Jul 02, 2013 at 19:58 UTC

    You seem to be ignoring the return object which should contain the information you're looking for.

    Your code seems to be protecting against $rObj being undefined, but actually it should get a value even in the case of an error. See SOAP::SOM. and its ->faultstring() method

      In this example at least, the SOM object ($rObj) is always undefined.
Re: SOAP::Lite -- transport vs SOAP faults
by snoopy (Curate) on Jul 03, 2013 at 01:42 UTC
    Try calling the SOAP::Lite faultdetail method:
    warn("? $0: ", $sObj->faultdetail(), "\n_ "); ### line 38
      Calling the faultdetail() method also causes an exception. I guess it would be an interesting experiment to see which methods can still be called after a transport error.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-06-25 20:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (83 votes). Check out past polls.

    Notices?