eBay Trading API:通过SOAP传递具有相同名称的元素

时间:2014-06-05 12:50:10

标签: php soap ebay

我需要通过SOAP传递多个NameValueLists,但我不知道如何包含他们的数据。

这应该是什么样子:

<Variations>
      <VariationSpecificsSet>
        <NameValueList>
          <Name>Size</Name>
          <Value>XL</Value>
        </NameValueList>
        <NameValueList>
          <Name>Color</Name>
          <Value>Black</Value>
        </NameValueList>
    </VariationSpecificsSet>
</Variations>

我的部分PHP代码:

$params->Item->Variations = new ArrayObject();
$params->Item->Variations->VariationSpecificsSet = new ArrayObject();
$params->Item->Variations->VariationSpecificsSet->NameValueList = new ArrayObject();

$list = new ArrayObject();
$list->name = 'title';
$list->value = "value";
$arr[0] = $list;
$arr[1] = $list;

$params->Item->Variations->VariationSpecificsSet->NameValueList = $arr;
$ebay->ebayCall( "VerifyAddFixedPriceItem", $params );

$ params的调试输出:

[Variations] => ArrayObject Object
    (
        [VariationSpecificsSet] => ArrayObject Object
            (
                [NameValueList] => Array
                    (
                        [0] => ArrayObject Object
                            (
                                [name] => title
                                [value] => value
                                [storage:ArrayObject:private] => Array
                                    (
                                    )

                            )

                        [1] => ArrayObject Object
                            (
                                [name] => title
                                [value] => value
                                [storage:ArrayObject:private] => Array
                                    (
                                    )

                            )

                        [2] => ArrayObject Object
                            (
                                [name] => title
                                [value] => value
                                [storage:ArrayObject:private] => Array
                                    (
                                    )

                            )

                    )

                [storage:ArrayObject:private] => Array
                    (
                    )

            )

        [storage:ArrayObject:private] => Array
            (
            )

    )

结果请求:没有名称,NameValueLists中没有值

<ns1:Variations>
    <ns1:VariationSpecificsSet>
        <ns1:NameValueList/>
        <ns1:NameValueList/>
        <ns1:NameValueList/>
    </ns1:VariationSpecificsSet>
</ns1:Variations>

如何在NameValueLists中正确放置数据?调试输出对我来说似乎很好,但它不会出现在xml中。我不能成为第一个......?

修改:我在SO上发现了一个问题,它正好描述了我的问题: Php soap client multiple node 在问这里之前我尝试过这种方法,但它仍然不适合我。我猜,它与eBay wsdl有关,但我无法弄清楚究竟是什么

1 个答案:

答案 0 :(得分:1)

$list->name$list->value上缺少大写字母就是答案。希望有时能帮助别人。哎呀