How to make REST calls from Google Web Toolkit? - gwt

I have my restful CXF service producing JSON with default JSON provider. I want to know if we can use GWT to build client which will user the restful service. Will it work ? If not, what would be a simple work around for this type ?
Thank you.
regards

It will work. See this. Here's a quote:
GWT does not limit you to this one RPC mechanism or server side development environment. You are free to integrate with other RPC mechanisms, such as JSON using the GWT supplied RequestBuilder class, JSNI methods or a third party library.

Related

Can dart script call GWT's RemoteServiceServlet

I have a Dart project want to reuse the existing GWT service (RemoteServiceServlet), any way can do this?
There is no special support for GWT-RPC included in Dart and there seem to be no 3rd-Party apps available that provide this functionality.
This question is similar (but not Dart)
GWT Data Serialization
If you're feeling ambitious, you can write a Dart client that understand the GWT-RPC wire-protocol and use that to communicate. This is likely to be a great deal of work however.
I had a similar situation where I needed to access GWT-RPC Services from a non-GWT client (it was JavaScript, not Dart, but the same concept applies). Instead of accessing the GWT-RPC service directly, I ended up using jsonrpc4j to setup a JSON-RPC service alongside GWT-RPC. I was able to point jsonrpc4j at the GWT services to use, so there was no code duplication, just the extra code needed to wire up the JSON-RPC.
Then you will need a Dart JSON-RPC client, of which there are a few available: jsonrpc, jsonrpc2.
This all assumes that you have access to the GWT server and can setup the JSON-RPC service.

Implement a multithreat in gwt with http request

I need implement a system with multithreat in GWT.
What is the best way to do this???
I am using http request, json
and web service building in php
Thanks
GWT code is translated to JavaScript which is not multithreaded (or at least, not in a way accessible to the user).
There are ways to program around tasks and callbacks in GWT. Take a look at the Scheduler class.

Implement REST service in gwt

I want to implement REST service in gwt .But I don't know how to go about it. I read some documents where they have implemented it using RestyGwt and jercy. But I have one app which is deployed on tomcat. Then situation is that my client side app is calling the methods on the application present on tomcat.
I have to implement it using REST so that my client side call will first go to Proxy service on client then it make REST call to the application on tomcat and fetch result and return. How can I do this in gwt. ?
As mentioned, you can only communicate with REST service.
Anyway, maybe take a look on dispatch concept in GWTPlatform and their way of implementing it. (https://github.com/ArcBees/GWTP/wiki/Rest-Dispatch).
Idea is easy, you have an action on client side which is registered to deal with rest url. You can define action interface with some additional annotations to tell what is excepected to be send and received. They are using piriti library for json serialization.
It is up to you if you need only client side implementation or you would like to use server side service creation too.
You can NOT implement a REST service in gwt, since gwt is thought as a client-side solution.
What the GWT kit provides for server side are a few utilities to facilitate the comunication between client-side and server-side when both are written in java (RPC, RF).
So you can consume a REST service from gwt (RequestBuilder, gwtquery-ajax, etc), but if you want to provide REST services you need a 3party solution for your server side like Jersey, CXF, etc.
There are, though, 3party solutions which provides the server side and client simultaneously like restygwt, errai-jax, etc.
If you are looking for a simple and reliable solution to query rest services from the client, in this question you have a client implementation done with gwtquery (ajax, databinding, promises)

The server side of GWT application

Is it possible to write a server side of GWT application in other languages then Java if yes how to use GWT-RPC mechanism, an sample code please
Thanks
Please read the GWT documentation Communication with the Server:
If you can run Java on the backend and are creating an interface for your application's server-side business logic, GWT RPC is probably your best choice. [...]
If your application talks to a server that cannot host Java servlets, or one that already uses another data format like JSON or XML, you can make HTTP requests to retrieve the data.
You can write your server in any language you choose, GWT is just JavaScript to be run in your users' browsers.
If you decide to go that route, you should look into using RequestFactory to communicate with your server instead of GWT-RPC, which is Java-specific. RequestFactory uses standard JSON, which any language can read/write.
Dont waist your time with GWT-RPC. It's bad. Use RequestFactory. I am surprised people are promoting GWT-RPC. It's a broken toy.

Access web service from GWT

Is there any way how I can access a web service from GWT using its WSDL? Previously I was trying to use the generated classes from ws-import.... but then someone pointed out to me that GWT cannot handle all Java, just a subset of it, hence it won't understand the ws-import classes.
Thanks and regards,
Krt_Malta
GWT can access web services using a RequestBuilder, which makes HTTP calls to a service and then gets access to its response.
Since your web service is using SOAP, the response you get in your RequestBuilder's callback will be XML. Parse that XML to find the information you're interested in, and you're good to go.
In our project we were using Axis Client to make SOAP Web Service Call(WSDL Driven). We had use the inbuild plug tool provided by the WTP/ AXIS Webservice in Spring Source Tool to create the client using provided WSDL. We had use the same client code to incorporate with GWT and everything works fine.