使用KSOAP2从Webservice到Android的整数数组

时间:2013-06-06 04:46:37

标签: android arrays android-ksoap2

我想将VB.NET Web服务中的单维双数组传递给Android应用程序。

请告诉我怎么做?

1 个答案:

答案 0 :(得分:1)

public ArrayList<HashMap<String, String>> getlogindata(String Tname,
            String col) {
        try {

            hmALData = new ArrayList<HashMap<String, String>>();

            SoapObject request = new SoapObject(NAMESPACE,
                    SOAP_METHOD_GETDATATBL);

            String ttnm = Tname.trim();

            request.addProperty("TName", ttnm);
            request.addProperty("ColumnNameStr", "*");

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);

            envelope.dotNet = true;

            envelope.setOutputSoapObject(request);

            HttpTransportSE aht = new HttpTransportSE(URL, 60000);

            aht.call(SOAP_ACTION_GETDATATBL, envelope);

            SoapObject response = (SoapObject) envelope.bodyIn;

            System.out.println("Response : " + response);

            System.out
                    .println("ResponseCount : " + response.getPropertyCount());

            SoapObject con = (SoapObject) response.getProperty(0);

            System.out.println("REsult One: " + con.toString());

            SoapObject con1 = (SoapObject) con.getProperty(1);

            System.out.println("REsult One1: " + con1.toString());

            if (con1.toString().trim().equals("anyType{}")) {
                return hmALData;
            }
            SoapObject con2 = (SoapObject) con1.getProperty(0);

            System.out.println("REsult One2: " + con2.toString());
            System.out.println("one2 Count: " + con2.getPropertyCount());

            for (int i = 0; i < con2.getPropertyCount(); i++) {

                SoapObject con3 = (SoapObject) con2.getProperty(i);

                System.out.println("REsult Three: " + con3.toString());

                hmData = new HashMap<String, String>();
                if (con3 instanceof SoapObject) {
                    SoapObject getAll = (SoapObject) con3;


                    hmData.put("LoginId", getAll.getProperty("LoginId")
                            .toString());
                    hmData.put("Password", getAll.getProperty("Password")
                            .toString());


                    }

                hmALData.add(hmData);
            }

            return hmALData;
        } catch (SocketTimeoutException e) {
            return hmALData;
        }

        catch (IOException e) {
            System.out.println("IOException : " + e);
            e.printStackTrace();

        } catch (XmlPullParserException e) {
            System.out.println("XMLPullParserException : " + e);
            e.printStackTrace();
        } catch (RuntimeException e) {
            e.printStackTrace();
        }

        return hmALData;
    }