Possible Duplicate:
Android, sending XML via HTTP POST (SOAP)
How can I post request for SOAP service in android?
Please give me some example
Thank you for sharing knowledge to me
Possible Duplicate:
Android, sending XML via HTTP POST (SOAP)
How can I post request for SOAP service in android?
Please give me some example
Thank you for sharing knowledge to me
Use the KSoap library, this is a codesnippet from my project:
SoapObject soapObject = new SoapObject(NAMESPACE_NIST_IMPORT,
METHOD_NAME_NIST_IMPORT);
ImportNistFileReq nistReq = new ImportNistFileReq(nistFile);
PropertyInfo pi = new PropertyInfo();
pi.setName("req");
pi.setValue(nistReq);
pi.setType(nistReq.getClass());
soapObject.addProperty(pi);
SoapSerializationEnvelope soapSerializationEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
new MarshalBase64().register(soapSerializationEnvelope);
soapSerializationEnvelope.setOutputSoapObject(soapObject);
soapSerializationEnvelope.addMapping(NAMESPACE_NIST_IMPORT, "ImportNistFileReq", new ImportNistFileReq().getClass());
soapSerializationEnvelope.dotNet = true;
Object objectResult = null;
try {
HttpTransportSE httpTransportSE = new HttpTransportSE(
URL_NIST_IMPORT);
httpTransportSE.debug = true;
httpTransportSE.call(SOAP_ACTION_NIST_IMPORT, soapSerializationEnvelope);
String host = httpTransportSE.getPath();
Log.i("HOST: ", host);
objectResult = (Object) soapSerializationEnvelope.getResponse();
} catch (IOException e) {
Log.e("IO: ", e.getMessage());
} catch (XmlPullParserException e) {
Log.e("XML: ", e.getMessage());
}
This piece of code sends a NIST File represented as a byte array
encoded as Byte64
to a Webservice. Request like this one should be called in a separated thread like an AsyncTask..
The constants:
Refers to the wsdl file provided by my .NET service. A great tutorial is this one. If something is unclear, just ask. Good luck.