Problems with Android KSoap2 and Array

I am using Ksoap2 to call a web service from Android. I create a request, but the .call () method throws the following exception:

07-22 11:12:57.718: W/System.err(9582): java.lang.NumberFormatException: Invalid int: "][2" 07-22 11:12:57.728: W/System.err(9582): at java.lang.Integer.invalidInt(Integer.java:138) 07-22 11:12:57.728: W/System.err(9582): at java.lang.Integer.parse(Integer.java:375) 07-22 11:12:57.738: W/System.err(9582): at java.lang.Integer.parseInt(Integer.java:366) 07-22 11:12:57.738: W/System.err(9582): at java.lang.Integer.parseInt(Integer.java:332) 07-22 11:12:57.738: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.getIndex(SoapSerializationEnvelope.java:287) 07-22 11:12:57.748: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.readVector(SoapSerializationEnvelope.java:304) 07-22 11:12:57.758: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.readInstance(SoapSerializationEnvelope.java:446) 07-22 11:12:57.758: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:387) 07-22 11:12:57.768: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273) 07-22 11:12:57.768: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389) 07-22 11:12:57.788: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273) 07-22 11:12:57.788: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389) 07-22 11:12:57.798: W/System.err(9582): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:151) 07-22 11:12:57.798: W/System.err(9582): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140) 07-22 11:12:57.798: W/System.err(9582): at org.ksoap2.transport.Transport.parseResponse(Transport.java:118) 07-22 11:12:57.808: W/System.err(9582): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:253) 07-22 11:12:57.808: W/System.err(9582): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116) 07-22 11:12:57.808: W/System.err(9582): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111) 

If I put the same request in SoapUI, the call will work.

Even using KSoap2, I get the answer, but the error seems to be in the analysis of the Ksoap2 answer.

I believe this part of the answer is throwing an error:

 <data soapenc:arrayType="xsd:anyType[][2]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 

Ksoap2 thinks that [2 of any type [] [2] is supposed to be int.

Is this a bug in ksoap2? Is there a workaround for this?

+4
source share
2 answers

07-22 11:12: 57.738: W / System.err (9582): at org.ksoap2.serialization.SoapSerializationEnvelope.getIndex (SoapSerializationEnvelope.java:287)

From ksoap v2.1.2 source: this is the SoapSerializationEnvelope.getIndex (String value, int start, int dflt) method that throws a NumberFormatException :

 private int getIndex(String value, int start, int dflt) { if (value == null) return dflt; return value.length() - start < 3 ? dflt : Integer.parseInt(value.substring(start + 1, value.length() - 1)); } 

And this is the SoapSerializationEnvelope.getIndex (String value, int start, int dflt) method from v2.0.1:

 private int getIndex(String value, int start, int dflt) { if (value == null) return dflt; return value.length() - start < 3 ? dflt : Integer.parseInt(value.substring(start + 1, value.length() - 1)); } 

Take a look at the bug report listed at http://sourceforge.net/p/kobjects/bugs/14/ . This is the same problem as yours. The bug report mentions version 2.0.1. And getIndex(String value, int start, int dflt) not changed between versions 2.0.1 and 2.1.2.

Another report: Unable to process two-dimensional arrays

0
source

I think he expects an int value in the first square bracket of soapenc: arrayType = "xsd: anyType [] [2]"

Since it does not receive any int value, an exception has occurred.

+1
source

Source: https://habr.com/ru/post/1492749/


All Articles