gpt4 book ai didi

php - 令人费解的 PHP Soap 故障

转载 作者:搜寻专家 更新时间:2023-10-31 22:11:48 27 4
gpt4 key购买 nike

(抱歉,如果这听起来有点傲慢...我没有太多代码可以粘贴,所以我想我应该对描述进行透彻)

我将 FedEx 的 SOAP WSDLPHP 的原生 SoapClient 一起使用。

服务 RateServiceShipService 等具有方法 RateService->getRates()、ShipService->processShipment() 等它接受一个数组作为参数。

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

这是令人费解的部分。

我采用“硬编码”数组并围绕它们构建了一个类,以便可以“动态”构建数组(就像您所做的那样)。

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

对于费率请求

FedEx SoapFault error: Attribute not allowed (no wildcards allowed): id in element ShippingChargesPayment@http://fedex.com/ws/rate/v13

对于发货请求

SOAP-ERROR: Encoding: Unresolved reference '#ref1'

似乎数组未通过 WSDL 进行验证。

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

我的发货类以包含“空白”请求数组的私有(private)变量开始:

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",
),
);

关于php - 令人费解的 PHP Soap 故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12198229/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com