In my java based web application (struts 2 and hibernate 3). I have made a web-service using apache axis.
The web-service has to return data from the database which will be used by the android application.
Now, that service obviously has to be published on a public ip so that I can access it in the android app.
What are the options to publish it on free public ip's or domains ?
Would it be better if I use REST instead of apache-axis to make a web-service? What is JAX?
And for android developers , How a web service is consumed in android?
Please answer its urgent and important.
In order to publish on the web you need to put it on a web enabled server, you can do it in several ways:
Turn your computer to a server (thuis is one article, just search in google "how to turn my computer to web server").
Upload your files to a free host
Upload your files to a paid host (usually for a very small fee)
REST vs SOAP (apache-axis):
I would recommend going with REST as it is more lighweight and more flexible (it enables you to get a response as xml,json,html while soap is usually just XML).
JAX-RS id java API for creating REST web services. Look at the jersey framework.
AJAX is a way to send/get data asynchronously and is used wideley in web applications.
How a web service is consumed in android can wideley vary depending on the technology you are using.
Related
I'm trying to understand the difference between Web Services and Websites.
In college, I learned how to build a website up by writing servlets and JSPs. However, I want to build"websites" using methods that people are using right now.
But I'm confused with the term of Web Services / Websites.
I was reading on JAX-RS, and it seems that JAX-RS is used for web services, and then I figured out there's a server side and client side. Does it mean that this application was created to communicate with each other using HTTP? An example is chat room that communicates through HTTP port? Then does this have nothing to do with creating website?
Does this means that JAX-RS is not used for building websites?
I'm being confused over this topic already. Can someone point me to the right direction?
Thanks
Website you have developed using JSP and Servlet can be categorized as a fully fledged web application where there is a backend (database, etc) and a UI front end for user interaction.
Webservices on the other hand are a set of services exposed through a set of URL or URI which doesn't necessarily have a UI front end for direct user interaction. More like an API.
For Example, Facebook can be considered as a dynamic website and Facebook Developer API which provides different services for third party (such as authentication, friends list, messages etc) can be considered as web service.
I was reading on JAX-RS, and it seems that JAX-RS is used for web services, and then I figured out there's a server side and client side
Yes JAX-RS is mostly used in web services and web services do have a client side. This client is mostly another application written to call the web service and rarely has user interaction.
Does this means that JAX-RS is not used for building websites?
No it is possible to use JAX-RS to build websites also. If you layer your web services using JAX-RS and then create web pages with Javascript or Flex or some other client to consume and produce for those JAX-RS web services then you can build a web site.
JAX-RS is a specification for RESTful Web Services with Java.
A service provides certain operations(server side). A client consumes the operations of a service. So a website could be a client of a service.
A web site can be used to collect and send data to services as well as display the results.
For example you login to a website to purchase a flight. The website asks for date of departure, departure city/state, destination city/state. Once you enter this information the website collects this data and builds a request and invokes some service. In return the service responds with flights that meet your date and destination requirements. The site parses this information and displays this data for you to choose the desired flight.
The website provides a user experience suitable for the data retrieved/displayed.
The web service enables the passing of this data via a defined request/response.
Here is the background of my situation:
I want to create an iPad application that interacts with a oracle SQL database. I have existing Java code from my Flex application that handles all the database requests, and modifications using the Spring Framework. The Flex Application ran as a web service through TomCat. Now I want to make that flex application into a mobile iPad version. I am having trouble figuring out what is the easiest way to use existing Java code and use it for the iPad because the iPad interacts using URL requests instead of direct with the Java.
My question is, can I use the existing Java code with the Spring framework to save time from coding all the back-end handling? Basically I want to access all the classes from my Java code by doing Requests from the iPad. Is this possible and will I need JSON or XML to interact between the iPad and the Java code?
Summary:
Can I use
iPad Objective-C <-----> Java (with spring framework) on TomCat Web Service to handle oracle SQL data handeling? If so, how and what technologies do I need? Will I need JSON or XML and how does that factor between the iPad and Java?
Thanks!
A good approach would be to design your app to communicate with RESTful services that return JSON. Once this is done your iPad app doesn't have to even know that the server code is written in Java.. it's just interacting over HTTP.
Here's a good tutorial on setting up your tomcat to host your RESTful services: http://www.vogella.com/articles/REST/article.html - I've used this for an app I'm developing. Spring isn't even necessary.
You could go XML, but JSON is just easier in my opinion. Here's a good blog outlining the good and bad of both sides. http://digitalbazaar.com/2010/11/22/json-vs-xml/
OK, I'm making the following presumptions.
Your flex application runs on a different machine from the Tomcat
server
Your flex application makes web service calls to the Tomcat server
So, the flex application doesn't know the underlying technology that provides the web services. It's just seeing/consuming the output
There's no reason why the iPad app can't do the same thing. There's no reason why it can't use the same web services that the Flex application uses. It could consume the same messages (Assuming it can handle the request/response format currently employed by the Flex application).
You can make changes if you like if you want to change the structure of the requests/responses between the clients. But the clients don't know (nor care) how the web services are implemented. They are just requesting and consuming info.
I'm developing a server-client application. It is a service that is supposed to be used by thousands of users so it should scale well. The server side is done in Spring + JPA(Hibernate) and it provides about 80 API methods. There will be multiple clients - GWT webapp, mobile devices clients (iOS, Android, Windows) + a simple desktop client (Eclipse RCP / To be decided).
I'm considering various ways to connect to the server side. My ideas are (maybe there are some other, better ways):
Use SOAP Webservices to expose server API to all the clients
SOAP WS are considered to be slow and I don't know it can handle all the communication
Android doesn't officially support SOAP WS (bu there are some 3rd party libs)
Use RESTfull WS to handle communication
better performance than SOAP
official support on all the mobile devices
may be difficult to access RESTfull WS from non-web, desktop client
Use REST WS for mobile, GWT Request Factory for webapp
Request Factory is recommended way to communicate with GWT client (at least it was on 2009 Google I/O). I suppose it should perform better than Web Services?
Which solution (listed above or not) would perform best and be the most productive for developers?
If you've worked on a similar project, I'd love to know your opinion :)
I'd vote for Using RESTful services on the backend, and interacting with that from the front end of your choice.
This gives you the most flexibility in terms of serving multiple clients. For instance, you can end-of-life a front end technology without having to remove any server side code, or you can introduce a new front end without any back end changes.
If you avoid trying to support both REST WS for mobile and GWT-backed server side classes (such as GWT-RPC) for webapp, you will have the following advantages:
Single back end to develop and test: do not underestimate this!
Ease of monitoring network traffic to debug what either end actually sent. GWT network traffic is not so easy to debug, I'll take JSON over GWT-RPC any day.
Don't worry about one technology or another not being able to consume your services: REST WS is becoming so popular that there are a variety of ways to use those services from any front end. For instance, a GWT app could use GWT overlays to map JSON responses to GWT/Java objects, and a desktop client could use Apache HTTP Client.
If your webservices are RESTful, I will recomend you RestyGWT.
I used it a long time ago and it works pretty well.
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
Our application is written in Java. Now we are integrating with a different company which offers web service API. This API allows Microsoft.NET or SOAP enabled application to integrate. Please consider me in this naive. So how do I verify if my application is SOAP enabled or how do I make it? Actually our current plan to integrate is through data transfer between two systems. But some customers want single sign on. So I am thinking of using their API in our application.
There are many web service libraries available for Java. One is included by default in Java 6, and is available for Java 5 here https://metro.dev.java.net/