这里是我的肥皂段,
//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;
}
虽然我调试的代码,我有一个错误的问题标题中提到。该错误被认为是在
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
线..
我想我不能从web服务的响应。我如何解决它?
Webservice返回xml.InnerText。它是String类型的。
请回答我。