2012-06-18 6 views
0

하루 종일 여기에 있었고 아무데도 들지 않는 것처럼 느껴졌습니다.이 태그가이 페이지의 모습과 같이 xml로 표시되도록해야합니다. http://admin.stock.imdfulfilment.com/api/service.asmx/GetCouriers. 그러나 다음 코드PHP에서 SOAP 봉투를 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); 
} 
?> 

답변

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);