Android 如何修复无响应的按钮及其onClick()方法?
单击login按钮不会产生来自web服务的响应,并且没有异常或其他可见错误。我怎样才能修理我的按钮 代码:Android 如何修复无响应的按钮及其onClick()方法?,android,web-services,soap,login,Android,Web Services,Soap,Login,单击login按钮不会产生来自web服务的响应,并且没有异常或其他可见错误。我怎样才能修理我的按钮 代码: 公共课堂口语活动{ 字符串命名空间=”http://mlxserver/"; 字符串方法\u NAME=“loginAuthentication”; 字符串SOAP_ACTION=”http://mlxserver/MX_AgentService/loginAuthentication"; 字符串URL=”http://mlxserver//HTTKSvc/MX_AgentService.
公共课堂口语活动{
字符串命名空间=”http://mlxserver/";
字符串方法\u NAME=“loginAuthentication”;
字符串SOAP_ACTION=”http://mlxserver/MX_AgentService/loginAuthentication";
字符串URL=”http://mlxserver//HTTKSvc/MX_AgentService.svc?wsdl";
编辑文本et1、et2、et3;
按钮bt1;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_-oral);
et1=(EditText)findViewById(R.id.editText1);
et2=(EditText)findViewById(R.id.editText2);
et3=(EditText)findViewById(R.id.editText3);
bt1=(按钮)findViewById(R.id.button1);
bt1.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
SoapObject请求=新的SoapObject(名称空间、方法名称);
request.addProperty(“用户名”,et1.getText().toString());
request.addProperty(“密码”,et2.getText().toString());
request.addProperty(“PIN”,et3.getText().toString());
/*String authentication=android.util.Base64.encodeToString(“用户名:password.getBytes(),android.util.Base64.DEFAULT”);
列表标题=新建ArrayList();
添加(新的HeaderProperty(“授权”、“基本”+认证));
*/
SoapSerializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
试一试{
HttpTransportSE httpTransport=新的HttpTransportSE(URL);
调用(SOAP_操作,信封);
SoapObject结果=(SoapObject)envelope.getResponse();
如果(结果!=null)
{
setText(result.getProperty(0.toString());
setText(result.getProperty(0.toString());
setText(result.getProperty(0.toString());
Intent next=新的Intent(getApplicationContext(),Second.class);
星触觉(next);
}
其他的
{
Toast.makeText(getApplicationContext(),“输入用户名”,Toast.LENGTH_LONG.show();
Toast.makeText(getApplicationContext(),“输入密码”,Toast.LENGTH_LONG.show();
Toast.makeText(getApplicationContext(),“输入PIN”,Toast.LENGTH_LONG.show();
}
}捕获(例外e){
e、 printStackTrace();
}
}
});
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.oral,menu);
返回true;
}
}
它可能引发异常。您是否已在android清单文件中授予访问权限
如果您授予internet权限,它可能会引发异常,可能是输入错误或服务器url/登录错误。etc无效
记录异常情况。您希望看到什么?您得到什么响应?任何异常情况?否。单击提交按钮后,它不会显示任何异常情况,也不会响应@ChiragShah
public class Oral extends Activity {
String NAMESPACE = "http://mlxserver/";
String METHOD_NAME = "loginAuthentication";
String SOAP_ACTION = "http://mlxserver/MX_AgentService/loginAuthentication";
String URL = "http://mlxserver//HTTKSvc/MX_AgentService.svc?wsdl";
EditText et1,et2,et3;
Button bt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_oral);
et1 = (EditText) findViewById(R.id.editText1);
et2 = (EditText) findViewById(R.id.editText2);
et3 = (EditText) findViewById(R.id.editText3);
bt1 = (Button) findViewById(R.id.button1);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("USERNAME",et1.getText().toString());
request.addProperty("PASSWORD",et2.getText().toString());
request.addProperty("PIN",et3.getText().toString());
/* String authentication = android.util.Base64.encodeToString("username:password".getBytes(), android.util.Base64.DEFAULT);
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
headers.add(new HeaderProperty("Authorization","Basic " +authentication));
*/
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try {
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
if(result != null)
{
et1.setText(result.getProperty(0).toString());
et2.setText(result.getProperty(0).toString());
et3.setText(result.getProperty(0).toString());
Intent next = new Intent (getApplicationContext(),Second.class);
startActivity(next);
}
else
{
Toast.makeText(getApplicationContext(), "Enter USERNAME",Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Enter PASSWORD",Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Enter PIN",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.oral, menu);
return true;
}
}