I am wondering what the pros and cons using RPC vs HTTP (doGet(),
doPost()) requests?
Most of the GWT samples are based on RPC. Is RPC technique a better/
recommended way?
Thanks in advance for your help.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Based on the statement above, my understanding is that the http
request is also an async.
On Jan 2, 5:46 pm, Lucas Vargas Freitas Ventura
<lucasvfvent...@gmail.com> wrote:
> HTTP requests are synchronized methods, and RPC are a asynchronized method.
>
> I think that RPC is the google's implementation of HttpXmlRequest.
>
> For Rich Internet Application you will use a lot of ajax, so you will use
> all most of time RPC.
>
> (Sorry, my english isn't good).
>
>
>
> On Sat, Jan 2, 2010 at 8:46 PM, Pion <onlee2...@gmail.com> wrote:
> > "Communicate with a Server" -
>
> >http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunicat...
> > - article mentions about RPC and HTTP techniques.
>
> > I am wondering what the pros and cons using RPC vs HTTP (doGet(),
> > doPost()) requests?
>
> > Most of the GWT samples are based on RPC. Is RPC technique a better/
> > recommended way?
>
> > Thanks in advance for your help.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
RPC serializes basic java objects and your javabeans based on them, giving you a nice model for programming since in GWT it's all Java when programming. If you use HTTP, you can post name-value string pairs, and then you'll have to process the response string. It's just much less powerful, but may work fine for you. I mean, the traditional web browser uses this technique, but it does mean handling errors and URL encoding your data to send and parsing the response.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
One of the things I like the most about the HTTP way is that, after
having spent some time to write and test my engine on the client, I
can reuse my engine to communicate with any server.
But since it was a my first app with gwt, it was not really an nice
start...
On Jan 3, 1:46 am, Pion <onlee2...@gmail.com> wrote:
> "Communicate with a Server" -http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunicat...
I am with you on the separation of concern between GWT client and server
using JSONP. Have you look at http://google-web-
toolkit.googlecode.com/svn/javadoc/2.0/index.html in GWT trunk and work
out a solution with a REST framework such as Restlet. Please share your
experience.
Duong BaTien
DBGROUPS and BudhNet
> To post to this group, send email to google-web-
> too...@googlegroups.com.
> To unsubscribe from this group, send email to google-
> web-toolkit...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?
> hl=en.
>
>
>
>
>
> --
> Lucas V. F. Ventura
> Ciência da Computação - UFRJ
>
>
> --
>
> You received this message because you are subscribed to the
> Google Groups "Google Web Toolkit" group.
>
> To post to this group, send email to google-web-
> too...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-
> toolkit+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Google Web Toolkit" group.
> To post to this group, send email to google-web-
> too...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-toolkit
> +unsub...@googlegroups.com.
As far as the RPC vs RESTful debate, I think most everyone would agree
that REST is better from an abstract interface perspective. However,
in many cases RPC is faster to develop in, GWT RPC is a faster
transport, and makes life easier than json and overlay types. This is,
of course, IMHO.
Not that I'm saying GWT-RPC is a silver bullet. I'm just saying if the
following are true for you, then GWT-RPC may be good for you:
(1) My GWT-based webapp is (and will always be) the only consumer of
my server resources (i.e. servlets)
(2) A Java server will always be used
(3) In a tradeoff between perfect design and perfect performance, I
tend towards performance.
On Jan 3, 9:21 am, Duong BaTien <duong.bat...@gmail.com> wrote:
> Hi Jan:
>
> I am with you on the separation of concern between GWT client and server
> using JSONP. Have you look athttp://google-web-
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
Performance
- Client Side - REST with JSON wins over RPC. Browsers are exceptionally good at json parsing. It is going to be much faster than GWTs serialization/deserialization mechanism. This is applicable only if you use javascript overlays. JSONArray/JSONObject/JSONValue classes don't give you this performance benefit.
Use JsonUtils.unsafeEval() to avoid the unused JSONObject created by
JSONParser.parse(), and then just use .cast() to turn the JSO into a
Report (unless of course you want a singleton in the $wnd.Report
global JS variable):
Report myReport = JsonUtils.unsafeEval(response.getText()).cast();
Hi Thomas:
Isn't an aspect of unsafeEval() that it's unsafe? Is JSONParser() also
unsafe? Or do I always want to add comments to the cargo at the
generator, strip such comments at the receiver and call unsafeEval() (&
its equivalent on the server)
From the JSONParser() code, I get the impression that it tries to
differentiate among arrays, strings, &c. I thought that such behavior
was A Good Thing.
Yes, both use a plain JS eval() to "parse" the JSON string. JSONParser
has room for enhancement in using native JSON parsing in browsers that
support it (IE8, FF3, Safari 4 and Chrome), whereas unsafeEval is
likely to always use eval().
I built my own JSON module that uses JSON.parse() when available
(using deferred binding to never try it in IE6/7, old-mozilla and
Opera, and always use it in IE8) and fallback to JsonUtils.unsafeEval
() otherwise.
> Or do I always want to add comments to the cargo at the
> generator, strip such comments at the receiver and call unsafeEval() (&
> its equivalent on the server)
I don't understand the "comments" thing (I think I understand the
"how", but I clearly don't get the "why")
> From the JSONParser() code, I get the impression that it tries to
> differentiate among arrays, strings, &c. I thought that such behavior
> was A Good Thing.
JSONParser only tries to provide "strong typing" by some kind of
"introspection/reflection", that you obviously don't have with JSOs,
but is it really needed?
Even with JSONParser, you'll generally don't handle the "error path"
and live with potential NPEs (in your snippet, what if the eval'd text
isn't an object but an array?), which finally leads to doing
computations about the data type that you don't really care in the
end.
It's generally not worth paying the JSONValue "tax" of data type
"discovery". The only thing that's missing with JSOs is an easy way of
doing data type discovery in case the JSON format allows for different
types of data (e.g. in an object, the value of key "foo" can be a
string or an array of strings; an array of numbers or strings; etc.)
Although I'm not as much experienced as most of you are, I'd like to
share some views of mine,
I developed a GWT 1.7 based application for My final year Project in
CS graduation course.
It's a fun to develop a full blown RIA application without any JS from
my side. I used RPC because web development was totally alien to me at
that time. And the get, post thing is not my concern, because of RPC.
*RPC is simple to use*
But when I need to pass data from server, (I used JPA) I have to
create another layer of classes for RPC representation (I'm not happy
with that, it's clearly against DRY).
Then I thought to host it, so public can access it. :-( Java hosting
is costly. And since I uses RPC (that's specific to Java), now I have
to reimplement it using Http method.
*RPC is less flexible*
* use http, then you can use virtually all server frameworks, may be
it's web2py(my current choice), PHP, grails, RoR, Python frameworks,
and Java itself (if you need), etc., *
Arun
--
Hi Jeff,I don't know why you're binding a Report object to $wnd, but in a standard case JSON usage would look the following way:
On 4 jan, 19:23, Jeff Chimene <jchim...@gmail.com> wrote:
> On 01/04/2010 10:57 AM, Thomas Broyer wrote:
>
> > Use JsonUtils.unsafeEval() to avoid the unused JSONObject created by
> > JSONParser.parse(), and then just use .cast() to turn the JSO into a
> > Report (unless of course you want a singleton in the $wnd.Report
> > global JS variable):
>
> > Report myReport = JsonUtils.unsafeEval(response.getText()).cast();
>
> Hi Thomas:
>
> Isn't an aspect of unsafeEval() that it's unsafe? Is JSONParser() also
> unsafe?
Yes, both use a plain JS eval() to "parse" the JSON string. JSONParser
has room for enhancement in using native JSON parsing in browsers that
support it (IE8, FF3, Safari 4 and Chrome), whereas unsafeEval is
likely to always use eval().
I built my own JSON module that uses JSON.parse() when available
(using deferred binding to never try it in IE6/7, old-mozilla and
Opera, and always use it in IE8) and fallback to JsonUtils.unsafeEval
() otherwise.
> Or do I always want to add comments to the cargo at the
> generator, strip such comments at the receiver and call unsafeEval() (&
> its equivalent on the server)
I don't understand the "comments" thing (I think I understand the
"how", but I clearly don't get the "why")
> From the JSONParser() code, I get the impression that it tries to
> differentiate among arrays, strings, &c. I thought that such behavior
> was A Good Thing.
JSONParser only tries to provide "strong typing" by some kind of
"introspection/reflection", that you obviously don't have with JSOs,
but is it really needed?
Even with JSONParser, you'll generally don't handle the "error path"
and live with potential NPEs (in your snippet, what if the eval'd text
isn't an object but an array?), which finally leads to doing
computations about the data type that you don't really care in the
end.
It's generally not worth paying the JSONValue "tax" of data type
"discovery".
The only thing that's missing with JSOs is an easy way of
doing data type discovery in case the JSON format allows for different
types of data (e.g. in an object, the value of key "foo" can be a
string or an array of strings; an array of numbers or strings; etc.)
Since you're asking this question, I presume you are a novice with
GWT. In this case, your path is clear - use GWT-RPC. While REST/JSON
has its uses, GWT-RPC is far easier to learn and far easier to use.
It's also much more robust in a fast-changing codebase; the client and
server use the same interfaces so the compiler keeps them in sync.
It's not an all-or-nothing choice; my app provides JAX-RS REST
services to iPhone clients but all the GWT<->server communication is
GWT-RPC because it's 10X faster to iterate.
If you're even remotely wondering whether you should use the GWT-RPC
system or roll your own REST APIs, you should be using GWT-RPC. It's
pretty much that simple.
Jeff
It won't work. I mean, GWT.create(someJSO.class) won't work. You just
cannot "instantiate" a JSO, though you can eventually cast() a
JavaScriptObject.createObject() or JavaScriptObject.createArray().
> I think, it should work, but even a Factory class that does the
> instantiation an returns a singleton object might be better than using
> native JavaScript to bind it to $wnd object, since it's important to hold
> everything in the GWT 'sandbox'.
Yes, a Provider would be the way to go.
I'm jumping a bit late in the discussion but as Duong pointed out, our
Restlet Framework has a special edition for GWT (as well as Android
and GAE) and supports RESTful interactions between GWT clients and
servers written in Restlet or other technologies.
Recently, we have even written the equivalent of GWT-RPC for REST/
HTTP, reusing the same serialization logic, therefore providing the
best of both worlds: the productivity and abstractions of annotated
Java interfaces and the reusability and interoperability of a RESTful
backend!
You can read more details about those features in this recent blog
post:
"Restlet, a RESTful middleware for GWT, GAE and Android"
http://blog.noelios.com/2009/12/17/restlet-a-restful-middleware-for-gwt-gae-and-android/
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com