You are on page 1of 9

Web Service

What is Web Service?


Web Service is an application that is designed to interact directly with other applications
over the internet. In simple sense, Web Services are means for interacting with objects
over the Internet.
Web Service is
o Language Independent
o Protocol Independent
o Platform Independent
o It assumes a stateless service architecture.
Example of Web Service

Weather Reporting: You can use Weather Reporting web service to display
weather information in your personal website.
Stock Quote: You can display latest update of Share market with Stock
Quote on your web site.
News Headline: You can display latest news update by using News Headline
Web Service in your website.
Web Service Communication
Web Services communicate by using standard web protocols and data formats, such
as

XML (Extensible Markup Language).


SOAP (Simple Object Access Protocol).
WSDL (Web Services Definition Language).
UDDI (Universal Discovery Description Integration).

Understanding Web Services


Consider, for example, the process of buying a book online When you enter a credit
card number to pay for a book, the Web site must communicate with a credit card
processor to authorize your credit card purchase. The credit card number must be
transmitted over the Web, and the purchase must be authorized or declined. All
these transactions must be accomplished in real-time. There is no standard way of
completing this process. To communicate with each major credit card processor, you
must implement different proprietary software.
XML Web services have the potential to standardize the process of authorizing
credit cards. Imagine a credit card authorization Web service. The Web service

would have an authorization method to accept a credit card number, an expiration


date, and a purchase amount. When the method is invoked, it would return either
approved or declined.
When purchasing a book, you must select a shipping method. To get a list of
shipping options and prices for each option, the Web site must communicate with
one or more shipping services. Again, there is no standard way of completing this
process. The method for communicating with Federal Express is different than the
method for communicating with United Parcel Service.
Now imagine a shipping Web service. You would transmit an origin and destination
address to the service, and it would return a list of shipping options with different
prices.
Before you can purchase a book, you must first log in to the Web site by entering
your username and password. Typically, you must enter new registration
information for each site that you use.
Again, imagine a Web service simplifying this process. In this case, it would be a
user registration Web service. Whenever you visit a Web site, it could communicate
with the user registration Web service to verify your identity. You would pass a
username and password to the Web service, and it would return a value indicating
whether the username and password combination is valid.

What is SOAP?
Since Web Services will run in a heterogeneous environment, the protocols used to
perform the data transfer between functions have to be independent of any runtime
environment. SOAP is a
protocol having these characteristics.
SOAP stands for Simple Object Access Protocol
SOAP is a communication protocol
SOAP is for communication between applications
SOAP is a format for sending messages
SOAP communicates via Internet
SOAP is platform independent
SOAP is language independent
SOAP is based on XML
SOAP is simple and extensible
SOAP allows you to get around firewalls

Why SOAP?

It is important for application development to allow Internet communication


between programs.

A better way to communicate between applications is over HTTP, because


HTTP is supported by all Internet browsers and servers. SOAP was created to
accomplish this.
SOAP provides a way to communicate between applications running on
different operating systems, with different technologies and programming
languages.

SOAP Building Blocks


A SOAP message is an ordinary XML document containing the following elements:
An Envelope element that identifies the XML document as a SOAP message
A Header element that contains header information
A Body element that contains call and response information
A Fault element containing errors and status information
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
...
</soap:Header>
<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
SOAP messages contain the tag ENVELOPE as the root element. The envelope
contains two elements:
An optional header.
A body.
The header may contain a set of so-called header entries that can be used to
provide information such as authentication or the encoding of the data. In addition,2
header attributes exist to provide information about how a recipient of a SOAP
message should process the message:
The actor attribute:
A SOAP message may travel from a sender to a receiver by passing different
endpoints along the message path. However, not all parts of a SOAP message
may be intended for the ultimate endpoint, instead, it may be intended for one
or more of the endpoints on the message path. The SOAP actor attribute is used
to address the Header element to a specific endpoint.
The encodingStyle Attribute
The encodingStyle attribute is used to define the data types used in the
document. This attribute may appear on any SOAP element, and it will apply to
that element's contents and all child elements.A SOAP message has no default
encoding.
The SOAP Body Element
The required SOAP Body element contains the actual SOAP message intended for
the ultimate endpoint of the message.
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">

<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
The SOAP Fault Element
The optional SOAP Fault element is used to indicate error messages. If a Fault
element is present, it must appear as a child element of the Body element. A Fault
element can only appear once in a SOAP message.
SOAP are remote function calls that invokes method and execute them on Remote
machine and translate the object communication into XML format. In short, SOAP
are way by which method calls are translate into XML format and sent via HTTP.

XML
XML provides a language which can be used between different platforms and
programming languages and still express complex messages and functions.
Web services use XML to code and to decode data, and SOAP to transport it (using
open protocols).
What is WSDL?
WSDL stands for Web Services Description Language
WSDL is written in XML
WSDL is an XML document
WSDL is used to describe Web services
WSDL is also used to locate Web services
WSDL is a W3C recommendation
WSDL Describes Web Services
WSDL is a document written in XML. The document describes a Web service. It
specifies the location of the service and the operations (or methods) the service
exposes.
A WSDL document is just a simple XML document.
It contains set of definitions to describe a web service.
The WSDL Document Structure
A WSDL document describes a web service using these major elements:
Element
Defines
<types>

The data types used by the web service

<message> The messages used by the web service


<portType> The operations performed by the web service
<binding>

The communication protocols used by the web


service

The main structure of a WSDL document looks like this:


<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
definition of a port.......
</portType>
<binding>
definition of a binding....
</binding>
</definitions>
WSDL Ports
The <portType> element is the most important WSDL element.
It describes a web service, the operations that can be performed, and the messages
that are involved.
The <portType> element can be compared to a function library (or a module, or a
class) in a traditional programming language.
WSDL Messages
The <message> element defines the data elements of an operation.
Each message can consist of one or more parts. The parts can be compared to the
parameters of a function call in a traditional programming language.
WSDL Types
The <types> element defines the data types that are used by the web service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define data
types.
WSDL Bindings
The <binding> element defines the message format and protocol details for each
port.
Universal Description, Discovery and Integration (UDDI) is a directory service where
businesses can register and search for Web services.
What is UDDI
UDDI is a platform-independent framework for describing services, discovering
businesses, and integrating business services by using the Internet.
UDDI stands for Universal Description, Discovery and Integration
UDDI is a directory for storing information about web services
UDDI is a directory of web service interfaces described by WSDL
UDDI communicates via SOAP

UDDI is built into the Microsoft .NET platform

UDDI Benefits
Any industry or businesses of all sizes can benefit from UDDI.
Before UDDI, there was no Internet standard for businesses to reach their customers
and partners with information about their products and services. Nor was there a
method of how to integrate into each other's systems and processes.

How can UDDI be Used


If the industry published an UDDI standard for flight rate checking and reservation,
airlines could register their services into an UDDI directory. Travel agencies could
then search the UDDI directory to find the airline's reservation interface. When the
interface is found, the travel agency can communicate with the service immediately
because it uses a well-defined reservation interface.

Advantages of Web Service Communication


XML Web services facilitate communication among different Web sites and different
applications. Because Web services are built on open standardssuch as HTTP,
XML, and SOAPthey enable communication in a platform-independent way.
Web Service messages are formatted as XML, a standard way for
communication between two incompatible system. And this message is sent
via HTTP, so that they can reach to any machine on the internet without
being blocked by firewall.
Because Web services are based on open standards, an ASP.NET Web site can
use Web services to communicate with a Web site created on a different
platform, such as Java.
One can use them as a common language to bridge the different platforms in
an organization.
Web services not only enable Web sitetoWeb site communication, they also
enable applicationtoWeb site and application-to-application communication.
For example, you can write a desktop application that communicates with a
banking Web service to retrieve your current checking account balance. Or
you can use Web services to enable a desktop application running on a
computer in Australia to communicate with a desktop application running on
a computer in Mexico.

XML Web Services Enable Aggregation


Another important benefit of XML Web services is that they enable you to
aggregate content from multiple Web sites and even multiple Web services.

Creating a web service

You might also like