Reputation: 16364
I need to access a .NET webservice in my android application. I did it using the ksoap2 library. I set up the connection and everything but I am not able to get the data back from the service. The service is supposed to send back a set of values. How do I catch those values ?
This is my java code to access the web-service.
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
//code to get back the values here. This is my doubt.
//What code do I write here to get the values from the service ?
} catch (Exception e) {
e.printStackTrace();
}
And this is the format of the response from the service.
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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:Body>
<GetControlResponse xmlns="http://tempuri.org/">
<GetControlResult>
<Id>int</Id>
<Belt>boolean</Belt>
<Lighting>boolean</Lighting>
<AutoSpeed>boolean</AutoSpeed>
<ManualSpeed>short</ManualSpeed>
<Projector>boolean</Projector>
<ProjecterPattern>short</ProjecterPattern>
</GetControlResult>
</GetControlResponse>
</soap:Body>
</soap:Envelope>
Upvotes: 0
Views: 2311
Reputation: 1
You can done this work by using this code:
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
System.out.println(request);
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
HttpTransportSE httpTransportSE = new HttpTransportSE(URL);
httpTransportSE.debug = true;
try {
httpTransportSE.call(SOAP_ACTION, envelope);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String ss = httpTransportSE.requestDump;
Log.d("Result", ss);
System.out.println(ss);
Upvotes: 0