我在我的Android应用程序中实现了ksoap2 api来调用Magento Soap API,我成功获得了会话ID,我得到了类别列表的响应。我喜欢
<callReturn xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">category_id</key>
<value xsi:type="xsd:string">1</value>
</item>
<item>
<key xsi:type="xsd:string">parent_id</key>
<value xsi:type="xsd:string">0</value>
</item>
<item>
<key xsi:type="xsd:string">name</key>
<value xsi:type="xsd:string">Root Catalog</value>
</item>
<item>
<key xsi:type="xsd:string">is_active</key>
<value xsi:nil="true"/>
</item>
<item>
<key xsi:type="xsd:string">position</key>
<value xsi:type="xsd:string">0</value>
</item>
<item>
<key xsi:type="xsd:string">image</key>
<value xsi:type="xsd:boolean">false</value>
</item>
<item>
<key xsi:type="xsd:string">meta_title</key>
<value xsi:nil="true"/>
</item>
<item>
<key xsi:type="xsd:string">meta_keywords</key>
<value xsi:nil="true"/>
</item>
<item>
<key xsi:type="xsd:string">level</key>
<value xsi:type="xsd:string">0</value>
</item>
<item>
<key xsi:type="xsd:string">children</key>
<value SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">category_id</key>
<value xsi:type="xsd:string">2</value>
问题是我无法在android对象或Arraylist中解析这个soap响应。
答案 0 :(得分:0)
你可以参考我使用Magento SOAP api的android应用程序的github链接。我解析了它,然后显示出来。
https://github.com/sudhirbelagali/SnowDogSoapAndroid
此应用程序为您提供magento SOAP协议的会话ID
下面是解析ProductList输出的代码.refere this
SoapObject resultRequestSOAP = (SoapObject) env.bodyIn;
Log.d("resultRequestSOAP ", resultRequestSOAP.toString());
SoapObject s_deals = (SoapObject) resultRequestSOAP.getProperty("storeView");
for (int i = 0; i < s_deals.getPropertyCount(); i++) {
Object property = s_deals.getProperty(i);
if (property instanceof SoapObject) {
SoapObject category_list = (SoapObject) property;
String CATEGORY = category_list.getProperty("product_id").toString();
list_Prod_id.add(CATEGORY);
String CATEGORY_URL = category_list.getProperty("sku").toString();
// list.add(CATEGORY_URL);
String CATEGORY_ICON = category_list.getProperty("name").toString();
list_Prod_id.add(CATEGORY_ICON);
list_Prod_id.add("*");
String CATEGORY_COUNT = category_list.getProperty("set").toString();
//list.add(CATEGORY_COUNT);
String SUPERTAG = category_list.getProperty("type").toString();
}
}
Log.d("List of Product id's ", String.valueOf(list_Prod_id));
如果这对您有所帮助请将此标记为您的问题的解决方案,并请投票给我。谢谢