我使用联邦快递的SOAP
WSDL
和PHP
的原生SoapClient
。
服务RateService
、ShipService
等具有接受数组作为自变量的方法RateService->getRates(), ShipService->processShipment(), etc.
。
我从"硬编码"阵列开始,能够通过WSDL验证阵列,连接到联邦快递的服务器并获得成功的响应。
以下是令人费解的部分。
我采用了我的"硬编码"数组,并围绕它们构建了一个类,这样数组就可以"动态"构建(就像您所做的那样)。
当我通过SoapClient运行"动态创建"的数组时,我得到了以下错误:
对于费率请求
FedEx SoapFault错误:不允许使用属性(不允许使用通配符):元素中的idShippingChargesPayment@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",
),
);
这是一个参考问题吗?
$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",
),
);