2013-07-17 32 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