Search code examples
androidsoapandroid-ksoap2

Ksoap for android not able to create the good soapEnvelop


The soap that I want is like this:

<int:userId>......</int:userId>

This is tested in SoapUI and with this I get the proper response back. What Ksoap makes is this:

<userId i:type="n0:undefined" xmlns:n0="http://namespace.com">.....</userId>

If I where to paste this code into SoapUI I get an error

'<Message>Error in line 5 position 88. Element 'http://namespace.com:
 userId'  
 contains data of the 'http://namespace.com:undefined' data contract.
 The deserializer has no knowledge of any type that maps to this contract. 
 Add the type corresponding to 'undefined' to the list of known types - 
 for example, by using the KnownTypeAttribute attribute or by 
 adding it to the list of known types passed to DataContractSerializer.
 </Message>

Maybe I am looking in the wrong direction for the solution but I am now asking how can I make ksoap omit the i:type part. If anyone can provide a different sollution, you will have my thank.


Solution

  • KSoap does have a tendancy to insert its own namespaces into each tag, which can give the output you're seeing.

    I had a similar such problem, which was easily resolved using the following :

    envelope.implicitTypes = true;
    

    Please also have a look at this other question on SO.