Java Web Service - Has it to be in a new project? - java

As you can see, I'm really starting learning about Web Services and, in all examples I've seen, a new Web Project is created to implement the Web Service.
In my case, I already have a Web Application implemented and I need a WS to an Android app for this application. So, my question is: can I create the WS in this project or do I have to make a new project for that?
Any help will be apreciated, thanks.

Can I create the WS in this project or do I have to make a new project for that?
It depends on your design. Any web application can be the producer of the web services, so yes, you can use your current web application to host the services. But, there will be more requests to your application since there are new clients apart from internet browsers, so if your application is prepared to handle lots of requests, then do it. IMO it should be a different web application since they have different purposes, even if they use the same business services and data access layers, so if your main web application is undeployed for maintainability purposes, then your web application that hosts the services can be still up and running smoothly.

Related

Developing app with web and Android client with Java

I'm going to start developing a new simple "X management" kind app, like contact management or events management. What I want to know is which tools would be the best to achieve it in the way I want.
My app needs to be a web app running on a server that has a mysql database to save and retrieve some simple information. This app must have a web client but I want it to be able to be extended to work with an Android app client.
Things I've thought:
I've worked on Java with facelets and JPA travels management app running on a GlassFish server on localhost with a JSF web view, so maybe my web client and the full app could be done with this.
I've worked with web services such as SOAP and REST with Jaxb and xml schemes to retrieve information parsing some webs into xml or json to show on a client .net app. So I've thought I can add to my app, like last topic we talked about, a REST web service layer to easily work as I want, or at least I think it would be easy. If I do this the Android app could share the same app core code but using the REST service.
My question is what could be the best way to do an app with 2 client side in different platforms that could share some code to be easy to extend it moreover to a desktop app. I've talked about these 2 options because I'm a students of computers at university and those are the tools I know, but I can easy learn more. I've also think about just a REST service and create a web and an Android client to work on same service or something like that.
This post is getting long, so here is the summary: What technologies and tools do you think are the best choice to create an java web app that needs to have web and Android client? Also what server, like tomcat, GlassFish or another, should I use? And what about persistence layer? JPA with mysql is the best I know to work with.
Thanks a lot.
P.D: I work with eclipse
From my point of view:
You can use java jersey and java spring both ( java spring as Dependency injection) for creating RESTful Web service. So, In server side you will create endpoint and you can access data from any platform through those endpoint.
Server can be anyone. It's up to you. I always try to use tomcat but tomcat is not a full JavaEE container it's only a servlet container. So if you want to use full JavaEE version then you should use Glassfish.
And yes JPA .It can be easily used in any environment supporting JPA including Java SE applications, Java EE application servers, Enterprise OSGi containers etc.
On the other hand, still choice is yours.

Issues with Creating application as a Web Service vs Regular MVC

I am working on a web application. The requirement is that is the future the application may also be used by other web application and mobile application.
My idea was the build the whole business logic layer as rest web service and build web client to consume this.
Later I can use the same thing in case I want to build a mobile client or give it to external parties. This saves me from writing a separate api code.
Is this the correct way?
Will it have any performance impact?
What is the primary reason of not adopting such an approach.?
I am using Java ,spring MVC,spring,hibetnate and Mysql as the development stack

Application architecture - how to connect Swing app to backend?

We are developing a java application which provide web services through SSL. This application is running in Tomcat server.
The purpose of web services is insert, update and select data. So under web service tier is implemented backend tier, which provide access to database.
Suddenly we were asked to build swing application which will also access the data in database. We want to use the same backend (exactly the same runtime) which is used for web service application. How to reach this goal?
I see following possibilities:
use web app instead swing application, which will be part of the same project like web service application and then it will be able to connect backend
Provide some extra web services for swing application only.
Use JMX. It is possible run JMX on Tomcat. Backend could provide functionality through JMX and Swing application could connect it.
Each of these possibilities have advantages and disadvantages. We followed solution 3 and I think it wasn't a clever selection. JMX has problem with generics, you can run only one JMX on tomcat etc.
Java world is rich and there should be some optimal solution for this situation. Could you help?
Add a web service client to the Swing app and let it make exactly the same calls to web services that a browser based UI would.
You're certainly free to add extra, Swing-only web services if you choose.
I didn't think JMX was anything other than a way to allow you to monitor MBeans using a JConsole. What does that have to do with Swing?

Client architecture for calling Spring based web service

I have written a SOAP based web service which runs fine on a Tomcat server. The Web Service service itself is a Spring MVC based web service that runs on the Tomcat application server.
Now i need to write a Thick client which will be a standalone Java app that will use the services of the web service. I think i am correct in that the client only needs to know about the service details (i.e. operations) and nothing else.
What i am not sure of is the architecture and environment i should use for the client. The client application will be based on Swing but is it possible to use Spring with Swing together?
On the web service i have the following setup
view --> Service --> Model
The client application is basically a configuration tool. It uses the web service to configure user accounts. This means that the client application does not actually write anything to any database. It just uses the services of the web service to make changes to 'user account' and probably view list of accounts.
My question really is
- Is an MVC design suitable for such a use case
- Usually Spring is used for web based applications. Is there any benefit in using Spring with the Swing based client?
- Are there any alternative or better solutions/design/architecture that would achieve the same?
An example showing Spring used in conjunction with a Swing application would be very usefull.
Thanks in advance.
Spring MVC is not appropriate for a Swing-based client. Use the core Spring framework and a JAX-RS implementation like Jersey to provide simple REST web services in tomcat. Jersey also provides a corresponding client API that you can use within your Swing application to invoke the REST services.
If you have decided upon Swing as your platform, there are two options you can look at:
(1) Net Beans Rich Client Platform
http://netbeans.org/kb/trails/platform.html
(2) You can roll up your sleeves and write your own app using a low level yet extremely flexible framework called Swixml
http://www.swixml.org/
Give Swixml a good try before you try others, it may surprise you.
You can implement Swing-based thin client application with Spring Integration backend serving as a integration tier. It can expose gateways accepting simple Java types or DTOs. Your Swing presenters / controllers interacts with these components in order to call remote webservices.

Web Service / Forms: Architecture and Framework Question

We have the following architecture in mind:
To an existing application, we would like to add a web service front end.
The web service will be used from a web portal, which runs on a different web server.
So, we will not use a database on this different web server and just forward entries from the web portal to the web service and show what the web service returns.
First question: what do you think about this architecture?
Second question: Can you recommend a java framework for this web server?
On the second question: one possibility is to use WSRP with Java Portlets.

Categories

Resources