回响SoapClient响应数据

时间:2018-09-19 23:22:58

标签: php arrays object soap soap-client

我正在使用SoapClient调用Web服务。我从Soap请求中收到的结果很长,使用了复杂的对象和数组结构来存储数据。我无法从请求中提取数据点。我将如何提取此数据的任何帮助将不胜感激。

这是我的SoapClient请求:

<?php
$client = new SoapClient('http://services.chromedata.com/Description/7b?wsdl', array('trace' => 1));
$account = ['number'=>"", 'secret'=>"", 'country'=>"US",    'language'=>"en"];
$switch =  ["ShowAvailableEquipment",  "ShowExtendedTechnicalSpecifications", "ShowExtendedDescriptions"];
$vin = $_POST["b12"];

$result = $client->describeVehicle([
'accountInfo' => $account,
'switch' => $switch,
'vin' => $vin
]);

echo "<pre>";
var_dump($result);
echo "</pre>";
?>

Soap Response的一部分:

["technicalSpecification"]=>
 array(97) {
[0]=>
object(stdClass)#640 (2) {
  ["titleId"]=>
  int(1)
  ["value"]=>
  array(2) {
    [0]=>
    object(stdClass)#641 (3) {
      ["styleId"]=>
      array(2) {
        [0]=>
        int(292015)
        [1]=>
        int(292016)
      }
      ["value"]=>
      string(7) "Audi S4"
      ["condition"]=>
      string(3) "-PT"
    }
    [1]=>
    object(stdClass)#642 (3) {
      ["styleId"]=>
      array(2) {
        [0]=>
        int(292015)
        [1]=>
        int(292016)
      }
      ["value"]=>
      string(7) "Audi S4"
      ["condition"]=>
      string(0) ""
    }
  }
}
[1]=>
object(stdClass)#643 (2) {
  ["titleId"]=>
  int(2)
  ["value"]=>
  object(stdClass)#644 (3) {
    ["styleId"]=>
    array(2) {
      [0]=>
      int(292015)
      [1]=>
      int(292016)
    }
    ["value"]=>
    string(12) "5 Door Wagon"
    ["condition"]=>
    string(0) ""
  }
}
[2]=>
object(stdClass)#645 (2) {
  ["titleId"]=>
  int(6)
  ["value"]=>
  object(stdClass)#646 (3) {
    ["styleId"]=>
    array(2) {
      [0]=>
      int(292015)
      [1]=>
      int(292016)
    }
    ["value"]=>
    string(15) "All-Wheel Drive"
    ["condition"]=>
    string(0) ""
  }
}

关于如何提取“ Audi S4”,“ 5门旅行车”和“全轮驱动”的任何输入都是很棒的。

我正在尝试创建以下变量:

$vehicle
$bodyStyle
$drivetrain

回显它们以创建类似以下内容的

echo "Vehicle: ".$vehicle."<br>";
echo "Body Style: ".$bodystyle."<br>";
echo "Drivetrain: ".$drivetrain."<br>";

非常感谢您的帮助!

0 个答案:

没有答案