GWT JsonpRequestBuilder超时问题 [英] GWT JsonpRequestBuilder Timeout issue

查看:185
本文介绍了GWT JsonpRequestBuilder超时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从使用JsonpRequestBuilder中抽出时间。



入口点代码如下所示:

  // private static final String SERVER_URL =http:// localhost:8094 / data / view /; 
private static final String SERVER_URL =http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby =开始时间和安培;最大结果= 15&安培; singleevents =真安培;排序顺序=升序&安培; futureevents =真;
private static final String SERVER_ERROR =尝试联系服务器时出现
+错误,请检查您的网络
+连接并重试。

/ **
*这是入口点方法。
* /
public void onModuleLoad(){

JsonpRequestBuilder requestBuilder = new JsonpRequestBuilder();
// requestBuilder.setTimeout(10000);
requestBuilder.requestObject(SERVER_URL,new Jazz10RequestCallback());

}

class Jazz10RequestCallback实现了AsyncCallback< Article> {

$ b $ @覆盖
public void onFailure(可捕获的Throwable){
Window.alert(发送消息失败:+ caught.getMessage()) ;
}

@Override
public void onSuccess(Article result){
// TODO自动生成的方法存根
Window.alert(result.toString ());
}

文章类很简单:

  import com.google.gwt.core.client.JavaScriptObject; 

public class Article扩展JavaScriptObject {


保护Article(){};



然而,gwt页面始终打中onFailure()回调并显示此警报:

 发送消息失败。呼叫< url>时超时。 

无法在Eclipse插件控制台上看到任何内容。我试过这个url,它完美的工作。



希望对调试技巧或建议有所帮助

解决方案

也许你应该通过 setCallbackParam ,因为您有 callback = insertAgenda 在你的url中 - 我认为通知服务器什么应该是包装JSON的回调函数的名称。
另外,检查Firebug的控制台(或者类似的浏览器工具)是值得的 - 即使GWT没有报告任何异常,Firebug也可能会这样。

PS:使用像Firebug这样的工具来查看应用程序确实是否会收到服务器的响应(这意味着,例如,您确实需要 setCallbackParam call)或者服务器端出现了问题(无论出于何种原因)。


I am getting time out from using JsonpRequestBuilder.

The entry point code goes like this:

// private static final String SERVER_URL = "http://localhost:8094/data/view/";
private static final String SERVER_URL = "http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true";
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() {

    JsonpRequestBuilder requestBuilder = new JsonpRequestBuilder();
    // requestBuilder.setTimeout(10000);
    requestBuilder.requestObject(SERVER_URL, new Jazz10RequestCallback());

}

class Jazz10RequestCallback implements AsyncCallback<Article> {


    @Override
    public void onFailure(Throwable caught) {
        Window.alert("Failed to send the message: " + caught.getMessage());     
    }

    @Override
    public void onSuccess(Article result) {
        // TODO Auto-generated method stub
        Window.alert(result.toString());
    }

The article class is simply:

import com.google.gwt.core.client.JavaScriptObject;

public class Article extends JavaScriptObject {


    protected Article() {};


}

The gwt page, however, always hit the onFailure() callback and show this alert:

Failed to send the message. Timeout while calling <url>.

Fail to see anything on the Eclipse plugin console. I tried the url and it works perfectly.

Would appreciate any tip on debugging technique or suggestion

解决方案

Maybe you should set the callback function explicitly via setCallbackParam, since you have callback=insertAgenda in your url - I presume that informs the server what should be the name of the callback function that wraps the JSON. Also, it's worth checking Firebug's console (or a similar tool for your browser) - even if GWT doesn't report any exceptions, Firebug still might.

PS: It's useful to use a tool like Firebug to see if the application does in fact receive the response from the server (that would mean that, for example, you do need the setCallbackParam call) or maybe there's something wrong on the server side (for whatever reason).

这篇关于GWT JsonpRequestBuilder超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆