Hi All,

I have been posting alot of questions here lately and have received alot of good resolutions. Once again, i encountered a problem and hoping someone can help.

I wrote a soap::lite client routine that calls the login() method of the web service. However, I would like to capture the fault when login fails. Below is my subroutine, althought I see the Fault using soap trace in the responses, but I am unable to capture it in my log.

#subroutine to login to webservice sub usdLogin { my ($service, $sid) = eval { my $wsdl = 'http://' . USD_Server . USD_Endpoint; my $srv = SOAP::Lite->uri(USD_URI)->service($wsdl); my $id = $srv->login(USD_USER, USD_PWD); if($id->fault) { printLog("ERROR","$0::".chomp($id->faultcode)); printLog("ERROR","$0::".chomp($id->faultstring)); printLog("ERROR","$0::".chomp($id->faultactor)); return 0; } return ($srv, $id); }; if ($@) { printLog("ERROR","$0::$@"); return exit 1; } return ($service, $sid); }
#here is my trace output. Ideally, I would love to capture #the faultcode, faultstring and ErrorMessage <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h +ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap +ache.org/xml-soap" soap:encodingStyle="http://schemas.xmlsoap.org/soa +p/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" x +mlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://www.c +a.com/UnicenterServicePlus/ServiceDesk" xmlns:xsi="http://www.w3.org/ +2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/so +ap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body +><impl:login><username xsi:type="xsd:string">ServiceDesk</username><p +assword xsi:type="xsd:string">default1</password></impl:login></soap: +Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Ser +ver Error Connection: close Date: Fri, 19 Sep 2008 20:14:28 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 Client-Date: Fri, 19 Sep 2008 20:14:31 GMT Client-Peer: 192.168.25.128:8080 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Client</faultcode> <faultstring>Error - invalid login password</faultstring> <faultactor></faultactor> <detail> <ErrorMessage>Error - invalid login password</ErrorMessage> <ErrorCode>1000</ErrorCode> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>

The only thing i see in my log file is the following:

[Fri Sep 19 16:13:42 2008]::ERROR::C:\dev\TWP\USDCache.pl::Unrecognize +d method 'fault'. List of available method(s): bunch of methods here. [Fri Sep 19 16:14:31 2008]::ERROR::C:\dev\TWP\USDCache.pl::Can't call +method "fault" on an undefined value at C:\dev\TWP\USDCache.pl line 9 +8.

Thanks again for all your help!

fujiman

In reply to How to capture SOAP::Lite fault? by fujiman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.