MAD
CHAPTER - 3
Web Services for Mobile Devices
WEB SERVICES
A web service is a service offered by an electronic
device to another electronic device, communicating with
each other over the internet.
It is also define as follows:
> It is a client server application or application
component for communication.
> It is a software system for interoperable machine to
machine communication.
> It is a collection of standards or protocols for
exchanging information between two devices or
application.
WEB SERVICE COMPONENTS
The basic web services platform is XML + HTTP. All
the standard web services work using the following
components.
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
WSDL:
WSDL is a xml document containing information about
web services such as method name, method parameter
and how to access it.
CONT…
WSDL is a part of UDDI. It acts as a interface between
web service applications
UDDI:
UDDI is a XML based framework for describing,
discovering and integrating web services.
UDDI is a directory of web service interfaces described
by WSDL, containing information about web services.
WEB SERVICE ARCHITECTURE
Architecture which consists of three distinct roles.
Provider
Requester
Broker
CONT…
Provider - The provider creates the web service and
makes it available to client application who want to use
it.
Requestor - A requestor is nothing but the client
application that needs to contact a web service. The
client application can be a .Net, Java, or any other
language based application which looks for some sort of
functionality via a web service.
Broker - The broker is nothing but the application which
provides access to the UDDI. The UDDI, as discussed in
the earlier topic enables the client application to locate
the web service.
TYPES OF WEB SERVICES
There are mainly two types of web services
> SOAP Web Services
> RESTful Web Services
SOAP stands for Simple Object Access Protocol.
It is a XML-based protocol for accessing web services.
SOAP is a W3C recommendation for communication
between two applications.
CONT…
It is platform independent and language independent.
By using SOAP, you will be able to interact with other
programming language applications.
Advantages:
WS Security: SOAP defines its own security known as
WS Security.
Language and Platform independent: SOAP web
services can be written in any programming language
and executed in any platform.
CONT…
Disadvantages:
Slow: SOAP uses XML format that must be parsed to be
read. It defines many standards that must be followed
while developing the SOAP applications. So it is slow
and consumes more bandwidth and resource.
WSDL dependent: SOAP uses WSDL and doesn't have
any other mechanism to discover the service.
CONT…
REST stands for Representational State
Transfer. REST is an architectural style not a protocol.
Advantages:
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.
CONT…
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 VS REST
ADVANTAGES
Exposing Business Functionality on the network
A web service is a unit of managed code that provides some
sort of functionality to client applications or end users
This functionality can be invoked over the HTTP protocol
which means that it can also be invoked over the internet.
Web service can be anywhere on the internet and provide the
necessary functionality as required.
Interoperability amongst applications
web services allow various applications to talk to each other
and share data and services among themselves.
CONT…
All types of applications can talk to each other.
A Standardized Protocol which everybody
understands
Web services use standardized industry protocol for the
communication.
All the four layers (Service Transport, XML Messaging,
Service Description, and Service Discovery layers) uses well-
defined protocols in the web services protocol stack.
Reduction in cost of communication
Web services use SOAP over HTTP protocol, so you can use
your existing low-cost internet for implementing web
services.
WEB SERVICES LANGUAGES
Languages are used for communication.
Programming languages are difficult to understand.
Web services have been successful because of their self-
describing nature.
Format choice impacts the ease of accessing the web
service and performance of the application.
When designing a web service, we have to consider how
the service will be accessed.
XML and JSON are the two formats used in web
services.
XML
It is eXtensible Markup Language.
XML is extensible: XML allows you to create your own
self-descriptive tags, or language, that suits your
application.
XML was developed by an organization called the World
Wide Web Consortium (W3C) and is available as an open
standard.
It is used to describe the documents.
If person is an object then it can be described as
CONT…
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML enables you to define the language systems used to
communicate by creating an XML Schema Document (XSD)
CONT…
XSTL:
It is eXtensible Stylesheet Language Transforms.
It is advanced than CSS.
With XSLT you can add/remove elements and attributes
to or from the output file.
XSLT is used to transform a document into another
representation.
XSLT transformation can applied to one application’s
XML output to be used by another application.
CONT…
CONT…
CONT…
CONT…
Xquery
XQuery is used to retrieve a subset of data from a full
XML document, like a SQL query is used to retrieve a
subset of data from a database.
<order>
<item price=”50” currency=”USD” name=”metal gear” />
<item price=”25” currency=”USD” name=”plastic gear” />
</order>
The following XQuery returns the sum:
sum(doc(‘orders.xml’)/order/item/@price)
JSON
Java Script Object Notation, was created in 2001, and
came into use in 2005.
It has few rules, few base types, and is human readable.
JSON schema enables document validation, but this is
rarely used.
JSON is a great format for transmitting data between
systems because it is simple, text based, and self-
describing.
A person can be represented in JSON like this:
{
firstName : “David”,
lastName : “Smith”
}
CONT…
There is no base type of date and there is no standard
way to represent dates.
It is recommended to represent dates using the
International Standards Organization 8601 format.
In ISO-8601 dates look like this:
1997-07-16T19:20:30.45+01:00.
Representing dates in ISO-8601 keeps them human
readable, ensures programming languages can parse
them, and keeps time zone information.
CONT…
Transferring Nontextual Data
Both JSON and XML create human-readable text
documents.
If web service needs nontextual data then different
transmission techniques are required.
When transmitting nontextual data as text, it needs to be
Base64 encoded.
Base64 has two drawbacks.
Textsize increases by 33% when it is represented.
Additional processing is required by both sender and receiver.