As some of you may know I posted a very popular blog post about a year ago about how to get Phonegap and GWT RPC working together.
A few weeks ago John Gentillin brought the issue up again on the mgwt user group.
He rightly suggested that this could be fixed by just changing the client and without touching the server at all. So today I decided to revisit the issue and see if I can find a nice way to handle it on the client.
To fix this you need some basic knowledge of how GWT RPC works on the client.
The compiler generates some classes around the RPC interface which do the actual communication.
We need to do two things:
- set the url for the entry point
- set the url for the gwt module base
Both parameters are passed with our request and help the server code find the serialization policy. With gwt-phonegap 1.7 I decided to introcude a utility method that handles all those things directly on the client. You just pass in your service, your module url (where you GWT app is deployed) and the relative path to your service.
The code would look like this:
GreetingServiceAsync service = GWT.create(GreetingService.class); PhonegapUtil.prepareService(service, "http://www.yourserver.com/", "greet");
If you want to see how this is implemented take a look here: PhonegapUtilImplDevice.java
There is also an article on RequestFactory & Phonegap.
This comment has been removed by the author.
ReplyDeleteHi daniel
ReplyDeletei try to use ur solution, but i have some problems on the rpc server part.
Type '*.ClientContext' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.
Am i missing something ? My bean has empty constructor, serial ID and implements Serializable.
Hi Yohan,
ReplyDeletelets put discussions on the mgwt user group: https://groups.google.com/group/mgwt (since we can discuss there in any length). Would you be so kind to repost there?
Hi Daniel,
ReplyDeleteI use your solution and i have a statusexception 0
This comment has been removed by the author.
ReplyDeleteI am also getting statusexception 0 when I am trying on local server http://127.0.0.1:8888. After the RPC call in the onFailure I am displaying exception message and cause. It is showing exception message as 0 and exception cause as null. Daniel can you please help. Wilkin Dessin, were you able to fix your issue?
ReplyDeleteYou will get StatusCodeException 0 when you are accessing your app's *.html file directly from the filesystem (not from the server; for example through URL file:///C:/AppFolder/war/index.html).
ReplyDeleteCheck bugs in your browser's dev console. If you have:
"Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match."
or
"XMLHttpRequest cannot load http://127.0.0.1:8888/appname/serviceName. Origin file:// is not allowed by Access-Control-Allow-Origin."
disable browser's web security (only for testing period!) -> run Chrome with flag "--disable-web-security" (first make sure that you don't have any running instances of Chrome). Chrome will display yellow bar saying that it's not safe now.
It is only a problem with Same Origin Policy (SOP) on desktop browser. WebView in PhoneGap allows this kind of request.
If you're still getting StatusCodeException 0, check if your services have proper entry points set (ServiceDefTarget.setServiceEntryPoint()).
I'm using m-gwt without gwt-phonegap, so I'm not using PhonegapUtil.prepareService(), but in the gwt-phonegap source code I can see that the implementation for the browser (PhonegapUtilImplBrowser.java) has empty prepareService() method (contrary to PhonegapUtilImplDevice.java). So the entry point will be wrong for the browser. Set it via ServiceDefTarget.setServiceEntryPoint().
And on the server side in RemoteServiceServlet override doGetSerializationPolicy() and set there proper moduleBaseURL.
All the construction of an electric utility check out have become the possibility as a result of any miniaturization about electronic elements and also opening from compact electrical power replica omega. Wristwatches together attemptedto are the initial to market. All the observe revealed the pioneer an individual throughout cutting edge design and style. But it surely has been in haste to advertise caused by doubts from wrist watches publishing one particular well before individuals. Consequently, it was eventually overwhelmed by using great satisfaction matters before it starts, which unfortunately affected it has the reputation. The source is when using the electric lenses which inturn quickly wore apart together with were being complicated vehicle repairs. Any sit back and watch got a number of global factors which made them all appealing to potential fans and patrons. When they are powered because of a tuning shell, many people hummed in lieu of ticked and even were the very first to obtain travelling across no time arms. Wrist watches types revealed the particular exceptionally exclusive together with strange tuning derive tool inside of http://www.attrinity.com. Nevertheless as expected, having the capability to lay claim to get the most legitimate watch for sale, had been an immense selling benefit on their behalf. By means of 1970 on the other hand, any publishing is about the walls to your running watches. Typically the devices made aim to hang on about the tad for a longer time while using advancement belonging to the unit which inturn joined together tuning hand systems along with quartz restrain replica watches uk. These types of developments impacted precisely how quartz pieces developed and also the advancement about accuracy technology. The pioneer sit back and watch was very pricey, being on the same as the see during the time, not to mention just were not in particular efficient having lots of requiring you to get were recalled. However quartz genie appeared to be straight from the flask, in addition to there was virtually no returning to college. Now, nearly all different watches can be quartz and are generally the most cost-effective in addition to genuine different watches on the market.
ReplyDeleteGet top flexispy reviews from advanced users who really know how to use this software properly.
ReplyDeleteIf you have kids, spyware for Snapchat is a necessary thing for you! You can check the list of the best Snapchat spy apps.
ReplyDeleteIt was a very different blog than the usual ones I visit. Thanks for sharing. big thumbs up for making such wonderful blog page The best tips for choosing a lawyer who specializes in car accidents
ReplyDelete.
hire a hacker to hack cell phone
ReplyDeletecheaters spy app free
Hack Wizards
WhatsApp Hack
This comment has been removed by the author.
ReplyDeleteMany difficulties arise for those who travel internationally. The need for cost-effective connection solutions is a persistent issue for them. However, problems with making long-distance calls from abroad are now moot because of the widespread availability of International IoT SIM card.
ReplyDelete