我想从aspx Web服务发送和接收数据,但我一直得到null响应。任何人都可以帮助我解决这个问题。谢谢!
以下是使用的代码:
private static String METHOD_NAME = "CheckVersion";
private static String NAMESPACE = "http://tempuri.org/";
private static String URL = "http://grpsvil.si2001.it/APIClient/Contents/RestPartnerTest.aspx";
private static String SOAP_ACTION = "http://tempuri.org/";
public void uploadToServer() {
Log.v("--", "fn called!");
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ApiKey",
"apikey");
request.addProperty("OperativeSystem", 0);
request.addProperty("AppVersion", 1);
request.addProperty("WebServiceVersion", 1);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapSerializationEnvelope.VER12);// or 12
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
Log.v("--", "2");
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
SoapPrimitive resultString;
try {
aht.call(SOAP_ACTION, soapEnvelope);
resultString = (SoapPrimitive) soapEnvelope.getResponse();
Log.v("--", "Responce: " + resultString);
} catch (IOException e) {
// TODO Auto-generated catch block
resultString = (SoapPrimitive) soapEnvelope.bodyIn;
Log.v("--", resultString + " 1");
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
resultString = (SoapPrimitive) soapEnvelope.bodyIn;
Log.v("--", resultString + " 2");
e.printStackTrace();
}
}