Ksoap2 Java.lang.runtimeexception: Cannot Serialize
I am trying to use a method from a .net web service. The code behind for the web service has a '/' at the end of the namespace [WebService(Namespace = 'http://www.mynamespace.com/'
Solution 1:
I figured it out...
This is inside an AsyncTask<>() if it wasn't already obvious with the Override doInBackground() method. The input parameter is a Integer...
type.
protected SoapObject doInBackground(Integer... branchNumber)
I don't know what the ellipsis does exactly, but I know it makes the parameter an array.
I was passing an integer array into the request object rather than a specific array element.
changing from
request.addProperty("branchNumber", branchNumber);
to
request.addProperty("branchNumber", branchNumber[0]);
fixed the issue.
Thank you @Paul-Jan and @beginner! I appreciate your answers!
Solution 2:
Instead of
PropertyInfo inputArgs = new PropertyInfo();
inputArgs.setName("branchNumber");
inputArgs.setValue(branchNumber);
inputArgs.setType(Integer.class);
request.addProperty(inputArgs);
try this:
request.addProperty("branchNumber", branchNumber);
Solution 3:
For those who want to add a list of Object as a parameter of web service :
List<Object> vect = new Vector<Object>();
vect.add("Element1");
vect.add("Element2");
vect.add("Element3");
PropertyInfo tabProp =new PropertyInfo();
tabProp.setName("LIST_PARAM");
tabProp.setValue(vect);
request.addProperty(tabProp );
Of course there is no need to note that the Async Task must implements the method :
protectedStringdoInBackground(List<Object>... params){
....
....
}
Post a Comment for "Ksoap2 Java.lang.runtimeexception: Cannot Serialize"