I want to build a server that communicates with an android phone
based on a request/response model
At first i thought i will use Httpservlets and communicate with the android
by Http messages. but i need to be able to access a pretty big object with every
request so i guess i cant really transfer the object to the servlet.
so i know this is a pretty newbish question but iv'e been searching for days
what kind of java EE tech should i use(i thought of EJB but as i understand they cant communicate with android)?
Thanks in advance
I think the right question is how to implement service layer for your android application:
Basically there are two options REST based web services and SOAP. Android's support for SOAP is inadequate and I personally prefer REST over soap any day. If you have decided to go with REST, your options in Java are Jersey, RESTlets or Spring Rest services. I will prefer Jersey, but you can also look in to Spring ( although not strictly complaint with the JSR).
(note: look in "SO" for comparison on various rest based frameworks in Java)
Related
I have started working on a university project. I have to test various REST frameworks for Android and see which one is the most efficient/stable currently.
Which are most popular REST frameworks currently for Android? I have heard about Spring.
Secondly, how do you create a RESTful service for Android?
There a number of REST libraries that do more or less for you. Arguably, the most popular for Android are Retrofit (https://github.com/square/retrofit) and my personal favourite RoboSpice (https://github.com/stephanenicolas/robospice) for two simple reasons: runs as a service and works alongside Activity lifecycle.
Answering which one is the best would start a flame war.
Keep in mind that ANY library that can do a HTTP request with POST and GET can be "weaponised" as RESTful library, it's only a matter of how much boilerplate you want to write on your own and how much control over each aspect you require.
I have created a Rest Web service using Jersey in a Java EE app. And I was able to create the client in a java app as well. I worked fine.
I'm now trying to consume my Web Service, but this time using Android.
I understood that Jersey libraries are not android oriented (Is that even true ? Please confirm this information ) and I read that Restlet is an alternative to build the Android Client.
How is that possible ? do you have any tutorials or documentation I can read for this purpose ?
"I understood that Jersey libraries are not android oriented (Is that even true ? Please confirm this information )"
This is pretty obvious. If you do the search on the jersey site, nothing shows up.
Also, it's pretty hard to find tutorial about Restlet on Android. I think you have to adapt from Java version. Personally, I use a plain http client to do REST stuff. (I think many people also do that.)
Regarding Restlet, you might find these useful:
http://weblogs.asp.net/uruit/archive/2011/09/13/accessing-odata-from-android-using-restlet.aspx
http://restlet.org/learn/guide/2.1/editions/android/
http://blog.restlet.com/2009/05/06/restlet-available-on-android-phones/
These questions are very helpful if you change your mind and want to do it without a framework.
Restful API service
Need sample Android REST Client project which implements Virgil Dobjanschi REST implementation pattern
I've seen people having trouble with using Jersey on Android before. You have to battle through a lot of exceptions to get it to work. There is a library on github that attempts to provide android support for jersey but I've not used it myself.
Restlet is available on android phones and you will have an easier time integrating it and getting it to work. However, I've personally found that using the HTTP client library on Android coupled with an external library to perform serialization / deserialization ( like gson ) is the easiest route to writing a REST client.
I am looking to create a simple service to learn calling a service from android.
What I want to do is an app to call a system over the web provide some parameters and the system respond. Very simple (hopefully)
But I want to build both ends.. not just the android end.
What tools would the community recommend that are industry standard and hopefully easily accessible.
I am hoping TomCat can do the hosting, but don't know if this should be a JSP or EE application.
Can anyone point me to an email of setting this up, again with both sides.
Hopefully Tomcat is a decent enough server to be both easy to setup and robust enough if enough calls are made to it.
Once that is done then I only need to do the android portion with Ksoap or anything else that is recommended.
Thanks in advance and I hope this is not too general a question.
I recommend using Apache CXF for a server. It does pretty much everything that you need in a web service. It does have a client part, but so far, I have implemented web services on Android myself, rather than using libraries. But that was a while ago, maybe today libs are better customized for Android.
I'm going to develope an application based on web services (axis2) and android (clients).
I'm now planning the logic architecture for my system and I supose that it should be like a SOA architecture. I have seen that a SOA architecture is based on layers.
So, this would be a "correct" logic architecture for my application? (with some changes of course)
http://geeks.ms/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/unai/DDD_5F00_NLAYER_5F00_ARCHITECTURE_5F00_SMALL_5F00_6ADA95E1.png
Android code (activities) would be on Presentation Layer?
EDIT
April 2014
Now, 3 years later with some more experience... REST is the best :)
Warning, it may that this answer is not at all an answer to you question but anyway, here is my thoughts.
I'm definitely not a SOA specialist but since SOA can be implemented with REST, it should not have any consequences on a SOA architecture. Android is REST-ready (see that Google IO 2010 session on REST) and there is only little SOAP support on android (afaik, but I may be wrong).
At some point, you'll have to evaluate the feasibility of the interop. between your Axis WS-* with any existing android SOAP support (the well-known ksoap2 project for example). The result could be not without impact on your architecture design.
The point here is: if you do use Rampart to use WS-Security, for example, on top of Axis2, it seems to me there are little chances that ksoap may interact at all (technically) with your service provider. On the one hand, if the service is simple and can be bound with ksoap2, great, go on. On the other hand, if you would use a not so simple security or authentication scheme, it could just be a nightmare to get the things done with the simple SOAP support on android. In the latest case and as the REST approach seems to be the preferred philosophy on android, you may be confronted to the decision to have a REST proxy dedicated to android between your Axis2 business WS and the android client-side application.
In the hope it may be of any help.
Perhaps you could even try SOAP. Android supports SOAP web services and provides ksoap2 libraries which you can use for sending request and getting response from your server easily.
For starters just check this out. Now, the latest version of ksoap also supports passing of Object Arrays.
For more information of ksoap2, I suggest to read this
Cheers
All the best
I'm a student trying to dive into the world of "complex web-enabled applications" for Android.
I had good tries making Android applications that call php functions, have JSON or XML responses and results, serialize objects and so on...
It really can work for simple projects, IMHO. For projects that require an increased complexity and control, I really would like to try something else.
Since Android apps are made in Java, I'm thinking it could be great if I could work with Java objects in Android and storing/retrieving Java objects in the server side too. Java Server Pages could be an answer, since I can embed Java code into HTML pages/HTTP services.
Is possible (and comfortable) to achieve this? Can I work with "local objects" in my Android app and with "remote objects" in my JSP app storing them, for example, in a remote database?
What could be an alternative?
I hope I've been clear. Thank you!
Spring android as HTTP client and ORMlite in the client side has been my salvation in many android projects. What I generally do is have this in the client side and in the server side use a Spring MVC server. But if your server is written in Php there's no problem. With this environment I can work with object in the client side and in the server side, never touching json/xml. I'm making a tumblr client in android. In this package I've all the things related to the Http client rest package. Look how I use it in this class example.