【问题标题】:assigning SOAP value to a variable [duplicate]将 SOAP 值分配给变量 [重复]
【发布时间】:2021-07-11 03:48:52
【问题描述】:

例如,我试图从这个 SOAP 调用中提取 ServiceType。在下面的示例中,它显示 FTTN

if (VocusDevController::login()) {

            $client = new SoapClient('wsdl/VocusSchemas/WholesaleServiceManagement.wsdl', array(
                'trace' => 1,
                'exception' => true
            ));
        
            try {
        
                $response = $client->Get(array(
                    "AccessKey" => "SOMEKEY", 
                    "ProductID" => "FIBRE",
                    "Scope" => "QUALIFY",
                    "Parameters" => array('Param' => array('_' => 'LOC000023125730', 'id' => 'DirectoryID'))
                ));

                echo '<pre>';
                print_r($response);
                echo '</pre>';
                echo '<hr>';
                // $output = $response->Parameters->Param->ServiceType; // This is where I am trying to extract ServiceType
            } catch (Exception $exception) {
                echo 'Exception Thrown: ' . $exception->getMessage();
            }
        }

这是我从上述调用中得到的输出

stdClass Object
(
    [TransactionID] => 17A935CDC7E1906
    [ResponseType] => SYNC
    [Parameters] => stdClass Object
        (
            [Param] => Array
                (
                    [0] => stdClass Object
                        (
                            [_] => PASS
                            [id] => Result
                        )

                    [1] => stdClass Object
                        (
                            [_] => FTTN
                            [id] => ServiceType
                        )

                    [2] => stdClass Object
                        (
                            [_] => 13
                            [id] => ServiceClass
                        )

                    [3] => stdClass Object
                        (
                            [_] => Type 1
                            [id] => ConnectionType
                        )

                    [4] => stdClass Object
                        (
                            [_] => 20210910
                            [id] => CopperDisconnectionDate
                        )

                    [5] => stdClass Object
                        (
                            [_] => Urban
                            [id] => Zone
                        )

                    [6] => stdClass Object
                        (
                            [_] => FALSE
                            [id] => DevelopmentCharge
                        )

                    [7] => stdClass Object
                        (
                            [_] => CSA200000000332
                            [id] => CSA
                        )

                    [8] => stdClass Object
                        (
                            [_] => Auto-Assigned
                            [id] => CVCID
                        )

                    [9] => stdClass Object
                        (
                            [_] => CPI300009724591N/ALine In Use13N/AFALSE5Mbps,10Mbps,20Mbps33-3577-82TRUEFALSE
                            [id] => CopperPairRecord
                        )

                    [10] => stdClass Object
                        (
                            [_] => LOC000023125730NBNLOT: 18 1 CHILDS CCT BELROSE NSW
                            [id] => BroadbandAddressRecord
                        )

                )

        )

)

我正在尝试使用 $output = $response-&gt;Parameters-&gt;Param-&gt;ServiceType; 提取 ServiceType,但是,我只是收到此错误:-

ErrorException
Attempt to read property "ServiceType" on array

所以,我显然试图错误地提取它。有人可以阐明我做错了什么吗?谢谢

【问题讨论】:

    标签: php soap soap-client


    【解决方案1】:

    感谢@miken32 在这里回复Accessing value in PHP SoapClient response element with attribute 我已使用以下方法成功拉取 ServiceType。

            $data = $response->Parameters->Param[1]->_;
            dd($data);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 1970-01-01
      • 1970-01-01
      • 2021-03-02
      • 1970-01-01
      • 2020-11-21
      • 2021-01-01
      相关资源
      最近更新 更多