令人困惑的PHP肥皂故障

时间:2012-08-30 13:40:10

标签: php soap fedex

(对不起,如果这听起来很光顾......我没有很多代码可以粘贴,所以我想我会对描述做得很透彻)

我正在使用联邦快递的SOAP WSDLPHP的原生SoapClient

服务RateServiceShipService等具有接受数组作为参数的方法RateService->getRates(), ShipService->processShipment(), etc.

我从“硬编码”数组开始,能够通过WSDL验证数组,连接到FedEx的服务器并获得成功的响应。

这是令人费解的部分。

我使用了“硬编码”数组并围绕它们构建了一个类,因此可以“动态”构建数组(就像你一样)。

当我通过SoapClient运行“动态创建”数组时,出现以下错误:

对于费率请求

  

FedEx SoapFault错误:不允许属性(不允许使用通配符):   元素ShippingChargesPayment中的id @ http://fedex.com/ws/rate/v13

对于船舶请求

  

SOAP-ERROR:编码:未解析的引用'#ref1'

似乎数组没有通过WSDL验证。

更新 - 我设法调试问题并使其正常工作,但我不确定为什么这是一个问题....这里是代码和进一步说明...以防万一有人想解释原因。

我的货件类以包含“空白”请求数组的私有变量开头:

class Shipment {
    private $_fedex_request = array(
        ...
        "RequestedShipment" => array(
            ...
            "ShippingChargesPayment" => array(
                "PaymentType" => "SENDER",
                "Payor" => array(
                    "ResponsibleParty" => array(
                        "AccountNumber" => null,
                        "Contact" => array(
                            "EMailAddress" => null,
                        ),
                    ),
                ),
            ),
            "CustomsClearanceDetail" => array(
                "DutiesPayment" => array(
                    "PaymentType" => "SENDER",
                    "Payor" => array(
                        "ResponsibleParty" => array(
                            "AccountNumber" => null,
                            "Contact" => array(
                                "EMailAddress" => null,
                            ),
                        ),
                    ),
                ),
            ),
        ),
    );
}

我有几种方法更新“空白”请求,在其中一种方法中,我有这个:

$ResponsibleParty = array(
    'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
    'Contact' => array(
        'EMailAddress' => "name@domain.com",
    ),
);

$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = $ResponsibleParty;
$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty'] = $ResponsibleParty;

....我改为:

$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = array(
    'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
    'Contact' => array(
        'EMailAddress' => "name@domain.com",
    ),
);

$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty']= array(
    'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
    'Contact' => array(
        'EMailAddress' => "name@domain.com",
    ),
);

这是一个参考问题吗?

1 个答案:

答案 0 :(得分:0)

$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
    'EMailAddress' => "name@domain.com",
),
);

看来这两者并不相等。

$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty'] = Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
    'EMailAddress' => "name@domain.com",
),
);

我猜你的意思是写

$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty'] = 
array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
    'EMailAddress' => "name@domain.com",
),
);