We have have an application who have a service and dao layer. It use spring 3.2
We started to create a new web application who use spring 4 (client side and controller).
What could be the best technology to communicate both application? Both are not on the same server.
I know there is spring remoting, but I don't know if it's still a good solution.
I'd recommend exposing the service layer using contract first SOAP or REST web services. They'll be reusable by any client that can make an HTTP request, including your new app.
Spring remoting is a fine solution and only takes a few minutes get set up.
Related
I´m building a web application which comunicates server and clients through REST services (I´m planning to build a mobile app in mid term).
I´ve used Spring Security in other web applications without REST services. But I´m not sure if that approach is suitable for my scenario.
Is it possible secure both access to web pages and calls to REST services using Spring Security? What would you recommend?
Backend uses Spring Data + Spring MVC.
Thank you.
Yes, Spring Security is a good way to secure both REST endpoints and traditional MVC webpages. The implementation can be similar for both your REST endpoints and MVC routes depending on your requirements.
Spring Security is a popular and effective way to add security to your Spring application. Since you already have experience with it, you should be able to secure your REST endpoints with relative ease.
Check out this detailed tutorial on securing REST routes with Spring Security to get started: https://spring.io/guides/tutorials/rest/5/
I have had lots of trobule trying to get my head around how to solve this scenario:
We have an integration application that uses Camel for integration. This application also has a REST Api that exposes some services providing information about the application, for instance listing the active routes etc.
I have created a user interface for this using AngularJS that connects to these rest services. My main problem is how can I package this application as a self contained jar-file that provides the user interface and all the camel integration.
My working theory: Use a separate Jetty server to serve the Angular JS files and let Camel expose the REST services. The problem with this is CORS since the REST services reside on another port than the jetty server serving the Web UI.
Some requirements for the solution:
Must be a single self contained jar-file.
The camel integration is the main purpose, the Web UI is secondary
and only used for trouble shooting. No need for a high performance
web container since the Web ui is used by only a handful of users.
I have been struggling with this for a couple of days now and it feels like I am over complicating the solution. Help on how to solve this is greatly appreciated.
You could take a look at hawtio
http://hawt.io/
as that is how we do that, hawtio is a web console for java, and has plugins for Camel. Its built using angularjs, and uses REST to communicate with the local or remote Java JVMs. To make the REST calls easier we use Jolokia.
Jolokia requires an agent to be embedded in the JVM, eg where Camel runs. Then that helps with CORS et all. http://jolokia.org/reference/html/security.html#d0e2490
I'm wondering if it is possible to create XML-RPC server component within EJB module without servlets. I know EJB typically uses RMI as communication protocol but what if I want to omit RMI. What if i want to exchange data between EJB and web module (WAR) or other clients by different way like XML-RPC.
Can EJB-module work as stand-alone unit which will expose its state and services as XML-RPC server?
I still can do EJB module connected with WAR via RMI while this WAR will expose those services via servlet. Then other WARs or whatever-they-are clients can call this first WAR. Is this right or there is some other possibility?
What you probably want is to use Spring Remoting to expose your EJBs via for instance JAX-WS. Spring will create automatically servlets for handling the requests for you. The bad news is that you have to call your EJBs from the remoting services you build - meaning some boilerplate code. It should be quite straight forward though.
An other possibility you might take a look at is Restlet which can be used to build restful services.
In EJB3, your service beans are just annotated POJOs. You can simply annotate the same POJOs with #WebService (and the rest of this family of annotations) to expose the same services as web services.
I realize this isn't strictly what you asked for as the implementation for services exposed in this way is JAX-WS which uses SOAP messages. But I think it achieves your intent.
I have set up a CXF web service which works well. My service primarily loads data from an ftp to a db.
I would like to create a web interface through which the invoker can view the progress of their package. I thought it would be easy to integrate Spring MVC with CXF but there doesn't seem to be any good solution. I searched all over the net and could not find any thing simpler than this http://ayax79.wordpress.com/2009/02/19/making-spring-mvc-and-cxf-play-well-together/
The reason I would like to integrate Spring MVC with CXF and not create a stand alone web interface is because I have some custom Spring beans with in the CXF service which I can make use off to start and stop the process.
Is it that difficult to build an interface on CXF? Or am I just not thinking in the right direction?
The article you linked to has more to do with handling 1) web requests and 2) CXF requests within the same webapp, i.e. building a web application which can accept traditional http requests for MVC pages and also accept web service requests.
The author of that article seems to be pretty confused about Spring and how ApplicationContexts work, as the commenter Felix provides a good and simple solution for what the original author wants to accomplish (reuse the same bean definitions and instances within two contexts, having some URLs mapped to DispatcherServlet and other URLs mapped to a CXF dispatcher).
If you simply want your Spring MVC web application to be able to interact with and make requests to a CXF service, this is simple - you write code to consume the services as you would in any other type of application that interacted with a CXF/Soap/etc web service.
I'd recommend taking a look at the following sections in the Spring manual about access JAXRPC or JAXWS web services:
Accessing web services using JAX-RPC
Accessing web services using JAX-WS
Another option that you have is to simply generate client proxies for your CXF service using a tool like wsdl2java. Note that the next two options on this page I linked to, "JAX-WS Proxy" and "JAX-WS Dipatch APIs" do the same thing functionally as the Spring option above (creating a dynamic proxy at runtime).
I'm researching how best to create a Restful web service on Google app engine. My end goal is to have an Android application call a web service on GAE to post and get data. At this point I not sure what the best approach is.
What I know at this point is Spring MVC 3 provide the ability to create web service but it does not provide a full implementation of JAX-RS. I also have read a few blog that talk about how Spring and Restlet can be integrated together. On the other side I have read that I could only use Restlet in GAE. I would also like provide a light web interface for users to view their posted data
So my questions are the following.
1. Should I just use Restlet.
2. Should I just use Spring MVC to provide my Restful web service.
3. Should I use Spring and Restlet together.
At this point I think I should invest my time in Restlet because that seems to be the best approach for calling web services in Android. I'm also debating if Spring MVC is just over kill.
Any thoughts would be helpful.
Have a look at the following similar questions:
Easiest frameworks to implement Java REST web services and Can anyone recommend a Java web framework that is based on MVC and supports REST?
I recently set up RESTlet on GAE and it was an absolute breeze! There are docs outlining the procedure on the RESTlet website and I was up and running RESTlet on GAE using the Google datastore within two hours.
The major downside is that performance of the Google data store for low volume apps is atrocious. Timeouts are not uncommon. (Google mandates a maximum 30 second request time and your app can easily take up half of that in coming out of hibernation if it hasn't been accessed recently)
Right now I am building another RESTful app and chose to go the Spring 3 MVC / Hibernate / MYSQL route. I am not new to Spring DI or MySQL, but I am new to Spring MVC and it is taking me days to work through all the issues I am encountering. I am disappointed in the quality of available documentation and I have not been able to find a reasonable and complete Spring 3 MVC RESTful CRUD tutorial anywhere. Argh.
I don't have experience with Restlet but Spring MVC 3.0 is quite powerful for building restful webservice AND webapps. So if you also plan for your service to be accessible through browsers then it is a great solution since your controllers can serve both apps and browsers.
Perhaps this is also possible with Restlet but I have not heard of its capabilities for building webapps.
Just beware that Spring has a high loading time. This means that you have to be careful to avoid slow responses from cold starts.