我正在使用 GCM 生成注册 ID,它正在生成很好的价值。但我的问题是我使用soap 将数据发送到asp.net 服务器。它在数据库中存储空值。
我已经尝试了很多,但不知道是什么问题。我还通过给出 regID 的固定值进行了检查,并在那时存储了数据。
我的代码如下:请给我解决方案。
private class TheTask extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... params) {
GCMRegistrar.checkDevice(getApplicationContext());
GCMRegistrar.checkManifest(getApplicationContext());
String regId = GCMRegistrar
.getRegistrationId(getApplicationContext());
if (regId.equals("")) {
flag = 1;
GCMRegistrar.register(getApplicationContext(), "1507652xxxxx");
} else {
Log.v("Registration", "Already registered, regId: " + regId);
}
if (flag == 1) {
regId = GCMRegistrar.getRegistrationId(getApplicationContext());
request = new SoapObject(NAMESPACE, METHOD_NAME);
regisid = new PropertyInfo();
regisid.setName("RegId");
regisid.setValue(regId);
regisid.setType(String.class);
request.addProperty(regisid);
SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envp.dotNet = true;
envp.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envp);
SoapPrimitive response = (SoapPrimitive) envp.getResponse();
Response = response.toString();
} catch (Exception e) {
e.printStackTrace();
}
}
return Response;
}
@Override
protected void onPostExecute(String result) {
}
}