php.net |  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: mfischer@php.net Assigned: davidc (profile)
Status: Closed Package: SOAP related
PHP Version: 5.3CVS-2008-04-23 (CVS) OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mfischer@php.net
New email:
PHP Version: OS:

 

 [2008-04-23 19:23 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-07 14:19 UTC] davidc@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 12:01:26 2024 UTC