这是我第一次使用Windows Azure。所以,如果找到,请忽略我的愚蠢错误。
我在将记录插入位于windows azure的数据库时遇到问题。这是我的java代码:
import java.net.MalformedURLException;
import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.MobileServiceTable;
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponse;
import com.microsoft.windowsazure.mobileservices.TableOperationCallback;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class HomeScreen extends Activity {
EditText et_id, et_acc_mas_id, et_amount, et_sender_id, et_borrower_id,
et_entry_date, et_cancel_flag;
Button btn_save, btn_clear;
EditText[] et;
private MobileServiceClient mClient;
private MobileServiceTable<AccountLiner> mToDoTable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_screen);
try {
mClient = new MobileServiceClient(
"https://xxxxxxxx.azure-mobile.net/",
"XXXXXXXXXXXXXXXXXXXXXXXXX", this);
mToDoTable = mClient.getTable(AccountLiner.class);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
et_id = (EditText) findViewById(R.id.editText1);
et_acc_mas_id = (EditText) findViewById(R.id.editText2);
et_amount = (EditText) findViewById(R.id.editText3);
et_sender_id = (EditText) findViewById(R.id.editText4);
et_borrower_id = (EditText) findViewById(R.id.editText5);
et_entry_date = (EditText) findViewById(R.id.editText6);
et_cancel_flag = (EditText) findViewById(R.id.editText7);
et = new EditText[] { et_id, et_acc_mas_id, et_amount,
et_sender_id, et_borrower_id, et_entry_date, et_cancel_flag };
btn_save = (Button) findViewById(R.id.button1);
btn_save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
addItem();
for (EditText e : et) {
e.setText("");
}
}
});
btn_clear = (Button) findViewById(R.id.button2);
btn_clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for (EditText e : et) {
e.setText("");
}
}
});
}
public void addItem() {
if (mClient == null) {
return;
}
Log.i("add item", "add item");
// Create a new item
// AccountLiner item = new AccountLiner(Integer.parseInt(et_id.getText()
// .toString().trim()), Integer.parseInt(et_acc_mas_id.getText()
// .toString().trim()), Float.parseFloat(et_amount.getText().toString().trim()),
// Integer.parseInt(et_sender_id.getText().toString().trim()),
// Integer.parseInt(et_borrower_id.getText().toString().trim()),
// et_entry_date.getText().toString().trim(), false);
AccountLiner item = new AccountLiner(Integer.parseInt(et_acc_mas_id.getText()
.toString().trim()), Float.parseFloat(et_amount.getText().toString().trim()),
Integer.parseInt(et_sender_id.getText().toString().trim()),
Integer.parseInt(et_borrower_id.getText().toString().trim()),
et_entry_date.getText().toString().trim(), false);
// Insert the new item
mToDoTable.insert(item, new TableOperationCallback<AccountLiner>() {
public void onCompleted(AccountLiner entity, Exception exception,
ServiceFilterResponse response) {
if (exception == null) {
Log.i("insert", "insert");
} else {
exception.printStackTrace();
}
}
});
}
}
当我检查时,我找不到任何记录,并且通过打印堆栈跟踪获得异常:
06-11 18:15:34.318: W/KeyCharacterMap(25959): No keyboard for id 0
06-11 18:15:34.318: W/KeyCharacterMap(25959): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
06-11 18:15:49.558: I/add item(25959): add item
06-11 18:15:49.798: D/dalvikvm(25959): GC_FOR_MALLOC freed 6889 objects / 339584 bytes in 68ms
06-11 18:15:51.118: W/System.err(25959): com.microsoft.windowsazure.mobileservices.MobileServiceException: Error while processing request.
06-11 18:15:51.118: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.MobileServiceConnection$1.onNext(MobileServiceConnection.java:122)
06-11 18:15:51.118: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.MobileServiceClient$7.handleRequest(MobileServiceClient.java:728)
06-11 18:15:51.118: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.MobileServiceConnection.start(MobileServiceConnection.java:93)
06-11 18:15:51.118: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.RequestAsyncTask.doInBackground(RequestAsyncTask.java:77)
06-11 18:15:51.118: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.RequestAsyncTask.doInBackground(RequestAsyncTask.java:1)
06-11 18:15:51.118: W/System.err(25959): at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-11 18:15:51.118: W/System.err(25959): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-11 18:15:51.118: W/System.err(25959): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-11 18:15:51.118: W/System.err(25959): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-11 18:15:51.118: W/System.err(25959): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-11 18:15:51.118: W/System.err(25959): at java.lang.Thread.run(Thread.java:1096)
06-11 18:15:51.118: W/System.err(25959): Caused by: javax.net.ssl.SSLException: Not trusted server certificate
06-11 18:15:51.118: W/System.err(25959): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:371)
06-11 18:15:51.118: W/System.err(25959): at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:199)
06-11 18:15:51.148: W/System.err(25959): at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:256)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:375)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-11 18:15:51.148: W/System.err(25959): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
06-11 18:15:51.148: W/System.err(25959): at android.net.http.AndroidHttpClient.execute(AndroidHttpClient.java:243)
06-11 18:15:51.148: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.ServiceFilterRequestImpl.execute(ServiceFilterRequestImpl.java:71)
06-11 18:15:51.148: W/System.err(25959): at com.microsoft.windowsazure.mobileservices.MobileServiceConnection$1.onNext(MobileServiceConnection.java:102)
06-11 18:15:51.148: W/System.err(25959): ... 10 more
06-11 18:15:51.148: W/System.err(25959): Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: TrustAnchor for CertPath not found.
06-11 18:15:51.148: W/System.err(25959): at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:168)
06-11 18:15:51.148: W/System.err(25959): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:366)
06-11 18:15:51.148: W/System.err(25959): ... 23 more
06-11 18:15:51.158: W/System.err(25959): Caused by: java.security.cert.CertPathValidatorException: TrustAnchor for CertPath not found.
06-11 18:15:51.158: W/System.err(25959): at org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi.engineValidate(PKIXCertPathValidatorSpi.java:149)
06-11 18:15:51.158: W/System.err(25959): at java.security.cert.CertPathValidator.validate(CertPathValidator.java:202)
06-11 18:15:51.158: W/System.err(25959): at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:164)
06-11 18:15:51.158: W/System.err(25959): ... 24 more
请帮我找到问题。