Open - Jorum

clappingknaveΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

93 εμφανίσεις

Distributed Web Systems
Web Services
Lecturer
Department
University
Outline

Web services and the Semantic Web

XML and Web services protocols

Implementing web services
What is a Web Service?

A Web Service is any service that:

Is
available over the Internet
or private
(intranet) networks

Uses a standardized XML messaging
system

Is
not tied to any one operating system or
programming language

Although not required, a web service may
also have two additional (and
desirable
)
properties
:

a web service should be
self describing
.

a web service should be
discoverable
.
A Basic Web Service
Computer A:
Language: Perl
Operating System:

Windows 2000
Computer B:
Language: Java
Operating System:

Linux
XML
XML
XML Messaging

There are several
alternatives for XML
messaging:

XML Remote
Procedure Calls
(XML-RPC)

SOAP

Regular XML
transported over
HTTP

Any of these options
are valid.
XML-RPC
SOAP
HTTP POST/GET
XML Document
Self Describing and
Discoverable

Self describing:

If you publish a new web service, you should also
publish a public interface to the service.

At a minimum, you should include human-readable
documentation so that others can easily integrate
your service.

If you have created a
SOAP
service, you should also
include a public interface written in a common XML
grammar.

Discoverable:

If you create a web service, there should be a
relatively simple mechanism to publish this fact.

Interested parties should be able to easily discover
your service.

The discovery service could be completely
decentralised or completely centralised.
The Web Today: Human
Centric
Web
Browser
Web
Server
HTTP
GET: “What are
available flights for my
dates”
HTTP
Response
with HTML Page:

BE384 leaving at
14:45 arriving 15:50”

This illustrates a
human-centric web
, where humans are the primary
actors initiating web requests.

It also represents the primary model on which most of the web
operates today.
The Application-Centric
Web

Conversations between applications
occur as easily as
conversations between web browsers and servers
Booking
Application
Web
Server
On to
other applications

(e.g. travel agent systems)
On to
human
users
XML
Request: “What
are available flights for
my dates”
XML
Response:

BE384 leaving at
14:45 arriving 15:50”
The Semantic Web

Tim Berners
-
Lee, the original inventor
of the WWW, is now arguing for a
Semantic Web
:

The next stage is development of the Web

Application centric

Global application integration over the Web

Web services can be viewed as an actualisation of the
Semantic Web vision

Numerous applications:

e-commerce (shopping, travel, etc)

e-business (orders, logistics, etc)

scientific distributed computing (the Grid, etc)


Haven’t we seen this
before?

An application-centric web is not a new notion.

For years, developers have created

CGI applications, Java Servlets and CORBA applications

designed primarily for use by other applications.

The crucial difference is that most of these systems
consisted of
ad-hoc solutions
.

With web services, we have the promise of some
standardisation
.

Standardisation will lower the barrier to application
integration.
Long term vision:
Just-In-Time Integration
787-Travel

Smart”
travel
agent
application
Service
Registry
Discover Services
1
British Airways Server
Service Description
Ticket Booking Service
Retrieve Service
Description
2
Invoke Remote
Service
3
Hype vs Reality

How close are we to creating “Just-in-time” integration?

Currently, only some processes can be automated:

automatic registry query

automatic invocation of service

However,

no mechanism exists for automating business
relationships.

no mechanism exists for evaluating the quality of
services.


Hot” research area!

Big industry players involved (Microsoft, IBM, Sun, …)
XML


XML:
eXtensible Markup Language


"XML, to a certain extent, is HTML done
right." - Simon St.Laurent


XML is HTML on steroids.”


XML:

Extensible:
can be extended to lots of different
applications.

Markup language
: language used to mark up data.

Meta Language
: Language used to create other
languages.
XML vs HTML

XML
is
Extensible:

HTML: restricted set of tags, e.g. <TABLE>,
<H1>, <B>, etc.

XML: you can create your own tags

Example: Put a list of publications on the web.

HTML: You are stuck with regular HTML tags, e.g. H1,
H3, etc.

XML: You can create your own set of tags: TITLE,
AUTHOR, DATE, PUBLISHER, etc.
Publicati
o
ns list in HTML
<HTML>
<BODY>
<H1>Harry Potter</H1>
<H2>J. K. Rowling</H2>
<H3>1999</H3>
<H3>Scholastic</H3>
</BODY>
</HTML>
HTML conveys the

look and feel” of
your page.
As a human, it is
easy to pick out
the publisher.
But, how would
a computer pick
out the publisher?
Answer: XML
Publications list in XML
<BOOK>
<TITLE>Harry Potter</TITLE>
<AUTHOR>J. K. Rowling</AUTHOR>
<YEAR>1999</YEAR>
<PUBLISHER>Scholastic</PUBLISHER>
</BOOK>
Look at the new tags!
A Human and a computer can now easily
extract the publisher data.
XML vs HTML (contd.)

General Structure:

Both have Start tags and end tags.

Tag Sets:

HTML has set tags

XML lets you create your own tags.

General Purposes:

HTML focuses on "look and feel”

XML focuses on the structure of the data.

XML is not meant to be a replacement for HTML. In fact,
they are usually used together.

Basic Definitions

Tag:
a piece of markup

Example: <P>, <H1>, <TABLE>, etc.

Element:
a start and an end tag

Example: <H1>Hello</H1>

HTML Code:

<P>This is a <B>sample</B> paragraph.

This code contains:

3 tags, <P>, <B>, and </B>

However, it only contains one element
: <B>…</B>
XML rule 1: Well-
Formedness

XML is much more
strict
than HTML.

XML requires that documents be
well-
formed:


every start tag must have an end tag

all tags must be properly nested.

XML Code:

<P>This is a <B>sample</B> paragraph.</P>
Note the end </P>
Also, you ca
nnot
interleave
tags!
XML rule 2: XML is case
sensitive

XML is
case sensitive
.

HTML is not.

The following is valid in HTML:

<H1>Hello World</h1>

This will not work in XML.
Would result in
a well-formedness error:

H1 does not have a matching end H1 tag.
Rule 3: Attributes must be
quoted.

In HTML you can get away with doing the
following:

<FONT FACE=
ARIAL
SIZE=2>

In XML, you
must
put quotes around all your
attributes:

<BOOK ID=
“894329”
>Harry Potter</BOOK>
XML Example
<?xml version="1.0" encoding="ISO8859-1" ?>
<note>

<to>B359 class</to>

<from>Rinat</from>

<subject>Time management</subject>

<body>Please plan your work and complete the assignment
early!</body>
</note>
This XML Note could be part of
a message board application.
Back to web services:
Roles and protocols
UDDI
WSDL
XML-RPC, SOAP, Custom XML
HTTP, SMTP, FTP, BEEP
Discovery
Description
XML Messaging
Transport

Three major roles in web services:

Service Provider
: provider of the web service.

Service Requestor
: any consumer of the web service.

Service Registry
: logically centralised directory of
services.
XML-RPC

Use XML messages to perform Remote Procedure Calls
(RPC)

Simple!

Here is a sample XML-RPC request to a weather service:
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>

<methodName>weather.getWeather</methodName>

<params>

<param><value>10016</value></param>

</params>
</methodCall>

Give me the current weather conditions
in zip code: 10016.”
SOAP

SOAP: used to stand for “Simple Object
Access Protocol”

XML-Based protocol for exchanging
information between computers.

Currently a formal recommendation of the
World Wide Web Consortium (W3C.)
SOAP Message Format
SOAP Message
Envelope (Required)
Header (Optional)
Body (Required)
Fault (Optional: Response only)
SOAP Example

A sample SOAP request to a weather service:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope

xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body>

<ns1:
getWeather


xmlns:ns1="urn:examples:weatherservice"

SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding/">

<
zipcode
xsi:type="xsd:string">
10016
</
zipcode
>

</ns1:
getWeather
>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WSDL

WSDL:
Web Service Description Language

An XML grammar for specifying an interface for a web
service

Specifies

location
of web service

methods
that are available by the web service

data type information
for all XML messages

Given a WSDL file, a developer can immediately figure out
how to connect to the web service.

Eases overall integration process.

Better yet, with WSDL tools, you can automate the
integration…

WSDL is commonly used to describe SOAP services.
WSDL in a nutshell
<definitions>: Root WSDL Element
<message>: What messages will be transmitted?
<portType>: What operations (functions) will be supported?
<binding>: What SOAP specific details are there?
<service>: Where is the service located?
<types>: What data types will be transmitted?
WSDL Example: Weather
service

<message name="getWeatherRequest">

<part name="zipcode" type="xsd:string"/>

</message>

<message name="getWeatherResponse">

<part name="temperature" type="xsd:int"/>

</message>

<portType name="Weather_PortType">

<operation name="getWeather">

<input message="tns:getWeatherRequest"/>

<output message="tns:getWeatherResponse"/>

</operation>

</portType>
WSDL Example: Weather
service


<service name="Weather_Service">

<documentation>WSDL File for

Weather Service</documentation>

<port binding="tns:Weather_Binding"
name="Weather_Port">

<soap:address

location="http://ecerami.com/soap/servlet/rpcrouter"/>

</port>

</service>
</definitions>
UDDI

UDDI:
Universal Description, Discovery
and Integration.

Currently represents the
discovery
layer in
the protocol stack.

Originally created by Microsoft, IBM and
Ariba.

Technical specification for publishing and
finding businesses and web services.
Using the Protocols
Together
Find Services via UDDI
Step 1:
Retrieve Service Description File:
WSDL or XML-RPC Instructions
Step 2:
Create XML-RPC or SOAP Client
Step 3:
Invoke Remote Service
Step 4:
Implementing Web
services

Problem:

need to write code to parse XML

need to implement SOAP or other protocol used
Web server
Client
’s PC
XML inside
HTTP POST
XML inside
HTTP
response
Servlet
Parse XML, call necessary
methods, get results,
package them into XML
responses, send back to
client
Can use servlets!
Using Apache Axis

Apache Axis

a web application (a bunch of servlets)

provides an implementation of SOAP (XML handling, etc)

calls the Java classes implementing the corresponding
Web services


so all you need is to write a Java class, Axis will
make it accessible as a Web service!
Web server
Client
’s PC
XML inside
HTTP POST
XML inside
HTTP
response
Servlet
Java
classes
Using Apache Axis (contd.)

Deploying Web services in Axis

make your Java classes accessible to Axis – put them
inside Axis application tree (use standard places,
WEB-
INF/classes
or
WEB-INF/lib
)

tell Axis about your web services: set mapping from web
service names to class names

Web Services Deployment Descriptor (WSDD)

<service name="hello-service" provider="java:RPC">

<parameter name="className" value="Hello"/>

<parameter name="allowedMethods" value="*"/>

</service>
Tell Axis what methods should be exposed via the service
More Axis…

Axis also provides you with an number of useful
additional functions:

automatic generation of WSDL
for the deployed web
services

simplified deployment of web services via the
.jws files
:

rename your .java files to .jws

copy them into the root of the Axis application tree

when the file is accessed, Axis will automatically compile it and
convert SOAP calls correctly into Java invocations

automatic
building of Java interfaces and classes
for
the given web service from its WSDL

Please see Axis documentation for details!
Writing web services client

Use
SOAP client Java library
provided by
Axis:

create a Call object

set the URL for the web service

set the name of the operation to call

set types (and names) of input parameters and
the return value

invoke the service

Please see the detailed example in the
lab!
Summary

Moving from the human-centric Web of today to the
application-centric Web of tomorrow – the
Semantic Web

Web services provide a mechanism for building
interoperable Web applications

Based on
XML
– provides semantic markup of data

Service discovery and description:
WSDL
and
UDDI

Implementation technologies:
Axis
More information…

Questions