0

私は Eclipse を使用して Android クライアントを構築し、GAE と GWT を使用して開発した restlet サービスを再利用しています。

私のサービスはで実行されています

    http://127.0.0.1:8888/abc/audits  

この URL に直接アクセスし、GWT クライアントを使用してこれをテストできます。どちらも機能します。

ただし、次のコードは通信エラーを返します。

    private AuditsResource resource;
    private Audits audits;

    ClientResource cr = new ClientResource("http://127.0.0.1:8888/abc/audits");
    resource = cr.wrap(AuditsResource.class);
    try {
    // Get the remote contact
     audits = resource.retrieve();
    // The task is over, let the parent conclude.
    handler.sendEmptyMessage(0);
    } catch (Exception e) {
        Message msg = Message.obtain(handler, 2);
        Bundle data = new Bundle();
        data.putString("msg", "Cannot get the contact due to: "
            + e.getMessage());
        msg.setData(data);
        handler.sendMessage(msg);
    }

次にどこを見たらいいのかわからない。AuditsResource のサーバー実装を計測しましたが、(Android アプリケーションによって) 触れられることはありません。

AuditsResource クラスにはメソッドが 1 つあります。

    @Get
    public Audits retrieve();
4

2 に答える 2

0

localhost の代わりに 10.0.2.2 を使用して、Android/Restlet 経由で Android からローカルの Google App Engine に接続できます。

于 2012-05-21T04:06:15.490 に答える
0

問題は、Andriod Emulator が 127.0.0.1 または 10.0.2.2 のいずれにも接続できないことです。解決策は、PC の IP アドレスを使用することです。

于 2012-05-17T12:11:24.503 に答える