I have a webservice programmed in asp.net . I want to reach webservice from android application using SOAP(ksoap2) .
Here is my soap segment,
//Namespace of the Webservice - can be found in WSDL
private static String NAMESPACE = "http://tempuri.org/";
//Webservice URL - WSDL File location
private static String URL = "http://locationbasedapp.net/Service1.asmx";//Make sure you changed IP address
//SOAP Action URI again Namespace + Web method name
private static String SOAP_ACTION = "http://tempuri.org/";
public static String invokeListLocationsWS(String datetext, String webMethName) {
String xmlDataSet = "";
// Create request
SoapObject request = new SoapObject(NAMESPACE, webMethName);
// Property which holds input parameters
PropertyInfo datetextPI = new PropertyInfo();
PropertyInfo passPI = new PropertyInfo();
// Set Username
datetextPI.setName("datetext");
// Set Value
datetextPI.setValue(datetext);
// Set dataType
datetextPI.setType(String.class);
// Add the property to request object
request.addProperty(datetextPI);
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
// Set output SOAP object
envelope.setOutputSoapObject(request);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
// Invoke web service
androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
// Get the response
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
// Assign it to boolean variable variable
xmlDataSet =response.toString();
} catch (Exception e) {
//Assign Error Status true in static variable 'errored'
MapActivity.errored = true;
e.printStackTrace();
}
//Return booleam to calling object
return xmlDataSet;
}
While I am debugging the code , I have an error as mentioned on the question title. The error is seen on the
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
line..
I think I can't get response from webservice. How Can I fix it ?
Webservice returns xml.InnerText. It's type String.
Please answer me.
While I'm not an .NET developer I've seen similar error codes before using Java
and it always boils down to the XML
being returned by the calling web service
being invalid.
In my case what I tried was capturing the raw XML
response and then attempting to parse it using a XML
parsing library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.