0

我需要这个网络服务的帮助,它正在返回这个stdClass Object ( [GETOfertasAereasResult] => )

我需要返回一个包含所有值的数组。

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

1 回答 1

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);
于 2013-07-18T08:17:50.480 回答