php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55567 SoapFault is missing methods to get the Fault Code
Submitted: 2011-09-01 17:15 UTC Modified: -
Votes:9
Avg. Score:3.9 ± 1.1
Reproduced:9 of 9 (100.0%)
Same Version:1 (11.1%)
Same OS:2 (22.2%)
From: ch@php.net Assigned:
Status: Open Package: SOAP related
PHP Version: 5.4.0alpha3 OS:
Private report: No CVE-ID: None
 [2011-09-01 17:15 UTC] ch@php.net
Description:
------------
The SoapFault object does not have a getFaultCode() method nor does it set the exception code to the received SOAP fault code.

The code is available through the undocumented public property "faultcode" though.

I would suggest setting the Exception code to the SOAP fault code.
Backwards compatibility shouldn't be a big problem because currently, the code can only be 0 as the constructor does not even makes it possible to change it.

If you disagree, I'd like to see a getFaultCode() method at least.

Having access to the SOAP fault code is essential as SOAP does not transfer the Exception class name and thus there is no other way to cleanly distinguish between different kinds of exceptions.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-08 16:41 UTC] hairmare at purplehaze dot ch
I just ran into this in 5.3.8. Personally i would expect SOAPFault::getCode() to return the fault exactly as it was received from SOAP (ie. as a string).

I wrote a phpt case showing what behaviour I would expect. I didn't find a way to add it to this ticket, so here goes:

--TEST--
Test for strings in Exception::getCode()
--FILE--
<?php
$e = new SOAPFault("Client", "Sample Error Message");
var_dump($e->getCode());
?>
--EXPECT--
string(6) "Client"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 07:01:27 2024 UTC