我正在开发项目,在那里我从一个Web服务获得XML响应。
我使用了nusoap库来获取webservice输出。
当我打印该响应时,我得到了正确的XML输出。但是,当我将该变量放置为:
$xml = simplexml_load_string($output->response());
print_r($xml);
我得到了空物。 但我在simplexml_load_string()中粘贴了打印的xml字符串,我得到了对象。
我应该如何在simplexml_load_string()函数中使用SOAP XML响应?
我的代码如下: require_once( '的NuSOAP / LIB / nusoap.php'); $ client = new nusoap_client('http://serverip.path?wsdl',true);
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('getNjdgDashB', array("arg0" => 'treasury', "arg1" => 'treasury', "arg2" => 'G'));
echo $note= $client->responseData;
$note = str_ireplace('SOAP-ENV:', '', $note);
$clean_xml = str_ireplace( 'SOAP:', '', $note);
$xml = simplexml_load_string($clean_xml);
print_r($xml);