Skip to content

Intro To WebServices

raghusumanth edited this page Oct 1, 2020 · 1 revision

Welcome to the SpringBootApps wiki!

SpringMicroservices: Spring evolved alot: annotation, spring mvc, rest, spring boot, spring cloud and microservices.

RestfulWebServices:

Basic Concepts:

  • HTTP Request Methods: GET, PUT, DELETE, POST
  • Exception Handling, Validation, HATEOAS
  • HTTP Response Status: 200, 400, 404

Advanced Concepts: Versioning, Swagger, Filtering, Monitoring, Content Negotiation, Internationalization.

Tools/Frameworks Used: Spring, SpringBoot, JPA, Maven, Postman

MicroServices with SpringCloud:

  • SpringCloud Config Server and Bus
  • Load Balancing with Ribbon and Feign
  • Implement Naming Server with Eureka
  • Implement API Gateway with Zuul
  • Distributed Tracing with Zipkin
  • Fault Tolerance with Hystrix

Intro to WebService:

Software System designed to support interoperable machine to machine interaction over a network.

3 Keys:

  • Desgined for machine to machine(or application to application) interaction.
  • Should be interoperable - Not platfrom dependent
  • Should allow communication over a network.

How does data exchange takes place between applications?

  • Input to webservice is called Request, output from a webservice is called Response.

How webservices can be platform independent?

  • Request and Response formats should be platform independent. There are two popular formats: XML and JSON

How does the application know the format of Request and Response? By Service Definition: it specifies below things:

  • Request/Response Format
  • Request Structure
  • Response Structure
  • Endpoint

Key Terminologies of Web services: Request/Response

  • Message Exchange Format(XML/JSON)
  • Service Provider or Server
  • Service Consumer or Client
  • Service Definition(Defines the contract between Server and Client)
  • Transport(HTTP and MQ)

Web Service groups:

  • SOAP-based: Poses restrictions on the format of XML which is exchanged between service provider and service consumer.
  • REST-Styled: Defines an architectural approach

SOAP: Simple Object Access protocol. We use XML as Request Exchange format. Defines a specific XML request/response structure. Soap Envelope, Soap Header(with meta info- authentication, authorization etc.), Soap Body(real request and response content).

SOAP defines a format for request/response . Does not pose any restrictions on transport.

  • Format: SOAP XML Request, SOAP XML Response
  • Transport: SOAP over MQ, SOAP over HTTP
  • Service Definition is typically done using something called WSDL(Web Service Definition Language)

WSDL defines all the operations allowed and specifies the request/response structures.

Intro to Rest:

Representational State Transfer. Makes best use of HTTP. Request/Responses are in the format defined by HTTP. Request and Responses contains the Headers and Body. Additionally it defines something called RequestMethods(GET, PUT, POST,DELETE..) in Request. Response also will include HTTPResponse status codes: 200, 400,404, 5xx..etc.

Resource: A resource has an URI(Uniform resource identifier). A resource can have different representations: XML/HTML/JSON

In Rest:

  • No restriction on data exchange format. JSON is popular
  • Transport: only HTTP
  • Service Defination: No Standard. WADL(Web Application Definition Language)/Swagger/...

REST vs SOAP

  • Architectural Approach vs Restrictions
  • Data Exchange Format
  • Service Defination
  • Transport
  • Ease of Implementation