题
我需要用SOAP生成以下XML:
...
<InternationalShippingServiceOption>
<ShippingService>StandardInternational</ShippingService>
<ShippingServiceCost currencyID="USD">39.99</ShippingServiceCost>
<ShippingServicePriority>1</ShippingServicePriority>
<ShipToLocation>CA</ShipToLocation>
</InternationalShippingServiceOption>
...
因此,我在PHP中有以下肥皂阵列来执行此操作:
$params = array(
'InternationalShippingServiceOption' => array(
'ShippingService'=>'StandardInternational',
'ShippingServiceCost'=>39.99,
'ShippingServicePriority'=>1,
'ShipToLocation'=>'CA',
)
)
$client = new eBaySOAP($session); //eBaySOAP extends SoapClient
$results = $client->AddItem($params);
一切都很好,除了我没有生成 CurrencyId =“ USD” XML中的ShippingservCost标签中的属性。我该怎么做呢?
解决方案
您不需要使用肥皂。这起作用(至少对我来说):
$params = array(
'InternationalShippingServiceOption' => array(
'ShippingService'=>'StandardInternational',
'ShippingServiceCost' => array('_' => 39.99, 'currencyID' => 'USD')
'ShippingServicePriority'=>1,
'ShipToLocation'=>'CA',
)
)
我正在使用Paypal Soap API使用此技术。
其他提示
为什么,我很高兴你问。我今天只是解决了这个问题。
$shippingsvccostwithid = new SoapVar(array('currencyID' => $whatever),SOAP_ENC_OBJECT, 'ShippingServiceCost', 'https://your.namespace.here.com/');
$params = array("InternationalShippingServiceOption" => array(
"ShippingService" => "StandardInternational",
"ShippingServiceCost" => $shippingsvccostwithid,
"ShippingServicePriority" => 1,
"ShipToLocation" => "CA"
);
然后继续正常。
如果您需要更多帮助,请告诉我。
不隶属于 StackOverflow