Parsing ksoap2 response

后端 未结 5 928
迷失自我
迷失自我 2020-11-29 07:57

I use a ksoap2 lib for communicating from android client with SOAP web service. Great job was done by ksoap team, but the problem is, there is no any good example how to use

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 08:20

    My Project it's work. Hope this hepls.

            SoapObject requestx = new SoapObject(NAMESPACE, METHOD_NAME);
    
            SoapSerializationEnvelope envelopex = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelopex.dotNet = true;
            envelopex.setOutputSoapObject(requestx);
            HttpTransportSE httpTransportx = new HttpTransportSE(URL);          
    
            try  {                    
                httpTransportx.call(SOAP_ACTION, envelopex);
                SoapObject responsex = (SoapObject)envelopex.getResponse(); // not envelopex.bodyIn;
    
                 int i=0;
                 int RCount=responsex.getPropertyCount();
                 int[] tbIDArray = new int[RCount+1];
                 int[] iMonthAarray = new int[RCount+1];
                 int[] iYearAarray = new int[RCount+1];
                 String[] sDetailAarray = new String[RCount+1];
    
                 for (i = 0; i < RCount; i++) {
                     Object property = responsex.getProperty(i);
                     if (property instanceof SoapObject) {
                         SoapObject info = (SoapObject) property;
                         String tbID = info.getProperty("tbID").toString();
                         String iMonth = info.getProperty("iMonth").toString();
                         String iYear = info.getProperty("iYear").toString();
                         String sDetail = info.getProperty("sDetail").toString();
    
                        tbIDArray[i] =Integer.valueOf(tbID);
                        iMonthAarray[i] =Integer.valueOf(iMonth);
                        iYearAarray[i] =Integer.valueOf(iYear);
                        sDetailAarray[i] =sDetail;
                     }//if (property instanceof SoapObject) {
                 }//for (i = 0; i < RCount; i++) {
    
    
            }  catch (Exception exception)   {
                MsgBox1(exception.toString() , "Error");
            }
    

提交回复
热议问题