我在我的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 中解析此肥皂响应。
您可以参考我使用 Magento SOAP api 的 Android 应用程序的 github 链接。我已经解析它并显示了。
https://github.com/sudhirbelagali/SnowDogSoapAndroid
这个应用程序为您提供来自 magento SOAP 协议的会话 ID
下面是解析 ProductList 输出的代码。参考这个
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));