1 Reply Latest reply on May 7, 2013 8:33 AM by ktorp

    Android/Seam communication options

    zzzz8

      I currently have a web app that runs on Seam 2/ICEfaces/Liferay.  I'm starting to build an Android app that will communicate with my Seam 2 backend.  What options do I have?

       

      I'm leaning towards using RestEasy with Seam to provide a REST interface that my Android app can communicate with.  It's easy to do this on the backend with the JAX-RS annotations and fairly simple Seam/RESTEasy configuration, JAXB, along with ResourceQuery and ResourceHome features in Seam.  However, it seems like it would be difficult to implement something similar on the Android client side to marshal/unmarshal SOAP or JSON.

       

      Is it possible to run the RestEasy client on my Android app?  Should I even do this?

       

      Another option is using Exadel Flamingo.  It looks very promising.  However, that project seems to be dead...

        • 1. Re: Android/Seam communication options
          ktorp

          Hello.

           

          There are probably a lot of good ways to do android - seam communication, but I can tell you how we do it, and hope this can help you and answer some of your questions.

           

          We use gson in both ends to marshal/unmarshal json in order to make the corner cases (null handeling, double numbers with NaN or inf. and so on) behave consistently.

           

          To make the interface more type safe and let us get some compile time errors, the json data structure and interface we use to communicate is implemented as POJOs in a shared jar file. This pojo lib is included in the android app and in the seam project and is used by gson to do all marshalling/unmarshalling. Of cause the libs need to be in sync for this to work.

           

          In order to use gson to marshal/unmarshal the arguments and return values one the serverside, the resteasy anotated methods only have one parameter, and thats a UTF-8 string and return an UTF-8 encoded byte array. Also we only use POST in order to be able to send lots of data to the backend in a consistent way.

           

          This is the setup that works for us on the server side:

           

          @POST
          @Consumes("text/*;charset=utf-8")
          @Produces("text/json;charset=utf-8")
          @Path("/somePath")
          public byte[] theMethod( String parameterAsJSON) throws Exception
          

           

          On the android side we use restlet to consume services.

           

          I hope this helps.