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.
Related
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.
Currently I am working on an iPhone app. But the company also would like to have an android version for this app.
I have programmed all the request by Soap and used for the iPhone the Soap Request Generator of Sudz-C.
I am wondering now if something similar exists for the Android, It would be nice if I don't have to program this all by myself.
Anyone have some experiences or ideas?
You can use
http://easywsdl.com
website to generate all required java classes for your webservice. It uses ksoap2 library and supports many features like objects sent as references (WCF IsReference), complex inheritance, document and rpc style of webservice, all standard data types (including normal enums and IsFlag enums), and much more
ksoap2-android is what you are looking for, it will send/recive soap request's, is easy to use and on MIT license
I go through a lot of solution solution in WSDL 2 android. google don't matter about SOAP service and provide anything for it. wsdl2java won't work in most of case, some library cannot be use by android SDK. I suggest you to use http://easywsdl.com.
you'll see you can edit your own package name, class prefix and many other parameters depends on your need. If you have complex data and your are familiar to use Gson (https://code.google.com/p/google-gson/) to send parameter between your activities don't check "Use JodaDate" that is a great library for using date, but Gson doesn't support it (yet).
If you have few services that don't work (yes that can happen, depend of your WSDL configuration file), report it to contact and they will make the possible to fix your issue like they did for me.
The generator is fast. you will receive all your generated code and the .jar that you'll have to import into your project.
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 looking for an alternative HTTP client library than what is already included in the SDK. I haven't been able to find any. Does anyone know of any? It doesn't have to be open source.
Many of the issues with Android's built in HttpClient are related issues that have been resolved in HttpClient 4.1. Dirk Boye has created a script to convert the HttpClient 4.1 sources into an Android friendly package. You can find some prepackaged jar files and his script here: https://code.google.com/p/httpclientandroidlib/
You have different options to manage networking in Android:
OkHttp (needs Okio) + Volley + Gson: is a common REST solution for JSON based APIs. You can use each of these tools separately, so for example if you don't need JSON serialization/deserialization you can just use OkHttp + Volley (where OkHttp is the Http client and Volley is a REST library/helper that offers an easy way to load images as well). If you just want an alternative Http client you can use OkHttp(+Okio) which is the best one or among them right now. OkHttp needs Okio(that you can use as well separately) and is a library that complements java.io and java.nio to make it much easier to access, store, and process your data. You can find more information about this solution here..
OkHttp (needs Okio) + Retrofit + Moshi + Picasso. This option is pretty much equivalent to the previous one. Retrofit is comparable to Volley, Moshi to Gson and Picasso is on image loading department. All of this stuff was mainly developed by the same guys and all tied together works like a charm. More on that here.
ION is a very good library that tries to deal with a lot of stuff mention in the options 1 and 2 (Http client, REST helper, uses Gson as well and load images). Better check this out.
Android Async Http: I haven't tried and don't have any information about it, but looks like might be worth taking a look.
I'd say the option 1 is being replace by the option 2. The option 3 has a lot of fans and is developed basically by one (awesome) guy, but offers a LOT of things that you might be not using. That's the reason the Square guys (guys behind option 2) have split everything in 5 different libraries. I can't say much about the option 4. I might be checking it out soon.
Notable mention is Glide, that is (maybe) the best image loading library today developed by the (Google acquired) Bumptech guys.
A guy working on Okio/OkHttp was working in Google on the SDK http client, worked on Gson and is working on Moshi. That's the reason I am more inclined for the option 2 nowadays, people use to do better stuff than previously, or at least not worse.
OkHttp by Square is a good alternative.
Volley made by Google is also great in design.
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)