php boolean value as argument抛出编码错误

时间:2017-08-14 14:47:16

标签: php

当我尝试将一个布尔值作为参数放在一个函数调用中时,我得到的是我缺少一个属性

// try to get orders
try {
    $order = new Order($auth_login, $auth_password, $live_mode);
    $orders = $order->findOrdersBySubscriptionId($sessionId, $subscriptionId, (bool) false);
} catch (Exception $e) {
    var_dump($e);
}

这会出现此错误:

SoapFault Object
(
    [message:protected] => SOAP-ERROR: Encoding: object has no 'onlyOnGoing' property
        Array
            (
                [0] => Array
                    (
                        [Session] => 12345
                        [SubscriptionId] => 30520
                        [OnlyOnGoing] => 
                    )

            )

    )

)

我也试过(而不是(bool) false):

FALSEFalsefalse

没有工作!

修改

我浏览了Orders并找到了这一部分:

public function findOrdersBySubscriptionId($session, $subscriptionId, $onlyOnGoing) {
    try {
        $result = $this->client->findOrdersBySubscriptionId(array("Session" => $session, "SubscriptionId" => $subscriptionId, "OnlyOnGoing" => $onlyOnGoing));
        return $result;
    } catch (Except $e) {
        return array("Error" => $e->getMessage());
    }
}

我将"onlyOnGoing" => $onlyOnGoing更改为"OnlyOnGoing" => $onlyOnGoing

现在我收到此错误(我还将输出从print_r更改为var_dump):

object(SoapFault)#2668 (10) {
["message":protected]=>
string(58) "SOAP-ERROR: Encoding: object has no 'onlyOnGoing' property"
["trace":"Exception":private]=>
array(6) {
    [0]=>
    array(6) {
        [0]=>
        string(26) "findOrdersBySubscriptionId"
        [1]=>
        array(1) {
        [0]=>
        array(3) {
            ["Session"]=>
            string(36) "4D398084-9B08-38A3-362E-880111364DD8"
            ["SubscriptionId"]=>
            int(30520)
            ["OnlyOnGoing"]=>
            bool(false)
        }
        }
    }
    }
}

0 个答案:

没有答案