この「構成」でGWTを試しています:
1)json出力を生成するサーバーバックエンドをPythonで作成しました(localhot:8094で実行)
2) RequestBuilder を使用して GET を Python サーバーに設定する非常に単純な GWT アプリを作成しました (GWT Eclipse プラグインの開発モードでは、http://127.0.0.1:8888/test.htmlからアクセスできます) 。
コードは単純です
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Test implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_URL = "http://localhost:8094";
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network "
+ "connection and try again.";
/**
* This is the entry point method.
*/
public void onModuleLoad() {
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, SERVER_URL);
try {
requestBuilder.sendRequest(null, new Jazz10RequestCallback());
} catch (RequestException e) {
Window.alert("Failed to send the message: "
+ e.getMessage());
}
}
class Jazz10RequestCallback implements RequestCallback{
public void onError(Request request, Throwable exception) {
// never reach here
Window.alert("Failed to send the message: "
+ exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
// render output
Window.alert(response.getText());
}
}
}
ただし、アラートは常に onResponseReceived から発生し、何も表示されません (空の文字列だと思います)。
Python サーバーに問題なくアクセスでき、ブラウザ経由で json をダウンロードできます。しかし、GWT からサーバーにヒットするリクエストが表示されません。
「inherits name='com.google.gwt.http.HTTP」が gwt.xml ファイルにあることを確認しました
質問は次のとおりです。
1) ここでも同じサイト ポリシー制限が適用されますか? 私は例外(したがって失敗メッセージ)を期待していましたが、それは起こりませんでした
2) 本当に同じサイト ポリシーの問題である場合、Python バックエンドから GWT スクリプトを展開する最も簡単な方法は何ですか? Eclipse gwt プラグインは、war サブディレクトリにアーティファクトを生成します。これらのファイルを Python バックエンドの静的ディレクトリにコピーするだけで十分ですか?