SOAP 응답을 구문 분석하는 데 PHP SimpleXMLElement
및 simpleSMLToArray()
함수를 사용하는 데 문제가 있습니다. 내 SOAP 서버에서 SOAP 응답을 받고있다. 이 경우 SOAP 클라이언트와 서버를 모두 작성합니다. 나는 서버에 NuSoap을 사용하고 있습니다. 내게 비누 반응은 완벽 해 보이지만 PHP5 Soap Client는 구문 분석하지 않는 것 같습니다. 그래서, 과거와 마찬가지로 나는 SimpleXMLElement
과 PHP.NET (http://php.net/manual/en/book.simplexml.php)의 simpleXMLToArray()
함수를 사용하고 있지만 배열을 얻을 수 없습니다.PHP 구문 분석 비누 문제 - SimpleXMLElement
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:eCaseWSDL">
<SOAP-ENV:Body>
<ns1:registerDocumentByPatientResponse xmlns:ns1="urn:eCaseWSDL">
<returnArray xsi:type="tns:ReturnResult">
<id xsi:type="xsd:int">138</id>
<method xsi:type="xsd:string">registerDocumentByPatient</method>
<json xsi:type="xsd:string">0</json>
<message xsi:type="xsd:string">success</message>
<error xsi:type="xsd:string">0</error>
</returnArray>
</ns1:registerDocumentByPatientResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
내 수업의 PHP 코드 ($ this 참고 자료는 내 도서관 코드에 적용됨).
// Define SimpleXMLElement
$xml_element = new SimpleXMLElement($response_string); // SOAP XML
$name_spaces = $xml_element->getNamespaces(true);
var_dump($name_spaces);
$soap = $xml_element->children('ns1');
var_dump($soap);
$soap_array = $this->simpleXMLToArray($soap);
var_dump($soap_array);
return $soap_array;
나는 네임 스페이스를 볼 수있다. ns1 등. 그러나 배열은 반환되지 않습니다. SimpleXMLElement
은 객체를 반환하는 것처럼 보이지만 비어 있습니다.
<pre>array(3) {
["SOAP-ENV"]=>
string(41) "http://schemas.xmlsoap.org/soap/envelope/"
["ns1"]=>
string(13) "urn:eCaseWSDL"
["xsi"]=>
string(41) "http://www.w3.org/2001/XMLSchema-instance"
}
object(SimpleXMLElement)#23 (0) {
}
bool(false)
누구나 내가 뭘 잘못하고 있는지에 대한 아이디어가 있습니다. 오늘 아침에 커피를 충분히 마셔서는 안된다. 나는 정규 표현식으로 구문 분석하기를 원한다.
하지 ... 사용 ... 정규식을 수행 예를 액세스 할 때
또한, 당신은 실제 네임 스페이스 URI를 사용해야합니다. .. argggg ... [** 조랑말, 그는 온다! **] (http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454 # 1732454) 또한,이 대답은 도움이 될 것 같아요 ... [SimpleXML을 사용하여 네임 스페이스로 XML 구문 분석하기] (http://stackoverflow.com/questions/595946/parse-xml-with-namespace-using-simplexml) – rdlowrey