This createProduct services is create the product with the following parameter like price,name of the product,description,price.
It used coupon services to give the discount on the product...
#Technology used Java,Spring-data-jpa,SpringRest,springWeb #tools Spring-tool-suite,postman #project Management tools apache maveen
#VC Git
======================================================================================================================================================
#RestTemplate
-
Rest Template is used to create applications that consume RESTful Web Services.
-
You can use the exchange() method to consume the web services for all HTTP methods.
#You will have to follow the given points to consume the API −
- Autowired the Rest Template Object.
- Use HttpHeaders to set the Request Headers.
- Use HttpEntity to wrap the request object.
- Provide the URL, HttpMethod, and Return type for Exchange() method.
#The REST application follows the REST architectural approach.
- We use the REST application for developing and designing networked applications.
- It generates the HTTP request that performs CRUD operations on the data. Usually, it returns data in JSON or XML format.
=====================================================================================================================================================
-
REST stands for REpresentational State Transfer.
-
It is developed by Roy Thomas Fielding, who also developed HTTP.
-
The main goal of RESTful web services is to make web services more effective.
-
RESTful web services try to define services using the different concepts that are already present in HTTP.
-
REST is an architectural approach, not a protocol.
-
It does not define the standard message exchange format. We can build REST services with both XML and JSON.
-
JSON is more popular format with REST. The key abstraction is a resource in REST. A resource can be anything.
-
It can be accessed through a Uniform Resource Identifier (URI).
#For example:
The resource has representations like XML, HTML, and JSON. The current state capture by representational resource. When we request a resource, we provide the representation of the resource. The important methods of HTTP are:
- GET: It reads a resource.
- PUT: It updates an existing resource.
- POST: It creates a new resource.
- DELETE: It deletes the resource.
=========================================================================================================================================================
For example, if we want to perform the following actions in the social media application, we get the corresponding results.
-
POST /users: It creates a user.
-
GET /users/{id}: It retrieves the detail of a user.
-
GET /users: It retrieves the detail of all users.
-
DELETE /users: It deletes all users.
-
DELETE /users/{id}: It deletes a user.
-
GET /users/{id}/posts/post_id: It retrieve the detail of a specific post.
-
POST / users/{id}/ posts: It creates a post of the user.
==================================================================================================================================================================
- 404: RESOURCE NOT FOUND
- 200: SUCCESS
- 201: CREATED
- 401: UNAUTHORIZED
- 500: SERVER ERROR
===================================================================================================================================================================== #RESTful Service Constraints
-
There must be a service producer and service consumer.
-
The service is stateless.
-
The service result must be cacheable.
-
The interface is uniform and exposing resources.
-
The service should assume a layered architecture. ================================================================================================================================================================ #Advantages of RESTful web services
-
RESTful web services are platform-independent.
-
It can be written in any programming language and can be executed on any platform.
-
It provides different data format like JSON, text, HTML, and XML.
-
It is fast in comparison to SOAP because there is no strict specification like SOAP.
-
These are reusable.
-
They are language neutral.
================================================================================================================================================================== #SOAP vs REST Web Services
#There are many differences between SOAP and REST web services. The important 10 differences between SOAP and REST are given below:
#SOAP
-
SOAP is a protocol.
-
SOAP stands for Simple Object Access Protocol.
-
SOAP can't use REST because it is a protocol.
-
SOAP uses services interfaces to expose the business logic.
-
JAX-WS is the java API for SOAP web services.
-
SOAP defines standards to be strictly followed.
-
SOAP requires more bandwidth and resource than REST.
-
SOAP defines its own security.
-
SOAP permits XML data format only.
-
SOAP is less preferred than REST. ============================================================================================================================================================ #REST Web Services
-
REST is an architectural style.
-
REST stands for REpresentational State Transfer.
-
REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
-
REST uses URI to expose business logic.
-
JAX-RS is the java API for RESTful web services.
-
REST does not define too much standards like SOAP.
-
REST requires less bandwidth and resource than SOAP.
-
RESTful web services inherits security measures from the underlying transport.
-
REST permits different data format such as Plain text, HTML, XML, JSON etc.
-
REST more preferred than SOAP.
============================================================================================================================================================================
#Json:
- JSON stands for javascript object notation.
- The extension of json file is .json.
- The internet media type is application/json.
- The type of format in JSON is data interchange.
- It is extended from javascript.
- It is open source means that we do not have to pay anything to use JSON.
- The object created in JSON has some type.
- The data types supported by JSON are strings, numbers, Booleans, null, array.
- It does not have any capacity to display the data.
- JSON has no tags.
- JSON is quicker to read and write.
- JSON can use arrays to represent the data.
- It can be parsed by a standard javascript function.
- It can be easily parsed and little bit code is required to parse the data.
- File size is smaller as compared to XML.
- JSON is data-oriented.
- It is less secure than XML.
#XML:
- XML stands for an extensible markup language.
- The extension of xml file is .xml.
- The internet media type is application/xml or text/xml.
- The type of format in XML is a markup language.
- It is extended from SGML.
- It is also open source.
- XML data does not have any type.
- XML data is in a string format.
- XML is a markup language, so it has the capacity to display the content. 10)XML data is represented in tags, i.e., start tag and end tag.
- XML file is larger. If we want to represent the data in XML then it would create a larger file as compared to JSON.
- XML file takes time to read and write because the learning curve is higher.
- XML does not contain the concept of arrays.
- It has to be parsed before use. XML data which is used to interchange the data, must be parsed with respective to their programming language to use that.
- It is difficult to parse.
- File size is larger.
- XML is document-oriented.
- It is more secure than JSON.
============================================================================================================================================================== #Maven
-
Maven is a powerful project management tool that is based on POM (project object model).
-
It is used for projects build, dependency and documentation.
-
It simplifies the build process like ANT. But it is too much advanced than ANT.
#Understanding the problem without Maven
There are many problems that we face during the project development. They are discussed below:
In case of struts, spring, hibernate frameworks, we need to add set of jar files in each project. It must include all the dependencies of jars also.
We must create the right project structure in servlet, struts etc, otherwise it will not be executed.
We must have to build and deploy the project so that it may work.
==========================================================================================================================================================
#What it does?
Maven simplifies the above mentioned problems. It does mainly following tasks.
- It makes a project easy to build
- It provides uniform build process (maven project can be shared by all the maven projects)
- It provides project information (log document, cross referenced sources, mailing list, dependency list, unit test reports etc.)
- It is easy to migrate for new features of Maven
==============================================================================================================================================
#Apache Maven helps to manage
- Builds
- Documentation
- Reporing
- SCMs
- Releases
- Distribution
=====================================================================================================================================================
#What is Build Tool A build tool takes care of everything for building a process. It does following:
- Generates source code (if auto-generated code is used)
- Generates documentation from source code
- Compiles source code
- Packages compiled code into JAR of ZIP file
- Installs the packaged code in local repository, server repository, or central repository
=============================================================================================================================================================
#How to install Maven on windows
You can download and install maven on windows, linux and MAC OS platforms. Here, we are going to learn how to install maven on windows OS.
To install maven on windows, you need to perform following steps:
- Download maven and extract it
- Add JAVA_HOME and MAVEN_HOME in environment variable
- Add maven path in environment variable
- Verify Maven
-
Right click on MyComputer -> properties -> Advanced System Settings -> Environment variables -> click new button
-
Now add MAVEN_HOME in variable name and path of maven in variable value. It must be the home directory of maven i.e. outer directory of bin. For example: E:\apache-maven-3.1.1 .
To verify whether maven is installed or not, open the command prompt and write:
mvn −version
===============================================================================================================================================================