0% found this document useful (0 votes)
39 views

Introduction To Web Services

Web services evolved from previous distributed computing technologies like RPC, CORBA, and RMI to address issues of interoperability, firewall traversal, and complexity. Web services use XML, SOAP, WSDL, and UDDI to allow applications to communicate over the internet. SOAP defines a standard message format to invoke web service operations over various protocols like HTTP. Web services can be either document-oriented, sending business documents, or RPC-oriented, sending data as procedure arguments.

Uploaded by

Abhinav Sagar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Introduction To Web Services

Web services evolved from previous distributed computing technologies like RPC, CORBA, and RMI to address issues of interoperability, firewall traversal, and complexity. Web services use XML, SOAP, WSDL, and UDDI to allow applications to communicate over the internet. SOAP defines a standard message format to invoke web service operations over various protocols like HTTP. Web services can be either document-oriented, sending business documents, or RPC-oriented, sending data as procedure arguments.

Uploaded by

Abhinav Sagar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 70

Introduction to Web

Services
.
Agenda
 Motivation
 History
 Web service model
 Web service components
 A walkthrough examples
Web Service definition
A simple definition:

“a Web Service is an application component


accessible over open protocols”.
History
 Web services evolved from previous
technologies that served the same purpose
such as RPC, ORPC (DCOM, CORBA and
JAVA RMI).
 Web Services were intended to solve three
main problems:
1. Interoperability
2. Firewall traversal
3. Complexity
Interoperability
 Earlier distributed systems suffered from
interoperability issues because each vendor
implemented its own on-wire format for
distributed object messaging.
 Development of DCOM apps strictly bound to
Windows Operating system.
 Development of RMI bound to Java
programming language.
Firewall traversal
 Collaboration across corporations was an issue
because distributed systems such as CORBA
and DCOM used non-standard ports.
 Web Services use HTTP as a transport
protocol and most of the firewalls allow access
though port 80 (HTTP), leading to easier and
dynamic collaboration.
Complexity
 Web Services is a developer-friendly service
system.
 Most of the above-mentioned technologies
such as RMI, COM, and CORBA involve a
whole learning curve.
 New technologies and languages have to be
learnt to implement these services.
Web Service definition revisited
 A more precise definition:
 an application component that:
 Communicates via open protocols (HTTP, SMTP, etc.)
 Processes XML messages framed using SOAP
 Describes its messages using XML Schema
 Provides an endpoint description using WSDL
 Can be discovered using UDDI
Web Services Components
 XML – eXtensible Markup Language – A uniform
data representation and exchange mechanism.
 SOAP – Simple Object Access Protocol – A standard
way for communication.
 UDDI – Universal Description, Discovery and
Integration specification – A mechanism to register
and locate WS based application.
 WSDL – Web Services Description Language – A
standard meta language to described the services
offered.
The Web Service Model
 The Web Services architecture is based upon
the interactions between three roles:
 Service provider
 Service registry
 Service requestor
 The interactions involve the:
 Publish operations
 Find operation
 Bind operations.
The Web Service Model (cont)
The Web Services model follows the publish,
find, and bind paradigm.

Web Service
Registry

1. publish 2. find

Web Service
3. bind/invoke Web Service
Provider Client
Example – A simple Web Service
 A buyer (which might be a simple client) is ordering goods
from a seller service.
 The buyer finds the seller service by searching the UDDI
directory.
 The seller service is a Web Service whose interface is defined
using Web Services Description Language (WSDL).
 The buyer is invoking the order method on the seller service
using Simple Object Access Protocol (SOAP) and the WSDL
definition for the seller service.
 The buyer knows what to expect in the SOAP reply message
because this is defined in the WSDL definition for the seller
service.
XML
 XML stands for EXtensible Markup
Language.
 XML is a markup language much like
HTML.
 XML was designed to describe data.
 XML tags are not predefined. You must define
your own tags.
 The prefect choice for enabling cross-platform
data communication in Web Services.
XML vs HTML
An HTML example:
<html>
<body>
<h2>John Doe</h2>
<p>2 Backroads Lane<br>
New York<br>
045935435<br>
[email protected]<br>
</p>
</body>
</html>
XML vs HTML
 This will be displayed as:
John Doe

2 Backroads Lane
New York
045935435
[email protected]
 HTML specifies how the document is to be displayed,
and not what information is contained in the document.
 Hard for machine to extract the embedded information.
Relatively easy for human.
XML vs HTML
 Now look at the following:
<?xml version=1.0?>
<contact>
<name>John Doe</name>
<address>2 Backroads Lane</address>
<country>New York</country>
<phone>045935435</phone>
<email>[email protected]</email>
</contact>
 In this case:
 The information contained is being marked, but not for
displaying.
 Readable by both human and machines.
SOAP
 SOAP originally stood for "Simple Object Access
Protocol" .
 Web Services expose useful functionality to Web
users through a standard Web protocol called SOAP.
 Soap is an XML vocabulary standard to enable
programs on separate computers to interact across
any network. SOAP is a simple markup language for
describing messages between applications.
 Soap uses mainly HTTP as a transport protocol. That
is, HTTP message contains a SOAP message as its
payload section.
SOAP Characteristics
 SOAP has three major characteristics:
 Extensibility – security and WS-routing are
among the extensions under development.
 Neutrality - SOAP can be used over any transport
protocol such as HTTP, SMTP.
 Independent - SOAP allows for any programming
model .
SOAP Building Blocks
A SOAP message is an ordinary XML document
containing the following elements:
 A required Envelope element that identifies the XML
document as a SOAP message.
 An optional Header element that contains header
information.
 A required Body element that contains call and response
information.
 An optional Fault element that provides information about
errors that occurred while processing the message.
SOAP Request
POST /Stock HTTP/1.1
Host: www.stock.org
Content-Type: application/soap+xml; charset=utf-8 Content-Length: 150

<?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:Body xmlns:m="http://www.stock.org/stock">  
  <m:GetStockPrice>
<m:StockName>IBM</m:StockName>    
 </m:GetStockPrice>
</soap:Body>
</soap:Envelope>
SOAP Response
HTTP/1.1 200 OK
Content-Type: application/soap; charset=utf-8
Content-Length: 126

<?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:Body xmlns:m="http://www.stock.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
SOAP Security
 SOAP uses HTTP as a transport protocol and
hence can use HTTP security mainly HTTP
over SSL.
 But, since SOAP can run over a number of
application protocols (such as SMTP) security
had to be considered.
 The WS-Security specification defines a
complete encryption system.
Major Types of Web Services
Document-oriented 

Sends data formatted as a business document such as 

a purchase order
Typically initiates a process flow 

Remote Procedure Call (RPC)-oriented 

Sends data formatted as arguments to a procedure or object 

invocation
. 

Returns a result directly 


Document-oriented Web Service
Bulk Web Service Interface
Purchase
Database
Order

Receive
Email
acknowledgment
Check

Ship

Invoice
Send

Business Process Flow


RPC-oriented Web Service
Web Service Interface

Online
order
request
Application
programs
Database
or stored
procedures
Online
order
response
RPC Vs Document
.An RPC (remote procedure call) is essentially a call to a remote method 
Web services are XML-based, but you can still interact with the back-end service in an 
RPC-like fashion. Typically, the interaction is a very simple request/response, where
the client sends a SOAP message that contains a call to a method. The application
server receiving this request can then translate this request into the back-end object
(e.g., a Java object, EJB method, or C# method). There is very little that developers
have to do to build an RPC-based Web service because everything is mapped for
them. Note that even in this approach XML is used to contain the call.
With document style, XML "business documents" are transmitted across the wire.
They do not map directly to back-end method calls; they are actually complete, self-
contained business documents. When the service receives the XML document, it
might do some pre-processing on the document, perform some work, and construct
the response back. There is usually no direct mapping to a back-end object. In fact, a
request might invoke multiple components on the back end. The developer has to do
much of the work in processing and mapping the XML data received, and there are
very few tools on the market that can do this automatically. The document style is
typically used in conjunction with asynchronous protocols to provide reliable, loosely
.coupled architectures
RPC vs Document
Good analogy for illustrating RPC vs. document style is the difference between making a phone call and sending 
an email message. When making a phone call with no voicemail available, you are expecting some one on the
other end to pick up and begin talking to you. This is very much a request-response paradigm and maps well to
RPC-style messaging. On the other hand, sending an email doesn't require the sender to be there. The email, or
business document, which has all the information it needs, can wait in a queue or mail server until the receiver
wants to read it. This is analogous to the document style interaction.
The general recommendation is to use document style messaging in your architectures. While an RPC approach
can be implemented rather quickly, it will not be sufficient down the road when you have to interact with
suppliers, customers, and partners who are beyond your control. In these situations, you will want an architecture
that shields you (and the clients) as much as possible from the back-end implementation. Figure 3 shows the
architectural differences between RPC and document style messaging.
Figure 3: Document vs. RPC. Unlike document style messaging, RPC messaging requires an immediate response
:from the recipient.Document style messaging delivers a number of benefits

With document style, you can utilize the full capabilities of XML to describe and validate a business document. 
.With the RPC approach, the XML typically just describes the methods and parameters of the method call
It does not require a tight contract between the client and the service provider. RPC is typically static, requiring 
.changes to the client when the method signature changes. With document style, the rules can be less rigid
Because it is self-contained, document style is typically better suited for asynchronous processing 
WSDL
 WSDL stands for Web Services Description Language.
 WSDL is an XML vocabulary for describing Web services. It
allows developers to describe Web Services and their
capabilities, in a standard manner.
 WSDL specifies what a request message must contain and
what the response message will look like in unambiguous
notation. In other words, it is a contract between the XML
Web service and the client who wishes to use this service.
 In addition to describing message contents, WSDL defines
where the service is available and what communications
protocol is used to talk to the service.
The WSDL Document Structure
 A WSDL document is just a simple XML
document.
 It defines a web service using these major
elements:
 port type - The operations performed by the web
service.
 message - The messages used by the web service.
 types - The data types used by the web service.
 binding - The communication protocols used by
the web service.
WSDL Document
<message name="GetStockPriceRequest">
<part name="stock" type="xs:string"/>
</message>
<message name="GetStockPriceResponse">
<part name="value" type="xs:string"/>
</message>

<portType name=“StocksRates">
<operation name=“GetStockPrice">
<input message=“GetStockPriceRequest"/>
<output message=“GetStockPriceResponse"/>
</operation>
</portType>
UDDI
 UDDI stands for Universal Description,
Discovery and Integration.
 UDDI is a directory for storing information
about web services , like yellow pages.
 UDDI is a directory of web service interfaces
described by WSDL.
UDDI Details
SOAP is used to talk to UDDI registries 

White pages 

Business information (name, contact info) 

Yellow pages 

Categorization (industry, products, location) 

Green pages 

Technical specifications (service description) 


Resources
 http://msdn.microsoft.com/webservices/
understanding/webservicebasics/default.aspx
 http://www.w3schools.com/
 http://uddi.microsoft.com/Default.aspx
 http://www.developer.com/services/article.php
/2195981
 Many more on the web…
An Alternative Approach:
ebXML
A group of specifications focused on B2B 

interactions

Created by OASIS and UN/CEFACT 

A competitor to the SOAP school of web 

?services
Illustrating a B2B Interaction
1) Place order

Business X Business Y
2) Acknowledge order

3) Indicate shipment

4) Acknowledge receipt

5) Send invoice

6) Send payment
What’s Needed to Achieve This
Agreement on the interactions 

?What is the business process 

Agreement on the data 

?What are the document formats 

Agreement on the protocols 

?How is the information conveyed 


1
Reque
st ebX
Usage
Usage Example
Example
Send e ML sp
bXML ecifica
3 Bu
ild Sys specifi tion
te m cation 2
4
Regist
er com
pany p
rofile
11

8 TPA Accepted
DO
BUSINESS! a n yX e 6
7 Submit TPA
C om
p
P r ofil ario Specifications
b o ut X ’s
S c en 10
a y s
u ery ompan ny X’ enario Profiles
5 Q d C p a s Sc
m ’
Sen st Co ny X
eq ue m pa Scenarios
9 R nd C o
Se

ebXML BO Library

ebXML BP Model
Examples
 Using a Web Service
 Creating a new Web Service
Suppose that the owner of a chain of coffee houses, called The Coffee Break, wants to expand
the line of coffees that he sells. He instructs his business manager to find some new coffee
suppliers, get their wholesale prices, and then arrange for orders to be placed as the need arises.
The Coffee Break can analyze the prices and decide which new coffees it wants to carry and
which companies it wants to buy them from. The business manager assigns the task to the
company's software engineer, who decides that the best way to locate new coffee suppliers is to
search a Universal Description, Discovery, and Integration (UDDI) registry, where The Coffee
.Break has already registered itself
The engineer uses JAXR to send a query searching for wholesale coffee suppliers. JAXR sends
messages using JAXM in the background, which ensures that the registry will be able to receive
.and understand it
The UDDI registry will receive the query and apply the search criteria transmitted in the JAXR
code to the information it has about the organizations registered with it. When the search is
completed, the registry will send back information on how to contact the wholesale coffee
.distributors that met the specified criteria
The engineer's next step is to draft a request for price lists and send it to each of the coffee
distributors using JAXM. She writes an application that gets a connection to the company's
messaging service so that she can send the requests. She then creates a JAXM message, adds the
.request, and sends it
Each coffee distributor receives the request, and before sending out current prices, checks with
its stock quote service using JAX-RPC to get the latest quotes for the relevant coffee futures.
Based on the figures they get back, the distributors send The Coffee Break their newly revised
prices in an XML price sheet. The vendors use an agreed upon XML schema for their price
sheets because that way they can use a format that is convenient for them and that their buyers
.can process easily
Step by Step – using a web service
1. Inside Visual Studio .NET Choose File >
New > Project.
2. Choose Visual C# Projects (or Visual Basic
Projects if you prefer this language).

3. Choose
ASP.NET
Web
Application
as your
template
Step by Step – using a web service
 Inside the Location text box enter the name
of your project after the prefix :
http://localhost/YourProjectName
 Press OK.
 This makes The Internet Information
Services installed on your computer create a
new directory on the default path:
C:\Inetpub\wwwroot\FirstExample
Step by Step – using a web service
 You can open IIS by typing compmgmt.msc \s
in the run command and then choosing
Services And Application > Internet
Information Services.
 Inside this node you can choose Web Sites
node and then Default Web Site to see all the
web sites on your computer.
Step by Step – using a web service
Step by Step – using a web service
 In the new project you opened in
VS.NET Move to the Solution
Explorer.
 Right Click on the References
folder and Choose Add Web
References.
 This Opens the Add Web
Reference Dialog Box.
Step by Step – using a web service
 Type the Web Service URL and Press Go.
 It takes a couple of seconds to find the Web
services and finally all it’s methods appear in
the list box.
 The Web Reference name is shown in the
Dialog Box.
 Press Add Reference to complete the process.
Step by Step – using a web service
Step by Step – using a web service
 Add a new Web Form.
Step by Step – using a web service
 Add the following Controls to the Web Form
Step by Step – using a web service
 Double Click on the button and insert this code to it’s
OnClick event handler.
Step by Step – using a web service
1. Set the Web Form as the Start Page.
2. Build and Run the Program.
3. Try to use the Web Application.
Step By Step – Creating a Web Service
 In this Step I will create a new Web Service
and write a Simple Program that uses it.
 The program will perform various operations
on an array.
 The client program will be a simple dialog
box that activates those opeartions.
Step By Step – Creating a Web Service
 Create a new Visual C# project with the name
RemoteArray. The following screen appears.
Step By Step – Creating a Web Service
 To see the code Press on the following hyperlink.
Step By Step – Creating a Web Service

 Right Click on the References folder and


choose add Reference.
 Insert the System.Windows.Forms.dll option
in to this folder.
Step By Step – Creating a Web Service
Step By Step – Creating a Web Service
Step By Step – Creating a Web Service
 Insert the following code to the .asmx file you’ve
created.
Step By Step – Creating a Web Service
Step By Step – Creating a Web Service
Step By Step – Creating a Web Service
 Press Ctrl +F5 to Run the Web service.
Step By Step – Using Remote Array
 Add a new project to RemoteArray Solution
Step By Step – Using Remote Array

 Choose Windows Application from the


templates.
 Add a web reference for the Remote Array
Web Service.
 Remember that it’s inside an asmx file.
Step By Step – Using Remote Array
Step By Step – Using Remote Array
 Add the following elements to the Form
Step By Step – Using Remote Array
 Create a private RemoteArray object and a private int
array object to the Form.
 Insert this code after the Initialize component part.
Step By Step – Using Remote Array
 Insert the following code to controls handler
Step By Step – Using Remote Array
 Set the Windows Application project as the Startup
Step By Step – Using Remote Array

 Compile and run the application.


 This is an example that an XML Web
application can be used over Windows and not
only with ASP.NET
Introduction to Web Services

The End

You might also like