LuisCastilloSalinas / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Xml value for SoapObject property gets encoded, which causes webservice to fail #89

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a property info with a string key, and some xml for value
2. Set HttpTransportSE object to debug, and inspect requestDump when sending 
the envelope
3. Now all the start and end xml tags have been transformed to html encoding.

What is the expected output? What do you see instead?
The xml should be sent to the service as valid xml. The start and end tags 
where html encoded, causing the webservice to disgard the xml.

What version of the product are you using? On what operating system?
ksoap2-android-assembly-2.5.8-jar-with-dependencies

Please provide any additional information below.

Original issue reported on code.google.com by mortenah...@gmail.com on 2 Nov 2011 at 8:24

GoogleCodeExporter commented 9 years ago
can you provide your code that you send a xml string to webservice ??
My code is send xml string to web service success , nothing problem .

Original comment by tauit.d...@gmail.com on 2 Nov 2011 at 10:07

GoogleCodeExporter commented 9 years ago
Yes sure.

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);        

PropertyInfo RequestProp = new PropertyInfo();
RequestProp.setName("RequestXml");
String requestContent = "<request type=\""+this.getRequestTypeToString()+"\" 
xmlns=\"\">"+this.RequestContent+"</request>";
RequestProp.setValue(requestContent);
Request.addProperty(RequestProp);

SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setAddAdornments(false);
envelope.setOutputSoapObject(Request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" 
encoding=\"utf-8\"?>");
try {
    androidHttpTransport.call(SOAP_ACTION, envelope);
    Log.e("Soap error, request ",androidHttpTransport.requestDump);
    Log.e("Soap error, response ",androidHttpTransport.responseDump);
} catch (Exception e) {
    e.printStackTrace();
    Log.e("SoapError",e.getLocalizedMessage());
}

The requestDump writes out ">request type=\"start\" xmlns=\"\"><display 
height=\"800\" width=\"480\" ppi=\"240\" /></request>" which is correct, but 
the webservice returns with an error. If I send a self gererated soap message 
to the server and avoid the html encoding it works fine. If I use the encoding 
it fails.

Hope you can help.

Original comment by mortenah...@gmail.com on 2 Nov 2011 at 10:16

GoogleCodeExporter commented 9 years ago
The error from responseDump is:
System.Web.Services.Protocols.SoapException: Server was unable to read request. 
---> System.InvalidOperationException: There is an error in XML document (1, 
475). ---> System.InvalidOperationException: The specified node cannot be 
inserted as the valid child of this node, because the specified node is the 
wrong type.

Original comment by mortenah...@gmail.com on 2 Nov 2011 at 11:38

GoogleCodeExporter commented 9 years ago
I test with my webservice , it's correctly.
are you sure that you pass agrument for RequestXml method is correct?

P/S: Mywwebservice in php , so that, it may be diffirent from your.

Original comment by tauit.d...@gmail.com on 2 Nov 2011 at 12:11

GoogleCodeExporter commented 9 years ago
The problem is that my webservice expects an xmldocument, and a html encoded 
string is apparently not recognized as such. It works if i change the method to 
receive a string and convert the string into an xml document in the method.
However, my iPhone equivalent sends it as an xmldocument, and does not allow me 
to specify the type to send to be a string. So it is recognized as a 
xmldocument by the service, and a string does not work.

Original comment by mortenah...@gmail.com on 2 Nov 2011 at 12:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
RequestXML receive a agrument as XmlDocument , but you send a html encode 
string--> error

You can change RequestXml have prototype like this : RequestXml ( string s)

You can read xml Document to string, and send it to wwebservice

Original comment by tauit.d...@gmail.com on 2 Nov 2011 at 1:05

GoogleCodeExporter commented 9 years ago
So is this actually an issue and you could provide a fix or is this just a 
problem with your implementation then?

Original comment by mosa...@gmail.com on 8 Dec 2011 at 5:30

GoogleCodeExporter commented 9 years ago
Is it solved? I have the same problem. I've debuged code and i think that 
problem is in a method createRequestData. 

byte[] requestData = createRequestData(envelope);

After calling createRequestData, byte[] contains encoded html.

Original comment by rumaczy...@gmail.com on 25 Jul 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Ping.. is this actually still an issue with 3.0.0-RC.4

Original comment by mosa...@gmail.com on 12 Nov 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Hi, I've just tested and this problem happens on 3.0.0-RC.4.

Do you think there's a workaround or some quick fix to it?

Debugging I've reach the same point as mentioned in previously message, after 
byte[] requestData = createRequestData(envelope);
the xml content of any parameter is html enconded.

Thanks

Original comment by marcelo....@gmail.com on 22 Nov 2012 at 7:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Anybody knows if this was fixed on the new 3.1.1?

Any other workaround?

Thanks

Original comment by omiate...@gmail.com on 15 Jan 2014 at 7:57

GoogleCodeExporter commented 9 years ago
Maybe this helps: 
http://stackoverflow.com/questions/27164419/passing-xmldataset-as-parameter-ksoa
p2-android

Original comment by kewl...@gmail.com on 22 Jan 2015 at 2:34