我使用SOAP(ksoap2)lib从webservice同步数据。早在我的应用程序就好了。今天,当我今天运行我的程序时,我在此行收到以下错误 SoapPrimitive response =(SoapPrimitive)envelope.getResponse();
private final static String NAMESPACE = "http://tempuri.org/";
private static String URL = "http://172.230.0.30/pos_cashsale/Service1.asmx";
private final static String SOAP_ACTION = "http://tempuri.org/";
public static String invokeJSONWS(String Name1, String Value1,
String Name2, String Value2, String methName) {
String responseJSON = "";
// Create request
try {
SoapObject request = new SoapObject(NAMESPACE, methName);
if (!Value1.equals("")) {
// Property which holds input parameters
PropertyInfo paramPI = new PropertyInfo();
// Set Name
paramPI.setName(Name1);
// Set Value
paramPI.setValue(Value1);
// Set dataType
paramPI.setType(String.class);
// Add the property to request object
request.addProperty(paramPI);
}
if (!Value2.equals("")) {
// Property which holds input parameters
PropertyInfo paramPI2 = new PropertyInfo();
// Set Name
paramPI2.setName(Name2);
// Set Value
paramPI2.setValue(Value2);
// Set dataType
paramPI2.setType(String.class);
// Add the property to request object
request.addProperty(paramPI2);
}
// Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
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 + methName, envelope);
// Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
// Assign it to static variable
responseJSON = response.toString();
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return responseJSON;
}