(对不起,如果这听起来很傲慢......我没有很多代码要粘贴,所以我想我会彻底描述)
我正在使用 FedEx 的SOAP
WSDL
s 和PHP
's native SoapClient
。
services RateService
,ShipService
等具有RateService->getRates(), ShipService->processShipment(), etc.
接受数组作为参数的方法。
我从“硬编码”数组开始,能够通过 WSDL 验证数组,连接到 FedEx 的服务器并获得成功的响应。
这是令人费解的部分。
我拿了我的“硬编码”数组并围绕它们构建了一个类,以便可以“动态”构建数组(就像你一样)。
当我通过 SoapClient 运行“动态创建”的数组时,出现以下错误:
对于费率请求
FedEx SoapFault 错误:不允许属性(不允许使用通配符):元素中的 ID ShippingChargesPayment@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",
),
);
这是通过引用传递的问题吗?