Building a server to an android application - java

I checked this thread which actually looks for the same thing that i look - but he didnt got answered.
What i'm looking for is a way to connect between server (as a java application) and a client (as a android application) - in a way that the client will be able to call remote methods in the server, and get remote objects from the server. (doesn't matter if it uses AIDL or not..)
I worked with RMI and it's fine - but it unnable to use on Android, so i have to find another way.
Thanks for help!

Two possible avenues:
Use servlets on the server and pass data via GET/POST
JAX - pass data via SOAP requests
I'm sure there are others, too.

Related

Is there a way to trap and forward network requests from an iOS app in Java automation code?

Is there a way to intercept network requests emanating from an iOS app in Java (Appium) automation code? Basically I want to mock the server calls with a local server but my requests are protobuf requests so I am unable to use a library like www.mock-server.com. There seems to be another project https://github.com/mkopylec/charon-spring-boot-starter but it also seems to reverse proxy URLs of the application it deploys and not an external application. Basically I want to be able to use an API that can reverse proxy calls from another app from my automation Java code but still be able to deal with Protobuf requests.
thanks,
Paddy

Java Web App: Code to receive UDP packets

I recently started a dynamic web application using Java/JSP and Tomcat.
I did a bit of research, and there's no specific answer about it. I have my front-end JSPs and their handling is done on the corresponding servlets. This is nice and all, and is sort of local.
But I'd want the application to also run another Java class that loops and waits for incoming UDP packets from other external clients. I have a separate UDP receive class which works fine on its own, but I'd like this code to run in the background of the web application.
Is there any way this could be done?
Thank you.

Java application vs web service vs web application

I am developing a multi-platform (Android, iPhone, Windows and Blacbberry) mobile application. The application needs to communicate with our server for several tasks, such as retrieving buddy lists etc. The server interacts with data that is stored in a MySQL database. I intend to code the server element in Java, however I am confused by all the different types. So far, I think I have narrowed it down to three options:
1) I code the application using Jetty to accept http posts. I post XML to the server, handle it, interact with the DB and post a XML response back. I would save the application as a jar and leave it running on my server.
2)I develop a Java web service. REST/JSON/SOAP?
3)I develop a Java web application.
Whilst there are many questions already out there asking what the differences is, I am struggling to find a clear explanation as to what is the best approach in which situation. I have previously used the first approach but am assuming the second approach is the better option, I'm just not sure what the advantage is.
your 1-3 options are all variants of a "Web application".
Jetty is a Java based http server/servlet container. If you want to communicate between client and server using http, you are using an http server (although not necessarily Jetty).
A Web Service is part of a web application that conforms to a standard around how clients communicate with the server, and how the server offers up information to the clients.
A web application is a Java application that makes it services available over http.
So if you want to have your clients communicate with a server, and store info in a db, you are using a web-application.
I would recommend going with option 2 as it is more lightweight and can be parsed directly in you're web application. XML got more overhead and must be translated, while you can just serialize objects directly to JSON from you're Java application and then parse them in javascript at frontend

Server - Client impletmentation using RMI over the Internet

I implemented very basic RMI server client application. It works perfectly in LAN. It doesn't work over the Internet though. What are the things i should consider to make it work over the Internet(Programtically). In future i want to use Client call backs too. So, is it possible using Java - RMI? if yes how ?
It's been a while since I worked with RMI, but as far as I remember Java's RMI only works in the same sub-network. So it won't work directly over the internet.
You will need to use a different Technology like XML over HTTP, REST, Soap or similar Protocols.
If you cannot (or don't want to) change your application, you will probably need to implement some kind of proxy that talks RMI to your application and something different to the clients in the internet. But I would not recommend to do that

How to respond (if possible) to http get requests in GWT?

I would like to make a http get request with my Android phone (i know how to do that) and get the file in return (or some other response from database on the server).
Is it possible to do that in GWT (i just started reading tutorials) on the server side or will i have to learn PHP or sth. else?
I've seen this http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html but don't know if this is what i need.
Thank you very much!
What you need on the Server side is a Servlet engine such as Jetty or Apache Tomcat (or one of many others). You would then write your RPC call as per the link you provided and the server-side Java Servlet (Which is what GWT expects you to provide) would read the file and transfer the data in the file back to the client. The client GWT part of the app would then read the message asynchronously and then do whatever.
For the Server part you need to know Java, I would assume you know that if you are programming GWT.
If you wanted to use something else, like an existing HTTP service in PHP, then you would use the RequestBuilder to build your get or post and send it to the server.
One thing to remember is that everything in your client folder will be compiled to Javascript by GWT. So even though you are working in one project you are actually coding two different systems. One which is in Java (The server folder) and the client piece which GWT translates to Javascript, which runs in the browser.

Categories

Resources