KSoap2 Android not valid SOAP
- by Rogier21
Hello all,
I am trying to post to my own test soap server (C#) with Android in combination with KSOAP2.
Now I have the specifications from the SOAP server, it expects:
POST /SharingpointCheckBarcode.asmx HTTP/1.1
Host: awc.test.trin-it.nl
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/checkBarcode"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://tempuri.org/">
<username>string</username>
<password>string</password>
</AuthHeader>
</soap:Header>
<soap:Body>
<checkBarcode xmlns="http://tempuri.org/">
<barcode>string</barcode>
</checkBarcode>
</soap:Body>
</soap:Envelope>
But what Android KSOAP2 sends out:
<?xml version="1.0" encoding="utf-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<checkBarcode xmlns="http://tempuri.org" id="o0" c:root="1">
<username i:type="d:string">test</username>
<password i:type="d:string">test</password>
<barcode i:type="d:string">2620813000301</barcode>
</checkBarcode>
</v:Body>
</v:Envelope>
With this code:
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("username", "test");
request.addProperty("password", "test");
request.addProperty("barcode", "2620813000301");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.encodingStyle = "test";
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);
androidHttpTransport.debug = true;
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.d("MyAPP", "----------------- " + androidHttpTransport.requestDump +"\r\n\r\n" + androidHttpTransport.responseDump);
((TextView)findViewById(R.id.lblStatus)).setText(androidHttpTransport.requestDump +"\r\n\r\n" + androidHttpTransport.responseDump);
} catch(Exception E) {
((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage());
}
The response I get back from the server is that there are no results found, so not an error, but when I test it with another App or PHP, it with the same data, it says it's OK.
I think it's because of the