|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44811 [Patch] Improve error message when creating new SoapClient with invalid data
Submitted: 2008-04-23 19:23 UTC Modified: 2008-05-07 15:48 UTC
From: Assigned: davidc (profile)
Status: Closed Package: SOAP related
PHP Version: 5.3CVS-2008-04-23 (CVS) OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2008-04-23 19:23 UTC]
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
diff -u -r1. php_sdl.c
--- php_sdl.c	31 Dec 2007 07:17:13 -0000
+++ 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("");'

Expected result:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '': 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 '' in Command line code:1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-07 14:19 UTC]
Actually one thing you could do is simply this:

try { 
    new SoapClient("");
} catch(Exception $e) { 

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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 13:01:29 2024 UTC