Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call RESTFUL services from GWT?

Tags:

I'm using GWT as web development framework. I need to access some REST services from my GWT client code. Also I need to parse JSON (or maybe XML) which is response format of these services. Which is the best way for this problem?

Thanks in advance.

like image 241
ovunccetin Avatar asked Oct 27 '10 07:10

ovunccetin


People also ask

How do I call a RESTful API?

Step #1 – Enter the URL of the API in the textbox of the tool. Step #2 – Select the HTTP method used for this API (GET, POST, PATCH, etc). Step #3 – Enter any headers if they are required in the Headers textbox. Step #4 – Pass the request body of the API in a key-value pair.

Can we call REST API from Java?

You can definitely interact with RESTful web services by using URLConnection or HTTPClient to code HTTP requests. However, it's generally more desirable to use a library or framework which provides a simpler and more semantic API specifically designed for this purpose.

What is RestyGWT?

RestyGWT is a GWT generator for REST services and JSON encoded data transfer objects.


1 Answers

You can call REST services using the standard GWT RequestBuilder (or JsonpRequestBuilder if you need to call services on another domain).

With the JSON response string, you can call JSONParser.parseStrict(jsonString) to get a JSONValue, which can be a JSONObject, JSONArray, etc. This is all available in this package.

like image 118
Jason Hall Avatar answered Nov 16 '22 23:11

Jason Hall