SoapFault getMessage
| From: | Hannes Gassert | Date: | Mon, 14 Jun 2004 07:58:15 +0000 |
| Subject: | SoapFault getMessage | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-1553@lists.php.net to get a copy of this message | ||
Hi,
I'm currently playing with the PHP5 SOAP extension and now have a little
problem with the exception handling.
I tried to query a NuSOAP service, which can return an error like this
(body only):
<SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>Client</faultcode>
<faultactor>Authentication
error</faultactor>
<faultstring>You are not recognized by the
authentication process</faultstring>
<detail><soapVal
xsi:type="xsd:string"></soapVal></detail></SOAP-ENV:Fault></SOAP-ENV:Body>
This, of course, causes a SoapFault exception to be thrown, but it seems
like I can't access the error message:
$client = new
SoapClient("http://www.myweb-services.com/server/UserApps.wsdl");
$fname = "Ali"; $lname = "Baba";
$email = "test@example.com"; $passwd = '123456789';
try {
$myAuthenticationStruct = $client->AuthenticateUser($email, $passwd .
"____"); var_dump($myAuthenticationStruct);
}
catch (SoapFault $f){
var_dump($f->getMessage()); // yields string(0) ""
}
If I don't catch the SoapFault, a fatal error is issued containing the
message "You are not recognized by the authentication process", so the
information must be somewhere inside the exception. So how to access it,
except just echoing the entire exception?
I tried with yesterday's snapshot if that matters.
Thanks a lot and kind regards,
Hannes
--
http://hannes.kaywa.com