ksoap2 serialization problem

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

ksoap2 serialization problem

Postby Frionel » Fri Sep 23, 2011 8:09 am


I am working on a company which has a .net website and webservices.
The webservice are wsdl soad.

I need to comunicate my android device with those webservices, so,
after a lot of research, I found ksoap2.

First, I tried a simple comunication with strings, and it works fine!
But now, I need to work with complex objects, so I followed this
tutorial: http://seesharpgears.blogspot.com/2010/ ... -with.html

It uses "KvmSerializable" for the work. But when I tried with my
webservices I get the error below:

"SoapFault - faultcode: 'a:DeserializationFailed' faultstring: 'The
formatter threw an exception while trying to deserialize the message:
There was an error while trying to deserialize parameter http://tempuri.org/:user.
The InnerException message was 'Element user from namespace http://tempuri.org/
cannot have child contents to be deserialized as an object. Please use
XmlNode[] to deserialize this pattern of XML.'. Please see
InnerException for more details.' faultactor: 'null' detail: null"

This is my code:

Code: Select all
package Test.WebService;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class WebServiceTestActivity extends Activity {
   private static final String SOAP_ACTION = "urn:asdf:qwerty:WebService:Sorter/SecurityLoginCheckPrueba"; //urn:Disval:SML:WebService:Sorter
   private static final String METHOD_NAME = "SecurityLoginCheckPrueba"; //"testAndroid";
   private static final String NAMESPACE = "http://tempuri.org/";//"http://tempuri.org/";
   private static final String NAMESPACE_SERIALIZABLE = "urn:asdf:qwerty:Common:Serializable";
   private static final String URL = "http://xxx.xx.xx.xx/Sorter.svc?wsdl";  //MI local ip
    public void onCreate(Bundle savedInstanceState) {
        TextView tv = (TextView)findViewById(R.id.txt);
       //Inicializar variable para enviar:
       UserPrueba u = new UserPrueba();
       u.setProperty(0, "123456");
       u.setProperty(1, "s---l");
       u.setProperty(2, "---");
       PropertyInfo pi = new PropertyInfo();
       pi.setName("user"); //Nombre de la variable del parametro del contrato
       pi.setType(u.getClass()); //u.getClass()
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
       //request.addProperty("aux", "hola");
       //Crear la llamada:
        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet = true;

        soapEnvelope.setOutputSoapObject(request);        //soapEnvelope.bodyOut = request;
        //soapEnvelope.addMapping(NAMESPACE, "u",new UserPrueba().getClass());
        HttpTransportSE aht  = new HttpTransportSE(URL);
        //aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
           aht.call(SOAP_ACTION, soapEnvelope);
           SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
           SoapObject response = (SoapObject)soapEnvelope.getResponse();
           //SoapObject response = (SoapObject)soapEnvelope.getResponse();
           tv.setText("Resultado: " + resultString);
        } catch(Exception e){


Any ideas? Also, is there any option to extract the .xml it creates?

Once Poster
Once Poster
Posts: 1
Joined: Fri Sep 23, 2011 8:08 am


Re: ksoap2 serialization problem

Postby prasildas » Tue Sep 27, 2011 7:26 am

IN the above post I find the code have no problem but there is some mistakes in the declaration of the
url - it should end with .asmx
eg: String URL = "
check the above , mostly it will work.
Once Poster
Once Poster
Posts: 1
Joined: Tue Sep 27, 2011 7:15 am


Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests