java - 使用soap webservice在android中的活动之间传递数据
问题描述
您好,我是使用 android 和 soap 进行应用程序开发的新手。我的问题是我想检索登录用户的会话 ID 并在另一个活动中使用它。它是在身份验证期间由 Web 服务在表中提供的响应。我发现创建一个常量类作为解决方案,但我不知道如何去做。有人可以帮忙吗?这是身份验证的代码。
class AsyncCallWS extends AsyncTask<String, Void, String> {
private ProgressDialog Dialog = new ProgressDialog(LoginActivity.this);
@Override
protected String doInBackground(String... url) {
loginAction();
return null;
}
@Override
protected void onPreExecute() {
Dialog.setMessage("chargement...");
Dialog.show();
}
@Override
protected void onPostExecute(String result) {
Dialog.dismiss();
}
private void loginAction() {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
login = loginEdit.getText().toString();
password = passwordText.getText().toString();
//Pass value for userName variable of the web service
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("login");//Define the variable name in the web service method
unameProp.setValue(login);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable
//Pass value for Password variable of the web service
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(password);
passwordProp.setType(String.class);
request.addProperty(passwordProp);
//Pass value for Password variable of the web service
String mod = "APP";
PropertyInfo mode =new PropertyInfo();
mode.setName("mode");
mode.setValue(mod);
mode.setType(String.class);
request.addProperty(mode);
try {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
System.out.println("call Donnnnnnnnnnnnnnnnnnnnnnnnnnne");
String message0 = result.getProperty(0).toString();
String message1 = result.getProperty(1).toString();
// String message2 = result.getProperty(2).toString();
Log.e("result", "responceEEEEEEEEEEEEEEEEEEEEEEEE" + result);
Log.e("result", "Message1 " + message1);
Log.d("LOG_TAG", envelope.bodyIn.toString());
switch (message0) {
case "0":
runOnUiThread(new Runnable() {
public void run() {
Intent i = new Intent(getApplicationContext(), NFCTagActivity.class);
startActivity(i);
}
});
break;
default:
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(LoginActivity.this, "identifiants incorrects ou Le user à deja une session en cours", Toast.LENGTH_LONG).show();
}
});
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
解决方案
推荐阅读
- vba - 通过遍历用户表单从模块设置用户表单宽度
- swift - 使用 SwiftUI 或 UIKit 定位视图元素?
- javascript - 如何将变量从 ts fie 转移到另一个 angular
- python - 在 Django 中使用 Celery Task 创建对象(在 ViewSet 类中)
- typescript - 通过打字稿中的动态键字符串访问反应原生样式表成员
- c - CS50 Speller.c 问题
- kubernetes - kubectl apply 与 kubernetes 部署 - Terraform
- ubuntu - 是否有一个快速脚本可以将文件夹中的 JPG 重命名为其 HSL 值
- amazon-web-services - 视频点播的 Cloudfront 存储桶策略
- angular - “DialogRef”类型上不存在属性“then”
'.ts(2339)