You are on page 1of 29

01 Web Service Architecture

• What are “Web Services”?


• Web Service Model
• Components of Web Services
• SOAP
• UDDI
• WSDL
• Operations and Message Flow
• Example – A simple Web Service
What are “Web Services”?
A Web service is a software system identified by a URI,
whose public interfaces and bindings are described using
XML (eXtensible Markup Language ).

Its definition can be discovered by other software systems.

These systems may then interact with the Web service in


a manner prescribed by its definition, using XML based
messages conveyed by internet protocols.

2
14
Web Service Model

The Web Services architecture is based upon the


interactions between three roles:

Service
Provider

Service
registry

Service
requestor

3
14
Web Service Model

The interactions involve:

Publish operations

Find operation

Bind operations

4
14
Web Service Model

The Web Services model follows the publish, find,


and bind paradigm.

5
14
Components of Web Services

The basic web services platform is XML + HTTP.

All the standard web services work using the following


components:

SOAP (Simple Object Access Protocol)

(Universal Description, Discovery and


UDDI
Integration)

WSDL (Web Services Description Language)

6
14
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.

7
14
SOAP

SOAP is a simple markup language for describing messages


between applications.

It uses mainly HTTP as a transport protocol.

HTTP message contains a SOAP message as its payload


section.

8
14
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.

9
14
WSDL

WSDL stands for Web Services Description Language.

It is an XML vocabulary for describing Web services.

It allows developers to describe Web Services and


their capabilities, in a standard manner.

10
14
WSDL

WSDL specifies what a request message must


contain and what the response message will look like
in unambiguous notation.

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.
11
14
Operations and Message Flow

12
14
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).

13
14
Example – A simple Web Service

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.

14
14
02 Web Programming: CGI
• Common Gateway Interface(CGI)
• CGI Applications
• Setting Up a Web Server
• The cgi Module
• Creating the Form Page
• Generating the Results Page
• HTTP Header
Common Gateway Interface(CGI)

The entire process begins when the Web server receives


a client request (i.e., GET or POST) and calls the
appropriate application.

It then waits for the resulting HTML—meanwhile, the


client also waits.

Once the application has completed, it passes the


dynamically generated HTML back to the server, which
then (finally) forwards it back to the user.

2
14
Common Gateway Interface(CGI)

This process of the server receiving a form, contacting an


external application, and receiving and returning the
HTML takes place through the CGI.

3
14
Common Gateway Interface(CGI)

Forms input on the client and sent to a Web server can


include processing and perhaps some form of storage in
a back-end database.

CGI applications that create the HTML are usually written


in one of many higher-level programming languages that
have the ability to accept user data, process it, and then
return HTML back to the server.

4
14
CGI Applications

A CGI application is slightly different from a typical


program.

The primary differences are in the input, output, and user


interaction aspects of a computer program.

When a CGI script starts, it needs to retrieve the user-


supplied form data, but it has to obtain this data from the
Web client, not a user on the server computer or a disk file.

This is usually known as the request.


5
14
CGI Applications

The output differs in that any data sent to standard output


will be sent back to the connected Web client rather than
to the screen, GUI window, or disk file.

This is known as the response.

The data sent back must be a set of valid headers


followed by HTML-tagged data.

6
14
Setting Up a Web Server

python -m http.server --cgi 8000 (python3)

python -m CGIHTTPServer 8000 (python2)

7
14
The cgi Module

There is one primary class in the cgi module that


does all the work: the FieldStorage class.

This class reads in all the pertinent user information


from the Web client (via the Web server);

It should be instantiated when a Python CGI script


begins.

8
14
Creating the Form Page
<form action="/cgi-bin/hello.py"
method="get">
First Name: <input type="text"
name="first_name"> <br />
Last Name: <input type="text"
name="last_name" /> <br />
<input type="submit" value="Submit" />
</form>

9
14
Generating the Results Page

# Import modules for CGI handling

import cgi, cgitb

# Create instance of FieldStorage

form = cgi.FieldStorage()

# Get data from fields

first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
10
14
Generating the Results Page

print ("Content-type:text/html\r\n\r\n")
print ("<html>")
print ("<head>")
print ("<title>Hello - Second CGI Program</title>")
print ("</head>")
print ("<body>")
print ("<h2>Hello %s %s</h2>" % (first_name,
last_name))
print ("</body>")
print ("</html>")

11
14
HTTP Header

The line Content-type:text/html\r\n\r\n is part of HTTP


header which is sent to the browser to understand the
content.

There are few other important HTTP headers in CGI


Programming.

12
14
HTTP Header

Header Description

 A MIME string defining the format of the


Content-type: file being returned.
eg: Content-type:text/html
 The date the information becomes
invalid.
 It is used by the browser to decide when
Expires: Date
a page needs to be refreshed.
 A valid date string is in the format 01
Jan 1998 12:00:00 GMT.
 The URL that is returned instead of the
URL requested.
Location: URL
 This field can be used to redirect a
request to any file.
13
14
HTTP Header

Header Description

Last-modified:  The date of last modification of the


Date resource.
 The length, in bytes, of the data being
Content-length: returned.
N  The browser uses this value to report the
estimated download time for a file.

Set-Cookie:
 Set the cookie passed through the string
String

14
14
03 Building CGI Applications

You might also like