2013-07-17 48 views
0

我需要這個Web服務的幫助,它返回這個stdClass Object ([GETOfertasAereasResult] =>)web服務不返回數組

我需要所有的值返回數組。

<?php 
    try { 
     $wsdl_url = 'http://portaldoagente.com.br/wsonlinetravel/funcoes.asmx?WSDL'; 
     $client = new SOAPClient($wsdl_url); 
     $params = array(
      'sLojaChave' => "Y2Y4ZGRkOWU=", 
     ); 
     $return = $client->GETOfertasAereas($params); 
     print_r($return); 
    } catch (Exception $e) { 
     echo "Exception occured: " . $e; 
    } 
?> 
+0

哪來的web服務的文檔? – alfasin

+0

http://portaldoagente.com.br/wsonlinetravel/funcoes.asmx – user2295500

+0

您不會在您的請求中發佈XML:http://portaldoagente.com.br/wsonlinetravel/funcoes.asmx?op=GETOfertasAereas – alfasin

回答

0

假設你的數據是這樣的:

$return = '<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org /2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
<soap12:Body> 
<GETOfertasAereasResponse xmlns="http://tempuri.org/"> 
    <GETOfertasAereasResult>Some result content</GETOfertasAereasResult> 
</GETOfertasAereasResponse> 
</soap12:Body> 
</soap12:Envelope>'; 

試試這個:

$obj = new SimpleXMLElement($return); 
$body = $obj->children('soap12', true)->Body->children(); 
$content = (string) $body->GETOfertasAereasResponse->GETOfertasAereasResult; 
var_dump($content); 
+0

它是仍然不工作,我得到這個消息scrip stdClass對象([GETOfertasAereasResult] =>)字符串(0)「」我想要返回的數據作爲一個數組。當我測試wsdl時,我得到了大量數據的結果。 – user2295500

+0

@ user2295500 - 我不知道你的數據是什麼樣的。我發佈的代碼適用於我發佈的數據。如果你有不同的東西,請發佈。 –

+0

@ user2295500我不是一個好的php程序員,我需要從xml中獲取數據並將其顯示在html中。我認爲是解析數據的權利? – user2295500