0

私は一日中これにいて、どこにも行かないように感じます。これをこのページのようにxmlとして表示する必要がありますhttp://admin.stock.imdfulfilment.com/api/service.asmx/ GetCouriers。しかし、次のコードは

<?
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);
}
?>
4

1 に答える 1

1

二重にエンコードされたXMLが返されます。なぜ誰かが良いアイデア(おそらくwsdlの更新に煩わされたくない人)だと思ったのかわかりません。

$soap_url = 'http://admin.stock.imdfulfilment.com/api/service.asmx?wsdl';
$client = new SoapClient($soap_url, array(
            'trace' => 1,
            'exceptions'=>true,
            'GetCouriersResult' => 'xml')
        );

$result = $client->GetCouriers();
echo $result->GetCouriersResult->any;
//or you can load it in DOM or simpleXML if you need to read it;
$the_response_should_have_been = new simpleXMLElement($result->GetCouriersResult->any);
于 2012-06-18T21:40:48.840 に答える