|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-05-02 07:04 UTC] michal at lipek dot net
Description:
------------
Creating instance of \SoapClient with incorrect path to WSDL file causing incorrect work of SimpleXMLElement::asXML method, in completely different object.
I ran script below in PHP: 5.5 (Debian), 5.6 (Windows) and 7.0.6 (Windows) and 7.0.5 (CentOS). I got errors only in PHP 7 on Windows and Linux.
I've made one change in php.ini - I was activated php_soap extension.
Test script:
---------------
<?php
libxml_use_internal_errors(true);
try {
$a = new \SoapClient('fake/wsdl');
} catch (\SoapFault $ex) {
}
$source = simplexml_load_string("<xml></xml>");
var_dump($source->asXML('example.xml')); // should be true
var_dump(libxml_get_errors()); // should be one error, but there are 2
Expected result:
----------------
bool(true)
array(1) {
[0]=>
object(LibXMLError)#3 (6) {
["level"]=>
int(1)
["code"]=>
int(1549)
["column"]=>
int(0)
["message"]=>
string(43) "failed to load external entity "fake/wsdl"
"
["file"]=>
string(0) ""
["line"]=>
int(0)
}
}
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'fake/wsdl' : failed to load external entity "fake/wsdl"
in C:\a.php on line 6
Actual result:
--------------
bool(false)
array(2) {
[0]=>
object(LibXMLError)#3 (6) {
["level"]=>
int(1)
["code"]=>
int(1549)
["column"]=>
int(0)
["message"]=>
string(43) "failed to load external entity "fake/wsdl"
"
["file"]=>
string(0) ""
["line"]=>
int(0)
}
[1]=>
object(LibXMLError)#4 (6) {
["level"]=>
int(2)
["code"]=>
int(1545)
["column"]=>
int(0)
["message"]=>
string(11) "flush error"
["file"]=>
string(0) ""
["line"]=>
int(0)
}
}
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'fake/wsdl' : failed to load external entity "fake/wsdl"
in C:\a.php on line 6
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Good afternoon. Faced the same problem. I get false in the save method of the DOMDocument class. try { $test = @new SoapClient($url, $options); } catch (SoapFault $e) { } //***** $dom = new DOMDocument('1.0', "UTF-8"); //... $result = $dom->save($fileName); $result === false //**** it works: if ($result === false) { file_put_contents($fileName, $dom->saveXML()); }I cannot reproduce this with PHP-7.4 on Windows; I get: bool(true) array(1) { [0]=> object(LibXMLError)#3 (6) { ["level"]=> int(1) ["code"]=> int(1549) ["column"]=> int(0) ["message"]=> string(43) "failed to load external entity "fake/wsdl" " ["file"]=> string(0) "" ["line"]=> int(0) } } Can anybody reproduce this with any of the actively supported PHP versions[1]? [1] <https://www.php.net/supported-versions.php>