Spring service and Spring web app in one - spring

I'm making a Spring RESTFUL service and i wonder. Can I make a Spring RESTFUL service combine with a web app in a project. If it is possible, how to configure it?
.

yes that is possible to combine with web-app
for example your controller package into your restful controller also work
that is possible to crud operation via restful web service.

Related

Create a web application using Spring framework for back-end but without using Spring MVC.s

I want to learn the Spring Framework and therefore I decided to make a web application using it, but I don't want to use Spring MVC as it still uses JSP. What all projects from Spring can be used if I want to have a UI which can be made using React / Angular and the backend is managed by Spring.
You have to use REST API, and pass data to front-end JS framework via JSON.
Look here: https://spring.io/guides/gs/rest-service/
Start with creating a simple Rest Controller with Spring Boot.
Then you have to choose your JavaScript framework (jQuery, Angular, React),
and make a HTTP request to URL typed in your #RestController.
You can achieve this by using AJAX method from your JS framework.
Try this,it will speed up your development
Restful Web Service with Spring Boot
by the way,if you want to use Angular/React+Spring Boot you can use JHipster, this tool will just do the basic setup for your Angular/React+Spring Boot application in couple of minutes,the website has a clear video tutorial you can use it will only take about 15 min approx
Jhipster

Which Spring project is for RESTful Web Services as Spring Web-Service Project is for just SOAP based web services?

I was looking to implement RestFul Web Services using Spring so in all Spring Projects list I saw Spring Web Services.
But Strangely it's just for SOAP and no Restful web services!
Where is project for RestFul web Services? Is there any JAX-RS implementation of Restful Web Services?
( Actually, It should be part of Spring Web Services project as its a popular web Services architecture as SOAP itself)
For Creating ReSTful web using spring, two ways are there :
1.One very easy way to use Spring MVC project. Spring provides annotations specificto ReSTful web services if you are using Spring MVC project like #RestController etc.
2.One can also create ReSTful web services by following JAX-RS methodology. Using spring-boot-starter-jersey project. Using this one can get other core functionalities of spring framework like DI, AOP etc.

Spring REST API for web- and mobile-clients

This is my first question on StackOverflow and I hope someone can help me. :-)
I am planning to build a web-application (backend) with spring roo. For the backend I will use Spring and Hibernate/JPA. In the future I will implement a web client (JSF/Primefaces), a mobile client (Android) and a Windows App.
With spring roo it is easy to create a layered architecture with domain classes, repositories and services. This part is fun.
But now I am thinking about remoting and how to connect all the clients (web, mobile, windows) with my backend.
1.) What do you prefer for the remoting between client and backend? SOAP-Web Services or a REST-API (e.g. with JSON).
2.) If REST-API: How should the API look like for authentication/login functionality? REST is resource-oriented but how do you implement authentication with REST API?
At the moment I think a REST-API is a good idea. Because I am using spring it is easy to create a Spring MVC controller with REST support. But is this the correct way to implement a REST API for all the three devices? The web client e.g. should be implemented with JSF and Primefaces and I donĀ“t use spring MVC for the web layer.
3.)Can I nevertheless use Spring MVC controllers to build the REST API (together with JSF in the web layer)? Or is there a better way?
1.) What do you prefer for the remoting between client and backend? SOAP-Web Services or a REST-API (e.g. with JSON).
I don't have too much experience with SOAP-WS, but I have a ton of experience with REST-APIs using JSON. There are many implementations for mobile, web and server side clients that are fairly simple to implement.
2.) If REST-API: How should the API look like for authentication/login functionality? REST is resource oriented but how to implement authentication with REST API?
If you are already using spring, I recommend securing your API with Spring Security. You can use spring security even if you don't end up going with Spring MVC for your API implementation. There are many ways to secure a rest API with spring security, but I the simplest is to send the basic auth header with every request to a secure URI
3.)Can I nevertheless use Spring MVC controllers to build the REST API (together with JSF in the web layer)? Or is there a better way?
Spring MVC Controllers will work fine, but I would recommend going with RestEasy or Jersey. I find them to be more flexable.
I agree with #mad_fox. Additionally, i want to add another option regarding your question#2. If you dont want to use Spring security, you can write your own token based authentication mechanism using spring and basic java interceptors.
You can store the token in your browser local storage.

Spring 3.2 web application and android client

I have a Web application with a db and it uses spring framework, hibernate etc. I need to send data from a mobile client (iphone,android) to web application like login, insert, update db etc. There are many ways to do that I think, however I am looking for a good solution. What would you prefer? Spring Security? REST?
Yes, spring-security to secure your service, and spring-web && spring-mvc with jackson dependencies to create an annotated rest service that you can host in something like tomcat.

Securing REST endpoints with CXF in OSGI Karaf

What is the standard approach in securing REST endpoints implemented with CXF in OSGI?
The system in question is a web application deployed as a WAB in Karaf. The application contains JavaScript making AJAX calls to REST service implemented in a separate OSGI bundle using CXF. The main Web application is secured using Spring Security (with the standard DelegatingFilterProxy). The application should be open to be used with any security provider compatible with Spring Security.
We need to be able to obtain the user information in REST services based on the principal with which the user authenticated in the main Web application.
What is the best way to secure the REST endpoints in the application?
Thank you,
Michael

Resources