Retrieving information from java service to Android app - java

I am new to Android development and java services and I wanted to know how to implement this. I have a Java service using Spring (deployed on Tomcat, locally) and I can call a method in it called getInfo() that will send a JSON string of info. I want to know how to call this method getInfo() from my Android application and how to retrieve that JSON string? How do I communicate with the service? Please help me understand.

There are numerous ways to do this on android. An OS library that I like to use for Rest calls in android is called Retrofit.
http://square.github.io/retrofit/
Retrofit works by turning your interaction into your web service into plain old java objects by abstracting away the http request and the parsing of the json response.

Related

How to Consume JSON as input in PUT and POST method of REST webservice in android?

I want to consume rest webservice get and post method json format in android application. But I dont know how to consume and get the data from server can u please guide me to get and post the json data to server in android platform.
The best thing to use on Android for this is the Retrofit library. See their how to to accomplish this pretty easily.
Google states on their Android Developers page to use Volley for HTTP Requests.
About Volley: https://developer.android.com/training/volley/index.html
Request: https://developer.android.com/training/volley/simple.html
You can use this Tutorial to implement your stuff (it provides more information):
http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/

Use C# or VBA to call Jersey JAX-RS REST Webservice

I have a Jersey REST webservice and it works fine with java client. Now I'm wondering is it possible to use C# or VBA to call this webservice? Sorry I am new to C#/VBA. I am trying to create a add-in for excel. As far as I know I can use these two to create add-in. So my questions are:
What's the best way to create add-in in excel for getting/uploading data? Is Java possible? Or should I use C#?
If I use C#, is it possible to call java webservice in C#? I want to upload data via this webservice.
Thanks in advance.
Anything that can build an HTTP request matching the input expected for your Jersey REST service will work. JAX-WS and JAX-RS services are going to be exposed as agnostic access points for anything which can send an XML/JMS or HTTP request. You can confirm this by simply opening the endpoint in your web browser and trying to submit some GET requests that way.
That is the beauty of web services, they SHOULD be language agnostic. Basically you are just calling a url to return you some xml/json data which c# can handle.

How to create a web proxy service using a Java Program

I have a scenario where I am supposed to contact a RESTFul API which sends me a response in JSON. After I get the response I am suppose to store the data in the DB.
We use BPEL for our development. But, for clean development/deployment I am using Java for contacting the RESTFul API so that I don't have to handle any Java codes in my BPEL. So I wanted to create a web service proxy.
I have created a class which contacts this endpoint and gets me the response (JSON) and converts the response message(JSON) into XML.
Now, I want to create a Web Proxy service which I can host for this Java program that I have created. Is there any way that I can do this?
Thanks!
I got a solution to this. I created an intermediate webservice using java (using json.org library) for consuming the REST API and then giving my BPEL the SOAP response after parsing the JSON response.

How can I implement Hunch's API in java?

I'm creating a Java application that uses Hunch's API, but the problem is I have no clue as to how I can use a web API in Java. Any ideas?
That depends on what the API provides, generally you'd need a web server (like Tomcat) to run a web framework.
If it's just an api to communicate with a service via HTTP (maybe webservices) then have a look at the corresponding libraries (JAX-WS etc.).
Edit: I looked up Hunch API, and assume it is this: http://hunch.com/developers/v1/
It seems like it would return JSON encoded data, so you might use the URL class to read data from an URL. That data would be a JSON string which then needs to be decoded using one of the many JSON libraries out there (e.g. JSON-simple).

Android Client connecting to RestFul Webservice

hello All
I have been fed up of looking for a simple example of rest webservice connecting to Android Application. I know so many people have asked this question before, but there are so many different answers as a theory.
I know I must use restful web-service, rather than SOAP for mobile applications.
I need to create a webservice which is producing JSON, then in Android I can parse the JSON, but the problem is that as I am new to android I am looking for a simple example with both Server and client.
A server : JAVA with Database connection and Restful WebService that produce JSON
Android Client : which parse the JSON result from the webservice
please if somebody can provide such a example , please please help me.
Firstly, before you create your own web service, you might like to experiment with existing web services, such as those provided by Yahoo.
Have a look at the PlaceFinder API by Yahoo, its a free web service you can call, and is quite well documented. You can find the JSON examples here
Create a simple, standard java app that queries that web service, deals with JSON then System.out.print something from the response, that will get you familiar with what you need before you bring the android platform into the question
I haven't used the JSON examples, but I've written a quick tutorial on the XML side which may be of help. Once you're comfortable with this, introduce that code into an Android application and get it to print something on the screen.
You have quite a broad set of requirements in your question, please try what I've recommended then come back with refined further questions
Good luck!

Categories