#44811 [Opn]: [Patch] Improve error message when creating new SoapClient with invalid data
| From: | davidc@php.net | Date: | Wed, 07 May 2008 14:19:31 +0000 |
| Subject: | #44811 [Opn]: [Patch] Improve error message when creating new SoapClient with invalid data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124794@lists.php.net to get a copy of this message | ||
ID: 44811
Updated by: davidc@php.net
Reported By: mfischer@php.net
Status: Open
Bug Type: SOAP related
Operating System: Any
PHP Version: 5.3CVS-2008-04-23 (CVS)
Assigned To: davidc
New Comment:
Actually one thing you could do is simply this:
try {
new SoapClient("http://slashdot.org");
} catch(Exception $e) {
var_dump(libxml_get_last_error());
}
If you store this into a variable, you'll be able to retrieve the
->message property which has the detailed message.
We are still evaluating the need of adding the detailed message
natively.
Previous Comments:
------------------------------------------------------------------------
[2008-04-23 19:23:19] mfischer@php.net
Description:
------------
In case a new SoapClient is created and the loaded XML has problems,
the exact libxml2 error message is hidden.
It should be noted that with the provided patch, an extra \n gets
introduces which is from the libxml error context "message" member.
However I favor more exact error messages over formatting.
Index: php_sdl.c
===================================================================
RCS file: /repository/php-src/ext/soap/php_sdl.c,v
retrieving revision 1.88.2.12.2.9.2.2
diff -u -r1.88.2.12.2.9.2.2 php_sdl.c
--- php_sdl.c 31 Dec 2007 07:17:13 -0000 1.88.2.12.2.9.2.2
+++ php_sdl.c 23 Apr 2008 19:10:01 -0000
@@ -240,7 +240,12 @@
wsdl = soap_xmlParseFile(struri TSRMLS_CC);
if (!wsdl) {
- soap_error1(E_ERROR, "Parsing WSDL: Couldn't load from '%s'",
struri);
+ xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ if (xmlErrorPtr) {
+ soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s': %s",
struri, xmlErrorPtr->message);
+ } else {
+ soap_error1(E_ERROR, "Parsing WSDL: Couldn't load from '%s'",
struri);
+ }
}
zend_hash_add(&ctx->docs, struri, strlen(struri)+1, (void**)&wsdl,
sizeof(xmlDocPtr), NULL);
Reproduce code:
---------------
php -r 'new SoapClient("http://slashdot.org");'
Expected result:
----------------
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from 'http://slashdot.org': Premature end of data in
tag html line 3
in Command line code:1
Actual result:
--------------
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from 'http://slashdot.org' in Command line code:1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44811&edit=1