質問

I am new to web dev but I have managed to build my site using GWT and GAE. I use RequestFactory for client-server communications.

Now, someone wants to make mobile applications that use my backend.

I have found that RequestFactory works very well with Android. But I am somehow afraid it will not work with other "not-google" front ends (iOS for instance).

So my question is, can I make an API based on my RequestFactory backend (servlet) that can be used by any client? Any initial pointers as to how to implement it would be appreciated.

役に立ちましたか?

解決

I guess technically it would be possible. However, if you want to create an api anyone can use, you probably want an api were you specify both how to communicate with the api and the content send/received by the api. With RequestFactory both the how and what is shielded by RequestFactory. So if someone wants to communicate with your api and can't use the RequestFactory code in the project, the how and what of RequestFactory must be reverse engineered, and could change anytime because it's not guaranteed. Not the most elegant way to go forward.

A better approach is define an open api were you specify the how and what. For example with and apu based on REST (the how), communicating JSON data, and to specify the content format (the what). An example of such an api is the twitter api.

For your own project you could build on your api also, for example by using RestyGWT. Then you don't have to maintain both the code for the RequestFactory interface and REST interface. For other platforms there are probably several libraries available to make developing against a REST interface easy.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top