PHP中SOAP到XML的转换
我需要使用SOAP生成以下XML:PHP中SOAP到XML的转换,php,xml,soap,ebay-api,Php,Xml,Soap,Ebay Api,我需要使用SOAP生成以下XML: ... <InternationalShippingServiceOption> <ShippingService>StandardInternational</ShippingService> <ShippingServiceCost currency
...
<InternationalShippingServiceOption>
<ShippingService>StandardInternational</ShippingService>
<ShippingServiceCost currencyID="USD">39.99</ShippingServiceCost>
<ShippingServicePriority>1</ShippingServicePriority>
<ShipToLocation>CA</ShipToLocation>
</InternationalShippingServiceOption>
...
除了我没有在XML中的ShippingServiceCost标记中生成currencyID=USD属性之外,一切都很好。我该怎么做?为什么,我很高兴你问我。我今天刚解决了这个问题
$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"
);
然后像往常一样继续
如果您需要更多帮助,请告诉我。您不需要使用SoapVar。这至少对我有用:
$params = array(
'InternationalShippingServiceOption' => array(
'ShippingService'=>'StandardInternational',
'ShippingServiceCost' => array('_' => 39.99, 'currencyID' => 'USD')
'ShippingServicePriority'=>1,
'ShipToLocation'=>'CA',
)
)
我将此技术用于PayPal SOAP API。没有直接思考,添加了更多信息。如果您不介意的话,我有一个关于PayPal SOAP API的问题。如何设置“版本”?当我设置它时,标记变成“xsd:string”而不是“Version”。更多信息,谢谢!
$params = array(
'InternationalShippingServiceOption' => array(
'ShippingService'=>'StandardInternational',
'ShippingServiceCost' => array('_' => 39.99, 'currencyID' => 'USD')
'ShippingServicePriority'=>1,
'ShipToLocation'=>'CA',
)
)