0

我需要使用 SOAP 生成以下 XML:

                    ...
                <InternationalShippingServiceOption>
                        <ShippingService>StandardInternational</ShippingService>
                        <ShippingServiceCost currencyID="USD">39.99</ShippingServiceCost>
                        <ShippingServicePriority>1</ShippingServicePriority>
                        <ShipToLocation>CA</ShipToLocation>
                    </InternationalShippingServiceOption>
                    ...

所以我在 PHP 中有以下 SOAP 数组来执行此操作:

$params =   array(
         'InternationalShippingServiceOption' => array(
            'ShippingService'=>'StandardInternational',
            'ShippingServiceCost'=>39.99,
            'ShippingServicePriority'=>1,
            'ShipToLocation'=>'CA',
        )
    )
$client = new eBaySOAP($session); //eBaySOAP extends SoapClient
$results = $client->AddItem($params);

一切都很好,除了我没有在 XML 的 ShippingServiceCost 标记中生成currencyID="USD"属性。我该怎么做呢?

4

2 回答 2

0

为什么,我很高兴你问。我今天刚刚解决了这个问题。

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

然后照常继续。

如果您需要更多帮助,请告诉我。

于 2010-02-10T01:42:40.017 回答
0

您不需要使用 SoapVar。这有效(至少对我来说):

$params =   array(
         'InternationalShippingServiceOption' => array(
            'ShippingService'=>'StandardInternational',
            'ShippingServiceCost' => array('_' => 39.99, 'currencyID' => 'USD')
            'ShippingServicePriority'=>1,
            'ShipToLocation'=>'CA',
        )
    )

我将这种技术与 PayPal SOAP API 一起使用。

于 2010-05-04T07:11:02.890 回答