How To Build Web Service Using Spring Boot 2.x

Architecture Contains

  • MVC Architecture
  • JWT Based Authentication
  • Spring Data (JPA)
  • Application User Password Encryption
  • DB password Encryption.
  • SQL Server
  • Slf4j
  • Swagger For API Doc

Repository Contains

  • Application Source code
  • SQL script of Data Base along with key data
  • DB.txt file contains the DB config details.
  • Postman JSON script to test all web services.

Steps to Run Applications

  • Install JDK 11 or the latest version.
  • Clone the Project repository into local.
  • Git Url: https://github.com/VishnuViswam/sample-web-service.git
  • Install SQL server 2012.
  • Create application DB and user
  • Insert the DB key data.
  • Add the decoding key of the database password into the system variables. It is present in the DB.txt file.
  • Sometimes we may need to restart the windows to pick up the updated system variables.
  • Run the project source code.
  • To call the web services, import provided postman JSON scripts into the postman client application.

About Project Configurations

Web-Service Declaration

Each Web-services of the application will be declared in the controller layer.

Example

Java
 
@RequestMapping("/api/v1/user")
@RestController
@Validated
public class UserController {

    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private GeneralServices generalServices;

    @Autowired
    private UserService userService;

    /**
     * Web service to create new user
     *
     * @param httpServletRequest
     * @param user
     * @return
     */
    @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<Object> createUser(HttpServletRequest httpServletRequest,
                                             @Valid @RequestBody UserCreateModel user) {
        logger.debug("<--- Service to save new user request : received --->");
        ApiSuccessResponse apiResponse = userService.createUser(user, generalServices.getApiRequestedUserId(httpServletRequest));
        logger.debug("<--- Service to save new user response : given --->");
        return ResponseEntity.status(HttpStatus.CREATED).body(apiResponse);

    }

}

  • @RequestMapping("/api/v1/user") annotation is used to mention the category of web service.
  • @RestController annotation will configure the class to receive the rest-full web service call.
  • @PostMapping() annotation will decide the HTTP request type.
  • consumes & consumes tags will decide the content type of the HTTP request and response.

From this "controller layer," API requests will be taken to the service layer. All business logic will be handled here, then it will talk with the database using JPA.

How to Use an API

In the video below, we take a closer look at the "How to use an API? | API Tutorial | Web Services Tutorial." Let's get started!

Exploring the Fundamentals of Node.js With Mario Casciaro and Luciano Mammino

Node.js’ high scalability and its ability to run Javascript code outside the territories of the web browsers gives it an edge over traditional platforms for web development. It is considered to be possibly the biggest innovation of the decade and is loved not just for its technical capabilities, but also for the paradigm shift that it introduced in web development and, in general, in the software development ecosystem. 

Let’s explore the journey of Mario Casciaro and Luciano Mammino, the authors of Node.js Design Patterns, Third Edition, and get some insights on how they mastered the platform. 

Web Services or Mobile App Testing — The Prioritization Matrices

Web Service and  Mobile App Testing

Generally, we can say that: Web services are packet sized applications that communicate with each other via network but in a precise format. The output of one software used as an input to another reciprocally and the whole process executed with interface language like XML.

Mobile app testing is a strategic approach to detect bugs and fix them before users identify them. It’s evident that scalable and user-friendly applications win the race and gives your product wide recognition. Mobile app testing does it with it’s set of approaches right from installation, the target device and OS, UI/UX usability, functionality, interrupts, data network, hardware, and performance, and many other parameters.

Automate SOAP Client Auto-Generation Routines With WSDL Import for SBT and Scala

Automate SOAP client auto-generation routines.

Working with SOAP often gets tricky, and dealing with WSDL might be a huge contribution to the complexity of this task. Really, it could be the least expected thing to face when you are into a modern and fancy language like Scala, for example, which is well-known for its reactiveness and asynchronous way of dealing with requests.

In fact, many of the software developers that have made their way into the industry quite recently might not even know about SOAP and WSDL protocols, and get quickly annoyed or even enraged when first trying to connect to such a legacy service. So, should we deprecate this in favor of a modern technology stack or is there a less painful solution?

Do You Need PUT and PATCH?

Conventional wisdom says that REST APIs should be implemented as follows:

  •  GET — read
  •  POST — add
  •  PUT/PATCH — modify
  •  DELETE — remove

This mostly works well. Query parameters can be used to supply arguments for GET and DELETE operations.  POSTs can use either URL-encoded or multipart form data, standard encodings supported by nearly all web browsers, and other HTTP clients.