2013-04-08 62 views
-1

單擊登錄按鈕不會產生Web服務的響應,並且沒有例外或其他可見錯誤。我該如何修復我的按鈕?如何修復我的無響應按鈕及其onClick()方法?

代碼:

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

} 
+1

你在期待什麼? – 2013-04-08 06:36:48

+0

你有什麼迴應?有什麼異常? – 2013-04-08 07:57:50

+0

no ..點擊提交按鈕後,它不顯示任何異常,也沒有迴應@ChiragShah – user2256331 2013-04-08 08:20:38

回答

0

它可能會拋出異常。你有沒有在Android清單文件中授予訪問權限?

如果您給定的互聯網權限可能會引發異常可能是輸入或服務器url/login是錯誤的..等是無效的。

記錄異常。