Bug #72136 [Com]: Instancing SoapClient causing SimpleXMLElement::asXML method doesn't work

[email protected] ("kondratev dot v at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=72136&edit=1

 ID:                 72136
 Comment by:         kondratev dot v at gmail dot com
 Reported by:        michal at lipek dot net
 Summary:            Instancing SoapClient causing
                     SimpleXMLElement::asXML method doesn't work
 Status:             Open
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Linux, Windows
 PHP Version:        7.0.6
 Block user comment: N
 Private report:     N

 New Comment:

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());
}


Previous Comments:
------------------------------------------------------------------------
[2016-05-02 07:04:41] 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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72136&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.