我成功地在网络上部署了我的网络服务。我可以从我的应用程序中的 android 2.3 调用它。但它无法从我在 android 4.0 上运行的应用程序调用 web 服务,它给出了 null 错误。我使用最小 SDK 到 API 10
我调用网络服务的代码如下
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("number", username.getText().toString());
request.addProperty("password", password.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
Toast.makeText(getBaseContext(), "Wait while connecting server",Toast.LENGTH_LONG).show();
HttpTransportSE androidHttpTransport = new HttpTransportSE(
URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
txt.setText("upto result");
if (result != null) {
String h = String.valueOf(result.getProperty(0));
txt.setText(h);
if (h.equalsIgnoreCase("true")) {
Intent myIntent = new Intent(getBaseContext(),
ContactList.class);
myIntent.putExtra("mobileNumber", username
.getText().toString());
startActivity(myIntent);
} else {
Toast.makeText(getBaseContext(), "Not register or invalid password",Toast.LENGTH_LONG).show();
txt.setText("Invalid Credential");
}
} else {
txt.setText("Error while connecting server");
}
} catch (Exception e) {
e.printStackTrace();
txt.setText("Check internet connection" + e.getMessage());
}
我的代码有什么错误。
提前致谢