webservice没有返回数组

时间:2013-07-17 21:33:08

标签: php arrays web-services soap

我需要有关此网络服务的帮助,它会返回此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;
    }
?>

1 个答案:

答案 0 :(得分: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);