I have a gwt-application and want to connect to it's xmlrpc backend via a standalone xmlrpc-client (written e.g. with Apaches' xmlrpc-library).
Assume the project creates a servlet called TestServlet
connected to the URL /test/test
providing a Method public int add(int a, int b)
.
Calling the deployed servlet (running in a jetty on port 8080) with the code shown below, I get this error message in jettys' log:
javax.servlet.ServletException: Content-Type was 'text/xml'. Expected 'text/x-gwt-rpc'.
Is there any easy way to connect such a standalone xmlrpc-client with the gwt-enhanced xmlrpc-server? I read about xmlrpc-gwt - but I want to keept the gwt dependencies for that standalone client minimal.
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://127.0.0.1:8080/test/test"));
config.setConnectionTimeout(60 * 1000);
config.setReplyTimeout(60 * 1000);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[] {new Integer(2), new Integer(3)});
Integer result = (Integer) client.execute("TestServlet.add", params);
System.out.println(result);
GWT's RPC protocol is not related to XML/RPC . It's loosely based on JSON but it is not considered public, so you should not rely on its current form for interoperability.