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: 2021-09-26 04:22 UTC
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: cmb (profile)
Status: No Feedback Package: SOAP related
PHP Version: 7.0.6 OS: Linux, Windows
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: 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

Pull Requests

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());
}
 [2021-02-12 17:59 UTC] gudang dot 673 at gmail dot cpm
Almost five years and no fix yet?
Seriously?
 [2021-09-13 16:00 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: SimpleXML related +Package: SOAP related -Assigned To: +Assigned To: cmb
 [2021-09-13 16:00 UTC] cmb@php.net
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>
 [2021-09-26 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC