fujiman has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to capture SOAP::Lite fault?
by Anonymous Monk on Sep 20, 2008 at 06:28 UTC | |
by fujiman (Novice) on Sep 21, 2008 at 18:48 UTC | |
by Anonymous Monk on Sep 21, 2008 at 20:45 UTC | |
by fujiman (Novice) on Sep 23, 2008 at 22:40 UTC | |
|
Re: How to capture SOAP::Lite fault?
by roman (Monk) on Sep 21, 2008 at 22:00 UTC |