API-MS Unit 4
API-MS Unit 4
The Internet is the worldwide connectivity of hundreds of thousands of computers of various types
that belong to multiple networks. On the World Wide Web, a web service is a standardized method
for propagating messages between client and server applications. A web service is a software module
that is intended to carry out a specific set of functions. Web services in cloud computing can be
found and invoked over the network.
The web service would be able to deliver functionality to the client that invoked the web service.
A web service is a set of open protocols and standards that allow data to be exchanged between
different applications or systems. Web services can be used by software programs written in a variety
of programming languages and running on a variety of platforms to exchange data via computer
networks such as the Internet in a similar way to inter-process communication on a single computer.
Any software, application, or cloud technology that uses standardized web protocols (HTTP or HTTPS)
to connect, interoperate, and exchange data messages – commonly XML (Extensible Markup
Language) – across the internet is considered a web service.
Web services have the advantage of allowing programs developed in different languages to connect
with one another by exchanging data over a web service between clients and servers. A client
invokes a web service by submitting an XML request, which the service responds with an XML
response.
XML and HTTP is the most fundamental web services platform. The following components are used
by all typical web services:
SOAP stands for “Simple Object Access Protocol.” It is a transport-independent messaging protocol.
SOAP is built on sending XML data in the form of SOAP Messages. A document known as an XML
document is attached to each message. Only the structure of the XML document, not the content,
follows a pattern. The best thing about Web services and SOAP is that everything is sent through
HTTP, the standard web protocol.
A root element known as the element is required in every SOAP document. In an XML document, the
root element is the first element. The “envelope” is separated into two halves. The header comes
first, followed by the body. The routing data, or information that directs the XML document to which
client it should be sent to, is contained in the header. The real message will be in the body.
UDDI is a standard for specifying, publishing and discovering a service provider’s online services. It
provides a specification that aids in the hosting of data via web services. UDDI provides a repository
where WSDL files can be hosted so that a client application can discover a WSDL file to learn about
the various actions that a web service offers. As a result, the client application will have full access to
the UDDI, which serves as a database for all WSDL files.
The UDDI registry will hold the required information for the online service, just like a telephone
directory has the name, address, and phone number of a certain individual. So that a client
application may figure out where it is.
If a web service can’t be found, it can’t be used. The client invoking the web service should be aware
of the location of the web service. Second, the client application must understand what the web
service does in order to invoke the correct web service. The WSDL, or Web services description
language, is used to accomplish this. The WSDL file is another XML-based file that explains what the
web service does to the client application. The client application will be able to understand where
the web service is located and how to use it by using the WSDL document.
The diagram depicts a very simplified version of how a web service would function. The client would
use requests to send a sequence of web service calls to a server that would host the actual web
service.
Remote procedure calls are what are used to make these requests. Calls to methods hosted by the
relevant web service are known as Remote Procedure Calls (RPC). Example: Flipkart offers a web
service that displays prices for items offered on Flipkart.com. The front end or presentation layer can
be written in .Net or Java, but the web service can be communicated using either programming
language.
The data that is exchanged between the client and the server, which is XML, is the most important
part of a web service design. XML (Extensible markup language) is a simple intermediate language
that is understood by various programming languages. It is a counterpart to HTML. As a result, when
programs communicate with one another, they do so using XML. This creates a common platform for
applications written in different programming languages to communicate with one another.
For transmitting XML data between applications, web services employ SOAP (Simple Object Access
Protocol). The data is sent using standard HTTP. A SOAP message is data that is sent from the web
service to the application. An XML document is all that is contained in a SOAP message. The client
application that calls the web service can be created in any programming language because the
content is written in XML.
(a) XML Based: The information representation and record transportation layers of a web service
employ XML. There is no need for networking, operating system, or platform binding when using
XML. At the middle level, web offering-based applications are highly interoperable.
(b) Loosely Coupled: A customer of an internet service provider isn’t necessarily directly linked to
that service provider. The user interface for a web service provider can change over time without
impacting the user’s ability to interact with the service provider. A strongly coupled system means
that the patron’s and server’s decisions are inextricably linked, indicating that if one interface
changes, the other should be updated as well.
A loosely connected architecture makes software systems more manageable and allows for easier
integration between different structures.
(d) Coarse-Grained: Object-oriented systems, such as Java, make their services available through
individual methods. At the corporate level, a character technique is far too fine an operation to be
useful. Building a Java application from the ground, necessitates the development of several fine-
grained strategies, which are then combined into a rough-grained provider that is consumed by
either a buyer or a service.
Corporations should be coarse-grained, as should the interfaces they expose. Web services
generation is an easy approach to define coarse-grained services that have access to enough
commercial enterprise logic.
(e) Supports Remote Procedural Call: Consumers can use an XML-based protocol to call procedures,
functions, and methods on remote objects utilizing web services. A web service must support the
input and output framework exposed by remote systems.
Enterprise-wide component development Over the last few years, JavaBeans (EJBs) and.NET
Components have become more prevalent in architectural and enterprise deployments. A number of
RPC techniques are used to allocate and access both technologies.
A web function can support RPC by offering its own services, similar to those of a traditional role, or
by translating incoming invocations into an EJB or.NET component invocation.
(f) Supports Document Exchanges: One of XML’s most appealing features is its simple approach to
communicating with data and complex entities. These records can be as simple as talking to a current
address or as complex as talking to an entire book or a Request for Quotation. Web administrations
facilitate the simple exchange of archives, which aids incorporate reconciliation.
The web benefit design can be seen in two ways: (i) The first step is to examine each web benefit on-
screen character in detail. (ii) The second is to take a look at the rapidly growing web benefit
convention stack.
(a) Business Functions can be exposed over the Internet: A web service is a controlled code
component that delivers functionality to client applications or end-users. This capability can be
accessed over the HTTP protocol, which means it can be accessed from anywhere on the internet.
Because all apps are now accessible via the internet, Web services have become increasingly
valuable. Because all apps are now accessible via the internet, Web services have become
increasingly valuable. That is to say, the web service can be located anywhere on the internet and
provide the required functionality.
(b) Interoperability: Web administrations allow diverse apps to communicate with one another and
exchange information and services. Different apps can also make use of web services. A .NET
application, for example, can communicate with Java web administrations and vice versa. To make
the application stage and innovation self-contained, web administrations are used.
(c) Communication with Low Cost: Because web services employ the SOAP over HTTP protocol, you
can use your existing low-cost internet connection to implement them. Web services can be
developed using additional dependable transport protocols, such as FTP, in addition to SOAP over
HTTP.
(d) A Standard Protocol that Everyone Understands: Web services communicate via a defined
industry protocol. In the web services protocol stack, all four layers (Service Transport, XML
Messaging, Service Description, and Service Discovery) use well-defined protocols.
(e) Reusability: A single web service can be used simultaneously by several client applications.
Message Format
SOAP message transmits some basic information as given below
Information about message structure and instructions on processing it.
Encoding instructions for application-defined data types.
Information about Remote Procedure Calls and their responses.
The message in XML format contains four parts-
Envelope: This specifies that the XML message is a SOAP message. A
SOAP message is an XML document containing a header and a body,
both encapsulated within the envelope. Any fault is included within the
body of the message.
Header: This part is optional. When present, it can provide crucial
information about the applications.
Body: This contains the actual message being transmitted. Faults are
contained within the body tags.
Fault: This optional section contains the status of the application and
any errors. It should not appear more than once in a SOAP message.
Sample Message
xml
Content-Type: application/soap+xml
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-
envelope">
<env:Header>
<m:GetLastTradePrice xmlns:m="Some-URI" />
</env:Header>
<env:Body>
<symbol xmlns:p="Some-URI" >DIS</symbol>
</env:Body>
</env:Envelope>
Advantages of SOAP
SOAP is a light weight data interchange protocol because it is based on
XML.
SOAP was designed to be OS and Platform independent.
It is built on top of HTTP which is installed in most systems.
It is suggested by W3 consortium which is like a governing body for the
Web.
SOAP is mainly used for Web Services and Application Programming
Interfaces (APIs).
// POST /resource
// Creates a new resource with the state specified in the request body
app.post('/resource', function(req, res) {
var resource = req.body;
var id = createResource(resource);
res.json({ id: id });
});
// PUT /resource/123
// Updates the state of the resource with ID 123 with the state specified in the requ
app.put('/resource/:id', function(req, res) {
var id = req.params.id;
var resource = req.body;
updateResource(id, resource);
res.sendStatus(200);
});
// DELETE /resource/123
// Deletes the resource with ID 123
app.delete('/resource/:id', function(req, res) {
var id = req.params.id;
deleteResource(id);
res.sendStatus(200);
});
In this example, the service uses the GET, POST, PUT, and DELETE HTTP
methods to implement the CRUD operations on a resource. The service
uses the app.get(), app.post(), app.put(), and app.delete() methods to
register the appropriate handler functions for each operation. The req
and res objects represent the request and response, respectively, and
are used to access information about the request and send a response
to the client.
// PUT /resource/123
// Updates the state of the resource with ID 123 with the state
specified in the request body
app.put('/resource/:id', function(req, res) {
var id = req.params.id;
var resource = req.body;
updateResource(id, resource);
res.sendStatus(200);
});
// DELETE /resource/123
// Deletes the resource with ID 123
app.delete('/resource/:id', function(req, res) {
var id = req.params.id;
deleteResource(id);
res.sendStatus(200);
});