2014-06-05 25 views
0

我需要通過SOAP傳遞多個NameValueLists,但我不知道如何包含他們的數據。易趣交易API:通過SOAP傳遞具有相同名稱的元素

那應該如何看起來像:

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

我的PHP代碼部分:$ PARAMS

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

調試輸出:

[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

缺少大寫字母$list->name$list->value就是答案。希望有時幫助其他人。 grrr