我尝试了How to parse this SOAP XML response with PHP simplexml_load_string?的解决方案,但这不起作用。
也许有人对如何解析此Soap XML结果有所了解,您找到了soap.xml,结果和测试
Soap.xml
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ...>
<wsdl:documentation>soapExemple</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://.../xsd">
...
输出:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
const USER = "userHere";
const PASSWORD = "passHere";
$credentials = array('login' => USER, 'password' => PASSWORD);
$options = array("trace" => 1, "exception" => 0, 'encoding' => 'UTF-8');
$url = "pass/to/wsdl.xml";
$soap = new SoapClient($url, $credentials);
var_dump($soap);
try {
$result = $soap->__soapCall("reclis_XML", array("parameters"=>array("args0"=>array("METHODHERE" => "01"))));
var_dump($result);
} catch (SoapFault $exception) {
\Zend_Debug::dump( 'Exception Thrown: '.$exception->faultstring);
}
?>
结果:
object(stdClass)#6591 (1) {
["return"] => string(39171) "<?xml version="1.0" encoding="UTF-8"?>
<RECLIS>
<RESULT>KO</RESULT>
<REAL>0</REAL>
<RUS>
<REAL>0</REAL>
<CUSTOMER>
<CLEMAJ></CLEMAJ>
<NAME></NAME>
<LASTNALE>0</LASTNALE>
<PHONE>0</PHONE>
<AD></AD>
<ADDRESS1></ADDRESS1>
<ADDRESS2></ADDRESS2>
<CITY></CITY>
<CODE></CODE>
<PRICE>0</PRICE>
</CUSTOMER>
<CUSTOMER>
<CLEMAJ></CLEMAJ>
<NAME></NAME>
<LASTNALE>0</LASTNALE>
<PHONE>0</PHONE>
<AD></AD>
<ADDRESS1></ADDRESS1>
<ADDRESS2></ADDRESS2>
<CITY></CITY>
<CODE></CODE>
<PRICE>0</PRICE>
</CUSTOMER>
<CUSTOMER>
<CLEMAJ></CLEMAJ>
<NAME></NAME>
<LASTNALE>0</LASTNALE>
<PHONE>0</PHONE>
<AD></AD>
<ADDRESS1></ADDRESS1>
<ADDRESS2></ADDRESS2>
<CITY></CITY>
<CODE></CODE>
<PRICE>0</PRICE>
</CUSTOMER>
...
</RUS>
</RECLIS>
"
}
我尝试了这个,但是不起作用:
$xml=simplexml_load_string($myXMLData) or die("Error: Cannot create object");
print_r($xml);
有一个想法或其他解决方案来将我的xml结果作为数组获取
答案 0 :(得分:1)
您必须通过访问return
property
尝试使用:
$xml=simplexml_load_string($myXMLData->return) or die("Error: Cannot create object");
print_r($xml);