-1

单击登录按钮不会产生来自 Web 服务的响应,并且没有异常或其他可见错误。如何修复我的按钮?

代码:

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;
}

}
4

1 回答 1

0

它可能会抛出异常。您是否在 android 清单文件中授予了访问权限?

如果您给定的互联网权限,它可能会抛出异常,可能是输入或服务器 url/登录错误..等无效。

记录异常。

于 2013-04-08T07:26:34.067 回答