これに関する他のチュートリアルとSOの回答を読もうとしましたが、うまくいかないようです:/
SOAP リクエストを作成して応答を取得することはできますが、応答を解析できないようです。
$result = $client->GetAllAttributes($params);
結果の応答 xml は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetAllAttributesResponse xmlns="http://connect2.askadmissions.net/webservices/">
<GetAllAttributesResult>
<result>
<code>1</code>
<ErrorMessage />
<returndata>
<attributes>
<attribute>
<type>attribute</type>
<level />
<name>text1321</name>
<mappingname><![CDATA[Extra-Curricular Interest]]></mappingname>
<datatype>Varchar2</datatype>
<size>35</size>
<validationexp />
</attribute>
<attribute> (same as above, several of these are returned</attribute>
</attributes>
</returndata>
</result>
</GetAllAttributesResult>
</GetAllAttributesResponse>
</soap:Body>
</soap:Envelope>
</xml>
私はもう試した
$xml = simplexml_load_string($client->__getLastResponse());
print_r($xml);
ただし、「SimpleXMLElement Object ()」と出力するだけです。
私はもう試した
$responseXML = $client->__getLastResponse();
$xml = simplexml_load_string($responseXML);
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('hob', 'http://connect2.askadmissions.net/webservices/');
$item = $xml->xpath('//hob:GetAllAttributesResult');
print_r($item);
そして私は配列を取得します
Array
(
[0] => SimpleXMLElement Object
(
[0] => <result><code>1</code><ErrorMessage /><returndata><attributes><attribute> <type>attribute</type><level />
など (配列が非常に長い)
私の問題は、ツリーにさらに足を踏み入れようとしたときに発生します。私が行った場合
$item = $xml->xpath('//hob:GetAllAttributesResult/hob:result');
また
$item = $xml->xpath('//hob:GetAllAttributesResult/hob:code');
空の配列になってしまいます。
ツリーをさらに進めるにはどうすればよいですか?
助けてくれてありがとう。