The Problem
Due to several problems encountered with GSON (GWT JSON-RPC), I'd like to switch to Resty-GWT. The following example showcases my old setup, then below is my attempt at transferring.
The Data
This is the JSON data sent from the proxy I have setup:
{"id": 1, "result": ["Planets", "Stars"], "error": null}
ControlService.java - How I Make the Call (with GSON)
The class that makes the asynchronous call:
import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.RemoteJsonService;
import com.google.gwtjsonrpc.common.RpcImpl;
@RpcImpl(version=RpcImpl.Version.V2_0,transport=RpcImpl.Transport.HTTP_POST)
public interface ControlService extends RemoteJsonService
{
public void connectedNames( String [] Names, AsyncCallback<String[]> callback ); //FirstExample
}
createPanel.java
This is the class that actually calls and receives the data:
import com.google.gwtjsonrpc.common.AsyncCallback;
public class createPanel implements ChangeHandler{
public mainPanel(){
//Some code setting up the panels
service_ = GWT.create(ControlService.class);
((ServiceDefTarget) service_).setServiceEntryPoint("http://localhost:3900/services/ControlProxy.py"); //Directs GWT to the proxy
service_.connectedNames( new String[0], new AsyncCallback<String[]>() {
public void onSuccess( String[] result)
{
//I now play with the data
}
public void onFailure(Throwable why)
{
myList_.addItem( "Server error!" );
}
});
}
}
So How Do I Do This With RestyGWT?
My attempt:
testService.java
import javax.ws.rs.Path;
import org.fusesource.restygwt.client.MethodCallback;
import org.fusesource.restygwt.client.RestService;
@Path("http://localhost:3900/services/ControlProxy.py")
@POST
public interface testService extends RestService {
public void connectedNames( String [] Names, MethodCallback<String[]> callback );
}
testCreatePanel.java
public class createPanel implements ChangeHandler{
public mainPanel(){
//Some code setting up the panels
service_ = GWT.create(testService.class);
testService.connectedNames(cbcNames, callback);//how to extract data from this
}