简体   繁体   English

无法在Android中解析Magento soap API响应

[英]Unable to parse Magento soap api response in Android

I implement ksoap2 api in my android app for calling Magento Soap API, I got session id successfully, I'm getting response of category listing. 我在Android应用程序中实现了ksoap2 api来调用Magento Soap API,我成功获取了会话ID,并且得到了类别列表的响应。 I got repose like 我像

<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>

The issue is I'm unable to parse this soap response in android object or Arraylist. 问题是我无法在android对象或Arraylist中解析此肥皂响应。

you can refer this github link of my android application which uses Magento SOAP api . 您可以引用我的使用Magento SOAP api的android应用程序的github链接。 and I have parsed it and i displayed . 并且我已经解析它并显示出来。

https://github.com/sudhirbelagali/SnowDogSoapAndroid https://github.com/sudhirbelagali/SnowDogSoapAndroid

this app gives you session id from magento SOAP protocol 这个程序为您提供了来自magento SOAP协议的会话ID

Below is the code for parsing the output of ProductList .refere this 以下是用于解析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));

If this helped you Please mark this as the solution for your questions and up vote me please . 如果这对您有帮助,请将此标记为您的问题的解决方案,请投票给我。 Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM