调用JsonpRequestBuilder.requestObject()时超时异常

时间:2012-08-27 19:13:25

标签: json gwt

我在调用JsonpRequestBuilder请求时遇到超时异常。

我也提到question,但我每次都会收到超时异常。

我的入门点类是

package com.dips.restcalls.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.jsonp.client.JsonpRequestBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class RequestClass implements EntryPoint {


        @Override
        public void onModuleLoad() {
                // TODO Auto-generated method stub
            private static final String JSON_URL = "http://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key=XXXXXXXXXXX";

            JsonpRequestBuilder builder = new JsonpRequestBuilder();
            builder.setTimeout(1000);
            builder.setCallbackParam("jsonCallback");
            builder.requestObject(JSON_URL, new AsyncCallback<T>() {
                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub
                    System.out.println("Fails...."+ caught);
                }

                @Override
                public void onSuccess(T result) {
                    // TODO Auto-generated method stub
                    System.out.println("Sucess...");
                }
            });

        }

    }

您可以从Here

获取flickr json网址

我的JavaScriptObject类是

package com.dips.restcalls.client;

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

public class T extends JavaScriptObject {

    public T() {
        // TODO Auto-generated constructor stub
    }
}

在Firebug中我得到了json响应但是,在控制台中我每次都会收到Timeout Exception。 求你帮帮我。

0 个答案:

没有答案