2
您好我想從這些肥皂消息中獲取元素名稱以確定要採取的操作但是我得到正文在這種情況下accountInformationRequest是我之後。我是在一個單一的URL獲取多個請求因而需要獲得元素name.These是我試圖如何使用simplexml在soap消息中獲取元素名稱
$xml=simplexml_load_string($content);
$xml->registerXPathNamespace('env', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('ns', 'http://www.yyy.com/mct/tx/2.0');
$xml->registerXPathNamespace('ns1', 'http://www.yyy.com/mct/ty/2.0');
$xml->registerXPathNamespace('ns2', 'http://www.yyy.com/mct/tx/2.1');
$xml->registerXPathNamespace('ns3', 'http://www.yyy.com/mct/ty/2.1');
$bodies = $xml->xpath('env:Body');
foreach($bodies as $body){
echo $body->getName();
$reply = $body->children('ns', TRUE)->accountInformationRequest;
}
//Soap message
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.yyy.com/mct/tx/2.0"
xmlns:ns1="http://www.yyy.com/mct/ty/2.0"
xmlns:ns2="http://www.yyy.com/mct/tx/2.1"
xmlns:ns3="http://www.yyy.com/mct/ty/2.1">
<soapenv:Header/>
<soapenv:Body>
<ns:accountInformationRequest>
<ns:security>
<ns1:login>sam</ns1:login>
<ns1:password>lin</ns1:password>
</ns:security>
<ns:hsTransactionId>001</ns:hsTransactionId>
<ns:destinationUri>003</ns:destinationUri>
<!--Optional:-->
<ns:routingTag>B2B</ns:routingTag>
<!--Optional:-->
<ns2:vendorSpecificFields>
<!--Zero or more repetitions:-->
<ns3:vsf>
<ns3:vendorId>10</ns3:vendorId>
<ns3:fieldId>22</ns3:fieldId>
<ns3:value>2</ns3:value>
</ns3:vsf>
</ns2:vendorSpecificFields>
</ns:accountInformationRequest>
</soapenv:Body>
</soapenv:Envelope>