0
我一直在這一整天,感覺像我無處可去,我需要得到這個顯示爲一個XML,就像它是如何在這個頁面上http://admin.stock.imdfulfilment.com/api/service.asmx/GetCouriers。然而,下面的代碼PHP將XML信封解析爲XML
<?
try
{
$soap_url = 'http://admin.stock.imdfulfilment.com/api/service.asmx?wsdl';
$client = new SoapClient($soap_url, array(
'trace' => 1,
'exceptions'=>true,
'GetCouriersResult' => 'xml')
);
$client->GetCouriers();
$xml = simplexml_load_string($client->__getLastResponse());
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
foreach($xml->xpath('//soap:Envelope') as $item) {
echo "$item\n\n";
}
}
catch (Exception $e)
{
print_r($e);
}
?>