Building java server which share interfaces wtih Android client - java

2 month ago i started to develop an android application which needs to call remote methods and receive complex objects (custom objects with custom feilds in it) from a server.
My friend and I splitted the work so he worked on the android client and i on the server.
Before we started, we built the base interfaces which provide the functions that the client needs from the server, so my friend can program easly the application (by using fake classes as implementation for the interfaces), and after i finish the implemntations of the interfaces in the server-side he will make the connection and call the functions from the server and not from the fake classes.
Now the problem is that we can't find a way to pass those interfaces from the server to the client.
We tried to use java RMI, but we faild because android doesn't support java RMI,
then we tried to use JAX-WS (with tomcat 7) and we also faild because JAXB can't handle intefaces. (-you can see more details here about jaxb issue-)
My friend and I feel really lost.. we don't have any idea how to pass those interfaces between the server and the android client.
Is it possible what we're trying to do? if not,
what other options avaible for us to call remote methods and receive complex objects from the server?
Thanks!

You can expose webservices on the Server, so the client can interact with the server whenever its needed that might be quickest solution.
Or you can write a kind of servlet programming to get the json request from the client, process it and send the json respoonse back to the client. If the application is data intensive, the JSON helps you a lot

Not sure if this is too late now (after 2 months of development), but there are frameworks that should make RPC easier for you (take care of linking both ends). Two I know of are Apache Thrift (definitely usable with Android - there are apps that use it) or Apache Etch (possibly).
Apache Thrift:
http://thrift.apache.org/
Apache Etch:
http://incubator.apache.org/etch/
Blog about Evernote choice of Thrift:
http://blog.evernote.com/tech/2011/05/26/evernote-and-thrift/

If your application is limited to communication between Java on the server and Android (no other clients e.g. IOS) then an easier RPC path compared with IDL based solutions is to use jsonrpc. This solution provides both server and Android client components. It is extremely easy to implement on both client and server. One limitation is that byte arrays have to be encoded because the JSON transport does not support binary.

Related

Web Client API and Rest API

As I have understood we use Web services(Rest/Soap) so that a piece of code with some functionality written in one language(say Java) can be used by other programmer no matter the language(say Python) he is developing the application over the internet.
One of the projects I came across uses EWS web services to create,delete appointments on our Outlook 365. The application is developed in Java and a JAVA EWSAPI.jar file is included in the library path(which contains class files like appointment.class,Meeting.class etc) to connect to EWS server and create meetings .
My confusion is suppose we were developing the application in Python, so for that do we have another API (say EWSPython.pythonextension). So then how developing a web service helped us.
I understand API defines the set the methods available and how can they be called with argument.
Please clear my doubts.
I think that you have misunderstood the aim of webservices. We need webservices to make their calls (clients) a platform independent interface which means that once you have created your webservice using any technology (java for your case here) now anyone can call this service by creating a client using any language like python, C#, C++, Ruby, ........... in that case a service which was built by Java will be consumed or called by an application or client created using python and vice versa.
JAVA EWSAPI.jar file is a API Client Library.
What is a client library?
A client library, sometimes called a helper library, is a set of code that application developers can add to their development projects. It provides chunks of code that do the basic things an application needs to do in order to interact with the API. For example, a client library may:
Provide boiler-plate code needed to create an HTTP request and to process the HTTP response from the API.
Include classes that correspond with the elements or data types that the API expects. For example, a Java client library can return native Java objects in the response from the API.
Handle user authentication and authorisation.
How is that useful?
Looking at the developer who’s using the API: With a REST API or any web service API, the developer could be using any of a number of programming languages to make the API calls.
Wouldn’t it be great if we could give them some code in their own language, to help them get started with the API? That’s what a client library does. It helps to reduce the amount of code the application developers have to write, and ensures they’re using the API in the best supported manner.
For more information:
https://ffeathers.wordpress.com/2015/10/25/what-is-an-api-client-library/

Java client & server app: Serialization or REST / SOAP / RPC?

I am writing application in Java. It has 2 parts, server and client.
I need to communicate between server and client (secure using SSL). I don't have any other non-Java app connected to server (in long future too not), so I am not dependent on someone else's API.
Most of the data will be strings, numbers, and other "common" data types.
Is it good idea to use Java Serialization to communication between server and client? Or "good way" is use SOAP / XML / RPC / REST / ... ?
I found "Hessian binary web service protocol" is it good or is it waste of time?
Thank you for help. This is my first bigger client-server app.
Why do you want to restrict your service to java applications? It wouldn't be easier to develop and in the future you possible have to change it to other applications be able to communicate with.
I would suggest you to build a Rest Api serializing your data with JSON. It is simple and you can find lot of information about it, and libraries which do everything automatically, almost. To serialize the information you can use libraries like Jackson and to build your Rest Api Server you can use Spring MVC, you have a simple example here.
For the client you can use Jax-Rs 2.0 .
I hope it has been helpful! Ask anything!

What is the best way to create a client-server application with a Java Web Start program?

Ok so I have created an application, which is a Java Web Start application, but I have determined that I will need to write data to the server machine, hence the need for an additional server application. Pretty much I want the client to send different strings in order to process a clients requests in varying ways (eg create a new user file on the server machine or send user data read from a file to the client machine).
I was thinking of possibly using sockets, but if there is a better way then I'm all for that. Also I assume that whatever I do use, I will need to use threading in order to process many simultaneous requests, is this correct?
For your purpose you better create a webservice which communicates over http for exchanging data. I would recommend doing this in Java or maybe creating a WCF in C#.
Tutorials in Eclipse for java webservice: http://www.vogella.com/articles/REST/article.html#first_project
In netbeans: http://netbeans.org/kb/docs/websvc/jax-ws.html
The first tutorial is a restful service which is pretty popular and easy to grasp.
Good luck!

best way to communicate between .net and java

I have a .net application which needs to expose a service consumed by a java client. The service can't be public. There should be some authentication mechanism for the client. What is the best way to do this? I'm new to web services and am confused by all the soap, wsdl etc. and have also heard a lot that it'll be a pain to get the two to communicate. Your thoughts?
Web Services are the one of the best approaches for interoperability over WEB. it's not that much difficult to create and use. It's as simple as Connecting to different databases and writing XML parsing in your code.
There are so many ways doing authentication. If you are using the IIS for deploying .net web services, then You can use Windows Authentication, Forms Authentication. These 2 are out of the box features of IIS. You can implement your custom authentication also. There are few compatible cryptography algorithms also for encrypting your data.
Without web services, it's very difficult to establish communication between Java ad .net.
You can give a try for JSON also. But i am not sure.
Hey check this video which gives you details. http://skillsmatter.com/podcast/java-jee/consuming-a-dot-net-web-service-using-java
I'd go for a simple REST interface using something like Jersey on the Java side, and a .Net JSON library to parse the data I consume.

java server to server communication framework (json)

I am building an ESB (enterprise Service Bus). This means i need to
set up tcp connections and communicate with JSON (well not NEED.. but json is light and easy)
I made a server who is able to set up a TCP socket and receive json. This is all very nice but i need to be able to call methods via a tcp connection.
so for example to call a method:
{server:pictures, method:changeImage('name')}
This is just an example and could change.
my question is: Is there a framework that is able to:
set up tcp server
receive json messages and call the appropriate method
return an answer (in json).
of course json could also be xml but i would rather use json (much cleaner)
thanxs in advance!
A Web Server serving RESTful web services is exactly what you're asking about..
If I were you, I would look into using SOAP based messaging and the WS-* Standards. Things like WS-Federation and WS-AtomicTransactions will allow you to build a more robust ESB.
Any modern Servlet container, perhaps? Running DWR or jabsorb? Have you looked at the modern ESB implementations? Sounds like you have a lot of wheel I've seen before here.
Why do you need to create your own ESB? As I understand it's a quite complex task. Have you considered using existing open-source solutions?

Categories