php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72136 Instancing SoapClient causing SimpleXMLElement::asXML method doesn't work
Submitted: 2016-05-02 07:04 UTC Modified: -
Votes:5
Avg. Score:4.2 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:4 (80.0%)
From: michal at lipek dot net Assigned:
Status: Open Package: SimpleXML related
PHP Version: 7.0.6 OS: Linux, Windows
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michal at lipek dot net
New email:
PHP Version: OS:

 

 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-31 12:14 UTC] kondratev dot v at gmail dot com
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());
}
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 02:01:26 2019 UTC