我是新來的機器人請幫助我。
這是代碼,我已經嘗試了:如何通過在android中調用wcf web服務來驗證用戶名和密碼? &如何傳遞用戶名和密碼以及請求?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
btnLogin=(Button)findViewById(R.id.btnLogin);
btnCancel=(Button)findViewById(R.id.btnCancel);
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
username=(EditText)findViewById(R.id.et_un);
password=(EditText)findViewById(R.id.et_pwd);
SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);>
如何通過請求參數?
PropertyInfo p1=new PropertyInfo()
p1.setName("username");
p1.setValue("nitinr");
request.addProperty(p1);
PropertyInfo p2=new PropertyInfo();
p2.setName("password");
p2.setValue("123");
request.addProperty(p2);
如何爲此編碼? 我不知道如何解析響應的輸出? ,並指導將會有什麼迴應?
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
//invkoe web service and get result
try {
httpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
tv.setText(response.toString());
} catch (Exception exception) {
tv.setText(exception.toString());
}
if(username.equals("nitinr")){
if(password.equals("123")){
onClick(v);
} else{
lblResult.findViewById(R.id.tv_link);
}
}else{
btnLogin.findViewById(R.id.tv_valid)
}
}
});
}
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(getBaseContext(),Welcome.class);
startActivity(i);
}
}
嗨,我得到錯誤像'03 -08 02:35:50.046:E/AndroidRuntime(779):\t在android.os.StrictMode $ AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099) – user1256259 2012-03-08 09:50:08