Webservice



Def:

Web services are client and server applications that
communicate over the world wide web's (WWW) HyperText Transfer Protocol (HTTP).
Web services provide a standard means of interoperating between software applications 
running on a variety of platforms and frameworks.

Two Types:

SOAP
RESTful

SOAP

1. SOAP stands for Simple Object Access Protocol.
2. It is a XML-based protocol for accessing web services.
3. It is platform independent and language independent.
4. By using SOAP, you will be able to interact with other programming language applications.
5) SOAP defines its own security known as WS Security. When come to comparing SOAP is more secure than Rest.


Q.Which one is more secure Restful or SOAP?

Ans. SOAP defines its own security known as WS Security. When come to comparing SOAP is more secure than Rest.


Soap Disadvantages:

SOAP uses XML format, must be parsed to read,
SOAP only supports XML,
SOAP uses WSDL.

Restful

REST - Repersentational State Transfer

REST is an architectural style not a protocol.

Why you are using Restful?

No protocol.
Language and platform independent.
Response difrent data format. Ex. JSON Data Format.

Advantages of RESTful Web Services:

Fast: 
RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.

Language and Platform independent: 
RESTful web services can be written in any programming language and executed in any platform.

Can use SOAP:
 RESTful web services can use SOAP web services as the implementation.

Permits different data format: 
RESTful web service permits different data format such as Plain Text, HTML, XML and JSON.

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. RESTful 
SOAP permits XML data format only.
SOAP is less preferred than REST.

REST:

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.
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.

Q.Why Restful Webservice FAST?

It consumes less bandwidth and resource.

HTTP Methods:

Get -retrieve the data
Post- 
Put - data update
Delete- delete the data

What is Messaging?

Ans: A client sends a message in form of a HTTP Request and
server responds in form of a HTTP Respose.


Caching:

Caching is process of storing server response in client side,
so that a client needs not to make server request for same resource so many times.

***** JAX-RS Annotations
@Webservice
@path
@pathparam
@get
@put
@post
@head
@delete
@options
@Formparam

Most frequently used annotations:

@Path
syn: @Path('/path')
Its a class and method level of annotation
This will check the path next to the base URL
 Base URL after Run path

@pathparam

@Get
We can say it is a method level annotation.
This annotation indicates that the following method method should respond to the
HTTP Get request only.

@Put
we can say it is a method level annotation
This annotation indicates that the following method should respond to the HTTP PUT request only.


@post
Method level annotation
indicates that the following method should respond tho the HTTP post req only.


@Delete

method level annotation
HTTP Delete request only

@Produces Annotation