Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views78 pages

Chapter 3

The document discusses web connectivity for connected devices using various protocols including HTTP, SOAP, and REST. It outlines the function of communication gateways, the characteristics of HTTP requests and responses, and the structure and usage of SOAP messages. Additionally, it compares REST and RESTful APIs, highlighting their advantages and disadvantages in web service communication.

Uploaded by

chethanm9945
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views78 pages

Chapter 3

The document discusses web connectivity for connected devices using various protocols including HTTP, SOAP, and REST. It outlines the function of communication gateways, the characteristics of HTTP requests and responses, and the structure and usage of SOAP messages. Additionally, it compares REST and RESTful APIs, highlighting their advantages and disadvantages in web service communication.

Uploaded by

chethanm9945
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 78

WEB CONNECTIVITY FOR

CONNECTEDDEVICES NETWORK
USING GATEWAY, SOAP, REST,
HTTP RESTFUL AND WEBSOCKETS
Communication Gateway
• Communication gateway connects two
application layers, one at sender and
the other at receiver.
• The gateway also enables use of two
different protocols, one at sender and
the other at receiver ends.
• The gateway facilitates the
communication between web server
using the TCP/IP protocol conversion
gateway and IoT devices.
• It also facilitates communication
between the devices using CoAP client
and server using HTTP.
Gateway Provisions
1. Connects the sender and receiver ends using two different protocols.
• Example: IoT devices network maybe ZigBee network for connecting the
devices. The network then connects to the web server through a gateway. The
server posts and gets the data using HTTP.
2. A gateway facilitates the communication between IoT devices and
web server.
• Example:, (i) ZigBee to SOAP (Simple Object Access Protocol) and IP or
• (ii) CoAP protocol conversion gateway for RESTful HTTP
3. Functions as proxy between the system and server.
HTTP Request and Response Method
• An application uses a protocol.
• The application layer in TCP/IP suite of
protocols for Internet uses HTTP, FTP,
SMTP, POP3, TELNET and a number of
other protocols.
• HTTP is most widely used application layer
protocol for communication over TCP/IP.
• An HTTP client connects to an HTTP server
using TCP and then the client sends a
resource after establishing an HTTP
connection.

https://www.youtube.com/watch?
v=qcALGDn0zpk

https://www.youtube.com/watch?
v=wW2A5SZ3GkI
What does HTTP stand for?
A) Hyper Transfer Text Protocol
B) Hypertext Transmission Protocol
C) Hypertext Transfer Protocol
D) High Transfer Text Protocol
What does HTTP stand for?
A) Hyper Transfer Text Protocol
B) Hypertext Transmission Protocol
C) Hypertext Transfer Protocol
D) High Transfer Text Protocol
Answer: C) Hypertext Transfer Protocol
Which of the following HTTP methods is used to retrieve data
from a server?
A) GET
B) POST
C) PUT
D) DELETE
Which of the following HTTP methods is used to retrieve data
from a server?
A) GET
B) POST
C) PUT
D) DELETE
Answer: A) GET
Which HTTP method is used to submit data to be processed to
a specified resource?
A) GET
B) POST
C) DELETE
D) HEAD
Which HTTP method is used to submit data to be processed to
a specified resource?
A) GET
B) POST
C) DELETE
D) HEAD
Answer: B) POST
What is the default port for HTTP?
A) 21
B) 80
C) 443
D) 8080
What is the default port for HTTP?
A) 21
B) 80
C) 443
D) 8080
Answer: B) 80
Which HTTP status code indicates that the request was successful?
A) 200
B) 404
C) 500
D) 403
Which HTTP status code indicates that the request was
successful?
A) 200
B) 404
C) 500
D) 403
Answer: A) 200
In which layer of the OSI model does HTTP operate?
A) Application
B) Presentation
C) Transport
D) Network
In which layer of the OSI model does HTTP operate?
A) Application
B) Presentation
C) Transport
D) Network
Answer: A) Application
Which of the following HTTP status codes indicates "Not
Found"?
A) 200
B) 403
C) 404
D) 500
Which of the following HTTP status codes indicates "Not
Found"?
A) 200
B) 403
C) 404
D) 500
Answer: C) 404
Which HTTP method is idempotent, meaning it can be
repeated multiple times without causing different outcomes?
A) POST
B) PUT
C) DELETE
D) PATCH
Which HTTP method is idempotent, meaning it can be
repeated multiple times without causing different outcomes?
A) POST
B) PUT
C) DELETE
D) PATCH
Answer: B) PUT
What does the HTTP status code 301 indicate?
A) OK
B) Moved Permanently
C) Found
D) Unauthorized
What does the HTTP status code 301 indicate?
A) OK
B) Moved Permanently
C) Found
D) Unauthorized
Answer: B) Moved Permanently
Which of the following is true about HTTPS compared to
HTTP?
A) HTTPS is slower than HTTP
B) HTTPS is less secure than HTTP
C) HTTPS encrypts data using SSL/TLS
D) HTTPS uses port 80
Which of the following is true about HTTPS compared to
HTTP?
A) HTTPS is slower than HTTP
B) HTTPS is less secure than HTTP
C) HTTPS encrypts data using SSL/TLS
D) HTTPS uses port 80
Answer: C) HTTPS encrypts data using SSL/TLS
What does the HTTP method PATCH do?
A) Deletes a resource
B) Partially updates a resource
C) Retrieves a resource
D) Fully replaces a resource
What does the HTTP method PATCH do?
A) Deletes a resource
B) Partially updates a resource
C) Retrieves a resource
D) Fully replaces a resource
Answer: B) Partially updates a resource
Which HTTP header is used to specify the media type of the
resource?
A) Content-Length
B) Content-Type
C) User-Agent
D) Accept
Which HTTP header is used to specify the media type of the
resource?
A) Content-Length
B) Content-Type
C) User-Agent
D) Accept
Answer: B) Content-Type
What is the purpose of the HTTP OPTIONS method?
A) To retrieve data from the server
B) To submit data to be processed
C) To retrieve the allowed communication options for a URL
D) To create a new resource
What is the purpose of the HTTP OPTIONS method?
A) To retrieve data from the server
B) To submit data to be processed
C) To retrieve the allowed communication options for a URL
D) To create a new resource
Answer: C) To retrieve the allowed communication options for
a URL
Which of the following HTTP methods is considered unsafe
but idempotent?
A) GET
B) POST
C) DELETE
D) PUT
Which of the following HTTP methods is considered unsafe
but idempotent?
A) GET
B) POST
C) DELETE
D) PUT
Answer: C) DELETE
Data Exchanges Between HTTP Web-Objects

• An HTTP connection enables a one-way


communication at an instance from client
API to a server or from server to the API.
• An HTTP transfer is stateless which means
each data transfer is an independent
request. Therefore, header overhead
information and meta-data of previous
state need to be present with each HTTP
request. Metadata is data which describes
the data for interpretation in future.
Therefore, each data interchange needs
large headers over 100s of byte, and thus
greater latency in request-response
exchanges.
• HTTP polling is a method for
receiving new messages or
updates from an HTTP server.
Polling means finding whether
new messages or updates are
available and receiving them
in case they are.
• Polling methods have high
latencies and header sizes of
100s of bytes. An alternative
to this is using Java Applets,
Silverlight or Flash plugins.
SOAP(Simple Object Access
Protocol)
• Simple Object Access Protocol(SOAP) is a
network protocol for exchanging structured data
between nodes.
• It uses XML format to transfer messages.
• It works on top of application layer protocols like
HTML and SMTP for notations and transmission.
• SOAP allows processes to communicate
throughout platforms, languages and operating
systems, since protocols like HTTP are already
installed on all platforms.
• SOAP enables development of applications and
APIs.
• SOAP functions connect the GUI applications to
web servers using the standards of the Internet
—HTTP and XML.
• Microsoft’s .NET architecture supports SOAP for
Internet application development.
SOAP(Simple Object Access
Protocol)
• SOAP uses a body element after the specifications in an envelope. The
body element contains the SOAP message intended for ultimate
endpoint of the message
• A SOAP request could be an HTTP POST or an HTTP GET request.
• The HTTP POST request specifies at least two HTTP headers: content
type and content length.
• A SOAP method uses HTTP request/response after the HTTP binding
with the SOAP.
• The request and response complies with the SOAP encoding rules.
Let’s take an example to explain the structure and usage of SOAP
https://www.youtube.com/watch?v=sTGgBoFBDAY
What does SOAP stand for?
A) Simple Object Access Protocol
B) Secure Object Access Protocol
C) Server Object Access Protocol
D) System Object Access Protocol
What does SOAP stand for?
A) Simple Object Access Protocol
B) Secure Object Access Protocol
C) Server Object Access Protocol
D) System Object Access Protocol
Answer: A) Simple Object Access Protocol
SOAP is primarily used for:
A) Web page design
B) Sending email
C) Web services communication
D) Database management
SOAP is primarily used for:
A) Web page design
B) Sending email
C) Web services communication
D) Database management
Answer: C) Web services communication
SOAP is primarily used for:
A) Web page design
B) Sending email
C) Web services communication
D) Database management
SOAP is primarily used for:
A) Web page design
B) Sending email
C) Web services communication
D) Database management
Answer: C) Web services communication
Which protocol does SOAP rely on for transport?
A) HTTP
B) FTP
C) SMTP
D) DNS
Which protocol does SOAP rely on for transport?
A) HTTP
B) FTP
C) SMTP
D) DNS
Answer: A) HTTP (though SOAP can use other protocols, HTTP
is the most common)
Which of the following is true about SOAP?
A) It is language-dependent
B) It is platform-independent
C) It cannot be used over the internet
D) It only supports XML
Which of the following is true about SOAP?
A) It is language-dependent
B) It is platform-independent
C) It cannot be used over the internet
D) It only supports XML
Answer: B) It is platform-independent
SOAP messages are typically formatted in:
A) HTML
B) JSON
C) XML
D) YAML
SOAP messages are typically formatted in:
A) HTML
B) JSON
C) XML
D) YAML
Answer: C) XML
Which of the following is not a component of a SOAP
message?
A) Envelope
B) Header
C) Body
D) Footer
Which of the following is not a component of a SOAP
message?
A) Envelope
B) Header
C) Body
D) Footer
Answer: D) Footer
What is the purpose of the SOAP Envelope element?
A) To store attachments
B) To define the start and end of the message
C) To handle errors in the SOAP message
D) To authenticate the user
What is the purpose of the SOAP Envelope element?
A) To store attachments
B) To define the start and end of the message
C) To handle errors in the SOAP message
D) To authenticate the user
Answer: B) To define the start and end of the message
In a SOAP message, the Header element is used for:
A) Providing error information
B) Storing the main message content
C) Storing optional metadata and control information
D) Encrypting the message content
In a SOAP message, the Header element is used for:
A) Providing error information
B) Storing the main message content
C) Storing optional metadata and control information
D) Encrypting the message content
Answer: C) Storing optional metadata and control information
What is the main purpose of the Body element in a SOAP
message?
A) To store the SOAP message metadata
B) To store the actual data or payload of the SOAP message
C) To authenticate the SOAP message
D) To define message parameters
What is the main purpose of the Body element in a SOAP
message?
A) To store the SOAP message metadata
B) To store the actual data or payload of the SOAP message
C) To authenticate the SOAP message
D) To define message parameters
Answer: B) To store the actual data or payload of the SOAP
message
What does WSDL stand for, and how is it related to SOAP?
A) Web Services Description Language; it describes the services
available via SOAP
B) Web Services Data Language; it stores data in SOAP
C) Web Services Directory Language; it registers SOAP services
D) Web Services Debugging Language; it tests SOAP services
What does WSDL stand for, and how is it related to SOAP?
A) Web Services Description Language; it describes the services
available via SOAP
B) Web Services Data Language; it stores data in SOAP
C) Web Services Directory Language; it registers SOAP services
D) Web Services Debugging Language; it tests SOAP services
Answer: A) Web Services Description Language; it describes the
services available via SOAP
REST and RESTful HTTP Web
Applications
• W3C Technical Architecture Group (TAG) developed the
Representational State Transfer (REST) architectural style.11. The
group worked in parallel with HTTP 1.1.
• REST and RESTful are terms used to describe web applications that
use the Representational State Transfer (REST) architectural style:
• REST: A set of constraints that uses the web's current protocols and
technology
• RESTful: A web application that follows the REST architecture and
uses HTTP verbs like GET, PUT, POST, and DELETE to manipulate data
REST and RESTful HTTP Web
Applications
• Here are some characteristics of RESTful web applications:
Uniform interface
RESTful APIs have a consistent user interface across many devices
• Stateless
RESTful web services are stateless, meaning they are resources that can be identified by their URIs
• Cacheable
RESTful APIs can be cached, which improves performance and reduces network traffic
• Integration
RESTful APIs provide standardized and predictable integration across platforms
• HTTP methods
RESTful web applications use HTTP methods to create, retrieve, update, and delete resources
REST APIs are flexible and simple, making them ideal for evolving projects.
RESTful APIs are more standardized and predictable, making them crucial for large-scale projects.
REST and RESTful HTTP Web
Applications
• REST uses HTTP requests like GET, PUT, POST, and DELETE to manage CRUD (Create, Read, Update,
and Delete) operations. When you start reading about REST, you would also like to read about
RESTful and know the differences between them. While REST is a set of constraints, RESTful is an
API adhering to those constraints.
• Advantages of REST API:
• REST API is a lightweight and flexible architecture that can be easily implemented on any platform
or language.
• REST API is stateless, which means that each request contains all the necessary information to
complete the request. This allows for scalability and reduces the load on the server.
• REST API is widely adopted and supported by most modern programming languages and
frameworks.
• REST API provides a simple and standardized way of accessing resources over the internet.
REST and RESTful HTTP Web
Applications
• Disadvantages of REST API:
• REST API may not be the best choice for complex business logic and workflows.
• REST API can be difficult to implement in certain situations, especially when dealing with complex
data structures.
• REST API does not provide a built-in authentication or authorization mechanism, which means
that developers must implement their own security measures.
REST and RESTful HTTP Web
Applications
• Advantages of RESTful API:
• RESTful API is a standardized implementation of the REST architecture, which makes it easier for
developers to build and maintain web services.
• RESTful API provides a uniform interface for accessing resources, which simplifies the
development process.
• RESTful API supports caching, which can improve performance by reducing the number of
requests sent to the server.
• RESTful API can be used with a variety of data formats, including XML and JSON.
• Disadvantages of RESTful API:
• RESTful API may not be suitable for complex business logic and workflows.
• RESTful API can be difficult to implement in certain situations, especially when dealing with
complex data structures.
• RESTful API can be slower than other web service architectures, especially when dealing with
large amounts of data.
REST and RESTful HTTP Web
Applications
• Similarities between REST API and RESTful API:
• Both REST API and RESTful API are based on the REST architecture.
• Both REST API and RESTful API are stateless, which means that each request contains all the
necessary information to complete the request.
• Both REST API and RESTful API provide a simple and standardized way of accessing resources over
the internet.
Difference Between REST and RESTful API
Factors REST API RESTful API

Web application follows REST architecture, providing


Define Develops APIs to enable client-server interaction.
interoperability between different systems.

Working Uses web services and is based on request and response. Working is completely based on REST applications.

Nature Highly adaptable and user-friendly Too flexible

Strong protocol and is more secure, built-in architecture


Protocol Has a transport protocol, is less secure as compared to REST.
layers.

Has a cacheable, client-server, stateless, layer system with a All features of REST architecture along with some additional
Architecture
uniform interface. unique features.

Format of Data Format of data is based on HTTP. Format of data is based on HTTP, text, and JSON.

Bandwidth This consumes minimum bandwidth. This consumes less bandwidth.

It represents cacheable and non-cacheable data and The client can access cacheable information anytime and
Cache
displaces the non-cacheable data when not required. anywhere.
REST software architecture style provisions for the use of
specific practices, such as client-server mode of communication
and layered system architectural approach.

• Client-server interactions: It has characteristics of performance and creation of


scalable web objects and services.
• Scalability means ability to support greater number of interactions among
components and greater number of components
• Layered system: to a client which can connect through an intermediate layer
(proxy, firewall, gateway, proxy or intermediary server). REST enables
intermediate layer processing by constraining the messages such that the
interactions at each layer are self descriptive.
• Example: intermediate layer and server or proxy and server.
• Representation of each application state contains links that may be used for a
next-time interaction when the client selects those links and initiates a new state
transition.
RESTful
• When all interactions used in the applications conform fully to the
REST constraints then these are called RESTful.
• RESTful APIs comply with these constraints and thus conform to the
REST architectural style.
• RESTful HTTP APIs
WebSocket
• WebSocket is a
communication protocol that
allows a web browser and a
server to communicate in
real-time, without closing the
connection after each
exchange.
• It's used for applications that
require quick back-and-forth
communication, such as live
chat and gaming.
WebSocket
• Here are some key features of WebSocket:
• Two-way communication
• WebSocket allows the client and the server to send data to
each other at any time, without continuous polling.
• Persistent connection
• WebSocket establishes a persistent connection, allowing
data to flow both ways instantly without repeated
requests.

• Compatible with HTTP


• WebSocket is designed to work over HTTP ports 443 and
80, and supports HTTP proxies and intermediaries.
• WebSocket is different from HTTP, which is used to serve
most webpages. In HTTP, clients continuously poll the
server, which can cause increased latency and inefficiency.
• The WebSocket API provides two mechanisms for creating
and using WebSocket connections: the WebSocket
interface and the WebSocketStream interface.
WebSocket
• When can a web socket be used?
Real-time web application:
Real-time web application uses a web socket to show the data at client end, which is continuously
being sent by the backend server. In WebSocket, data is continuously pushed/transmitted into the
same connection which is already open, that is why WebSocket is faster and improves the
application performance.
e.g. in a trading website or bitcoin trading, for displaying the price fluctuation and movement data
is continuously pushed by the backend server to the client end by using a WebSocket channel.
• Gaming application: In a Gaming application, you might focus on that, data is continuously received by
the server, and without refreshing the UI, it will take effect on the screen, UI gets automatically refreshed
without even establishing the new connection, so it is very helpful in a Gaming application.

• Chat application: Chat applications use WebSockets to establish the connection only once for exchange,
publishing, and broadcasting the message among the subscribers. It reuses the same WebSocket
connection, for sending and receiving the message and for one-to-one message transfer.
WebSocket
• When not to use WebSocket?
• WebSocket can be used if we want any real-time updated or continuous streams of data
that are being transmitted over the network but if we want to fetch old data, or want to get
the data only once to process it with an application we should go with HTTP protocol, old
data which is not required very frequently or fetched only once can be queried by the
simple HTTP request, so in this scenario, it’s better not use WebSocket.
Differences between HTTP and WebSocket Connection
WebSocket Connection HTTP Connection

WebSocket is a bidirectional communication protocol that can send the The HTTP protocol is a unidirectional protocol that works on top
data from the client to the server or from the server to the client by of TCP protocol which is a connection-oriented transport layer
reusing the established connection channel. The connection is kept alive protocol, we can create the connection by using HTTP request
until terminated by either the client or the server. methods after getting the response HTTP connection get closed.

Almost all the real-time applications like (trading, monitoring,


notification) services use WebSocket to receive the data on a single Simple RESTful application uses HTTP protocol which is stateless.
communication channel.

It is used when we do not want to retain a connection for a


All the frequently updated applications used WebSocket because it is particular amount of time or reuse the connection for
faster than HTTP Connection. transmitting data; An HTTP connection is slower than
WebSockets.
• Figure 3.9 (a) shows Opcode and other
fields at a WebSocket Frame.
• Figure 3.9 (b) shows WebSocket API
provisions for events, attributes and
functions. Event means occurrence of
new condition, occurrence of which is
listened by an event-listener function,
and as soon as listening takes place, an
event handling function executes. The
handling function is also callback action.
• Figure 3.9 (c) shows data bidirectional
communication using WebSocket APIs
between the web objects and also the
browsers and servers.
Features of WebSocket
• Small header size (2B extended to 6 byte and above compared to 100s B and
aProtocol is intended to be compatible with HTTP-based server-side software and
intermediariesbove for an HTTP header which results in high latency.
• No new connection which will need a new header and thus no new latency period.
• facilitate live content and the creation of real-time games.
• Protocol is an independent TCP-based protocol. Its only relationship to HTTP is that
its handshake is interpreted by HTTP servers as an upgrade request.
• Protocol uses default port 80 for regular WebSocket connections using ws:// and
port 443 when using wss:// for WebSocket connections tunnelled over Transport
Layer Security (TLS).
• , so that a single port can be used by both HTTP clients talking to that server and
WebSocket clients talking to that server.
• Protocol specifies six frame types and leaves ten reserved for future use.
• Clients and servers exchange the ‘messages’ after a successful handshake.
Each frame belonging to the same message contains the same type of data.
Six types are (i) textual data (UTF-8) and (ii) binary data (whose
interpretation is left up to the application).
• Extensibility of request-response (client-server) architecture to iq
(information through and querying) chat and super chat extensibility to
cloud services.
• Support from intelligent and business analyst applications and processing
through web server or XMPP server and gateway for connecting the device
network with the IP network.
THANK YOU

You might also like