1

I created XML string using XmlSerializer and it prints out as

<tag> string </tag>

I want to add the xml string to SOAPObject and get response from web service. So I added and when I print out the requestDump the < and > are being replaced by &lt ; and &gt ;

I assume that it is being encoded by HttpTransportSE.

I read here Android Ksoap2 web service for download/Upload and it says I need to convert my string to binary before uploading? I am confused because the API tells us to upload xml. Currently, there is no error or exception but the result is empty. I think it's the encoding problem.

Any help will be appreciated. Thanks!

Community
  • 1
  • 1
  • Probably I'm late for you but this may help: http://stackoverflow.com/questions/27164419/passing-xmldataset-as-parameter-ksoap2-android – Doppelganger Jan 22 '15 at 14:38

2 Answers2

0

When using ksoap2 you don't have to handle the serialization yourself. If you want to add an entry to the xml like this:

<tag>string</tag>

Then you just have to call this when constructing the SoapObject you are sending to the server:

soapObject.addProperty("tag", "string");

Also modifying the requestDump is never a good idea. This output is just for debug purposes. That's the reason why you have to set transport.debug = true; for the requestDump or responseDump to even appear. As I said above just use the addProperty() and addSoapObject() methods to construct your request.

Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
  • Thanks for your help. But it doesn't really help me. I understand what you mean. I need xml in that "string". Transport debug is set to true. I did use 'addProperty()' and 'addSoapObject()' too but the result is empty. – KingOfMyHeart Apr 23 '14 at 01:58
  • 2
    Oh now I understand what you mean. You want to send the xml `string`, but you are worried because in the request dump the < and > etc are encoded? That is completely normal, you don't have to worry about that. Since the `SoapEnvelope` is XML you cannot send a String containing < or > or any other important character, to get around this problem all < and > etc in the payload are replaced with encoded characters like `<` and `>`. When the request reaches your server those encoded characters will be converted back to < or >. – Xaver Kapeller Apr 23 '14 at 02:04
0

Use SoapObject.setInnerText("..."); to add CDATA text to a Ksoap2 request.

Randnum
  • 1,360
  • 4
  • 32
  • 48