我有这个例外。我如何使用线程概念来做到这一点?
public class WebService extends AsyncTask<String, String, String>{
private final String NAMESPACE ="http://tempuri.org/";//"http://localhost:9583/YP_Android_WebService/YP_Android_WebService.asmx";//
private final String URL ="http://10.0.2.2:1243/YP_Android_WebService/YP_Android_WebService.asmx?WSDL";
public boolean checkUser(String _EmailID, String _Password) {
boolean result = false;
final String SOAP_ACTION ="http://tempuri.org/checkUser";//"http://localhost:9583/YP_Android_WebService/YP_Android_WebService.asmx/checkUserLogin";//
final String METHOD_NAME = "checkUser";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propertyInfoEmail = new PropertyInfo();
propertyInfoEmail.setName("_EmailID");
propertyInfoEmail.setValue(_EmailID);
propertyInfoEmail.setType(String.class);
request.addProperty(propertyInfoEmail);
PropertyInfo propertyInfoPassword = new PropertyInfo();
propertyInfoPassword.setName("_Password");
propertyInfoPassword.setValue(_Password);
propertyInfoPassword.setType(String.class);
request.addProperty(propertyInfoPassword);
final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true; // put this only if the web service is .NET one
envelope.setOutputSoapObject(request);
final HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
Log.i("myApp", response.toString());
if(response.toString().equalsIgnoreCase("true")){
result = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
例外是在这一点上。
androidHttpTransport.call(SOAP_ACTION, 信封); ti 抛出 NetworkonMainThread 异常。
谁能帮助我使用线程概念来做到这一点