web services l.
Skip this Video
Loading SlideShow in 5 Seconds..
Web Services PowerPoint Presentation
Download Presentation
Web Services

Loading in 2 Seconds...

play fullscreen
1 / 49

Web Services - PowerPoint PPT Presentation

  • Uploaded on

Web Services Semantic Web - Fall 2005 Computer Engineering Department Sharif University of Technology Outline What are web services? Definitions Advantages Challenges Architecture WS Protocol Stack SOAP WSDL UDDI Apache Axis Web evolution XML HTML T C P/IP Technology

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Web Services

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
web services

Web Services

Semantic Web - Fall 2005

Computer Engineering Department

Sharif University of Technology

  • What are web services?
    • Definitions
    • Advantages
    • Challenges
    • Architecture
  • WS Protocol Stack
  • SOAP
  • WSDL
  • UDDI
  • Apache Axis
web evolution
Web evolution








FTP, E-mail, Gopher


Web pages

Connect the Web

Web services

Browse the Web

Program the Web

  • Definition 1:
    • A web service is a service (“program”) that can be invoked from another program via the web.
  • Definition 2:
    • “Web Services are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web”. – IBM Web Services Tutorial
  • Definition 3:
    • A Web Service is a service on the Internet that
      • Use a standardized XML messaging system
      • Not tied to any operating system or programming language
    • Optional features
      • Self-describing: provide public interface to the service via a common XML grammar
      • Discoverable: Interested parties can find a service and locate its interface
  • Flight Reservation
  • Weather Service
  • Amazon.com web services
  • Retrieve geographic information
    • http://terraserver.microsoft.net/TerraService.asmx
  • Search the web, check spellings
    • One of the first useful Web Services built around SOAP
    • Allows you to integrate your application with Google’s search, spell check, and cached page databases.
    • http://www.google.com/apis/
a basic web service
A Basic Web Service



Language: JavaOperating System:


Language: Perl

Operating System:

Windows 2000

web services advantages
Web Services Advantages
  • Use open, text-based standards, which enable components written in different languages and for different platforms to communicate.
  • Promote a modular approach to programming, so multiple organizations can communicate with the same Web service.
  • Self-describing (metadata for access and use)
  • Discoverable (search and locate in registries)
  • loosely coupled (i.e. Services should not be dependent on each other).
service oriented architecture basic model
Service Oriented Architecture (Basic Model)















SOAP– Simple Object Access Protocol / SOA Protocol

UDDI – Universal, Description, Discovery, and Integration

WSDL – Web Services Description Language

service interaction
Service Interaction

I organise


I know

the weather

Get a car rental quote

locate service

ask for quote

Is quote good enough?


Reserve car, provisionally

… get other resources reserved

Confirm reservation

I locate services

Service Identifier


I book car


I book hotels

I convert


I book planes


Web Service Protocol Stack

Searching / Publishing Web Services

Discovery UDDI

Description WSDL

Describing Web Services interface



Encoding messages in XML format

Transporting XML messages between client and server

simple object access protocol soap
Simple Object Access Protocol (SOAP)
  • SOAP is an XML-based protocol designed to exchange information in a distributed environment (a communication protocol).
  • SOAP is platform & language independent
  • SOAP is a W3Cstandard
soap message structure
SOAP: Message Structure

<?xml version="1.0"?>











SOAP Envelope

SOAP Header



Message Name & Data

soap advantages disadvantages
SOAP Advantages/Disadvantages
  • Advantages
    • Human-readable XML
      • Easy to debug
    • SOAP runs over HTTP
      • Firewalls not affected
    • Services can be written in any language, platform or operating system.
  • Disadvantages
    • S-L-O.............W
      • XML produces a lot of overhead for small messages
  • Web ServicesDescription Language
  • WSDL is an XML-based format designed to describe the interfaces exposed by a service
    • What a service does?
    • How clients can use it?
  • Separation of abstract service description from concrete messaging format:
    • An abstract section describing the interfaces in a protocol-independent way
    • A concrete section relating the abstract definitions with the specific protocols
  • It can be used with all protocols (HTTP, SMTP, etc.), but it normally runs over HTTP.
  • If sender & receiver share and understand same WSDL file, interoperability is guaranteed.
wsdl definitions
WSDL: Definitions
  • A WSDL document defines services as a collection of network endpoints or ports, where the port types are abstract collection of operations, and the concrete protocol and data format specifications for a particular port type constitutes a reusable binding.
  • Types: a container for data type definitions using some type system such as XSD.
  • Message: an abstract, typed definition of the data being communicated.
  • Operation: an abstract description of an action supported by the service.
  • PortType: an abstract set of operations supported by one or more endpoints.
    • They are equivalent to interfaces.
  • Binding: a concrete protocol and data format specification for a particular port type.
    • The interfaces are bound to specific network and transport protocols. It is akin to implementing an interface.
  • Port: a single endpoint defined as a combination of a binding and a network address.
  • Service: a collection of related endpoints.
wsdl structure
WSDL Structure

<?xml version="1.0" encoding="UTF-8"?><definitions> <types> <!– define the types here using XML Schema </types> <message> <!– XML messages the web service uses are defined here </message> <portType> <!– define the input and output parameters here - </portType> <binding> <!– define the network protocol here </binding> <service> <!– location of the service </service></definitions>

the types
The <types>
  • The types element contains XML Schemas defining the datatypes that are to be passed to and from the web service

<types> <schematargetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all><element name="tickerSymbol" type="string"/></all> </complexType> </element> <element name="TradePrice"> <complexType> <all><element name="price" type="float"/></all> </complexType> </element> </schema> </types>

the message
The <message>
  • The <message>element is used to define the messages that will be exchanged between the client and the service
  • These message elements contain <part>elements, which will be using types defined in the types element
  • All the parts are namespace qualified

<messagename="GetLastTradePriceInput"> <partname="body" element="xsd1:TradePriceRequest"/> </message>

<messagename="GetLastTradePriceOutput"> <partname="body" element="xsd1:TradePrice"/></message>

the porttype
The <portType>
  • The types and messages have been defined, but they have not been defined in terms of where they fit in the functionality of the web service
  • This is done within <portType>and <operation>elements
  • A portType is analogous to a class
  • An operation is analogous to a method in that class

<portTypename="StockQuotePortType"> <operationname="GetLastTradePrice"><input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation></portType>

types of operation
Types of <operation>
  • There are four distinct types of operation
  • Synchronous
    • Request-response - The service receives a message and sends a reply
    • Solicit-response - The service sends a message and receives a reply message
  • Asynchronous
    • One-way - The service receives a message
    • Notification - The service sends a message
  • All of these can be defined in WSDL
defining the type of operation
Defining the type of operation
  • Presence and order of input/output elements defines the type of operation.
  • Request-response <input><output>
  • Solicit-response <output><input>
  • One-way <input> only
  • Notification <output> only
the binding element
The <binding> element
  • This element is used to define the mechanism that the client will actually use to interact with the web service
  • The most common choice is currently SOAP
  • The binding element defines the protocol specific information for the portTypes previously defined
the binding tag
The binding tag


The <binding> tag indicates that we will map a <Port Type> to a protocol

<soap:bindingstyle=“rpc” transport=“http://schemas.xmlsoap.org/soap/http/”>

Indicates we will be using the SOAP binding extensions to map the operations.

The alternative to “rpc” is “document”.

( to use GET/POST use <http:binding…>

to use MIME use <mime:binding…..> )

  • The final component of a WSDL file is the <service> element
  • The <service> element defines <port> elements that specify where requests should be sent
  • The <soap:address> subelement identifies the URL of the service
  • The precise content of <port> elements will be dependent upon the mechanism, i.e. SOAP, HTTP or MIME

<service name="StockQuoteService"> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port></service>

wsdl example 1 5
WSDL: Example (1/5)

<?xml version="1.0"?>

<definitions name="StockQuote"









<schema targetNamespace="http://example.com/stockquote/schema"


<complexType name="TimePeriod">


<element name="startTime" type="xsd:timeInstant"/>

<element name="endTime" type="xsd:timeInstant"/>



wsdl example 2 5
WSDL: Example (2/5

<complexType name="ArrayOfFloat">


<restriction base="soapenc:Array">

<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:float[]"/>






<message name="GetTradePricesInput">

<part name="tickerSymbol" element="xsd:string"/>

<part name="timePeriod" element="xsda:TimePeriod"/>


wsdl example 3 5
WSDL: Example (3/5)

<message name="GetTradePricesOutput">

<part name="result" type="xsda:ArrayOfFloat"/>

<part name="frequency" type="xsd:float"/>


<portType name="StockQuotePortType">

<operation name="GetLastTradePrice" parameterOrder="tickerSymboltimePeriodresultfrequency">

<input message="tns:GetTradePricesInput"/>

<output message="tns:GetTradePricesOutput"/>



wsdl example 4 5
WSDL: Example (4/5)

<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">

<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="GetTradePrices">

<soap:operation soapAction="http://example.com/GetTradePrices"/>


<soap:body use="encoded" namespace="http://example.com/stockquote“ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>



<soap:body use="encoded" namespace="http://example.com/stockquote"





wsdl example 5 5
WSDL: Example (5/5)

<service name="StockQuoteService">

<documentation>My first service</documentation>

<port name="StockQuotePort" binding="tns:StockQuoteBinding">

<soap:address location="http://example.com/stockquote"/>




  • Universal Description, Discovery and Integration
  • A Web Service registry & discovery mechanism for retrieving pointers for web services interfaces
  • Publish your business information and technical details of your Web Service
  • Search for other Web Services and connect to them
  • UDDI is not only limited to XML Web Services
  • The key to the ultimate success of Web services, but has some key limitations, and alternative discovery methods are provided by ebXML and WS-Inspection.
uddi details
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)
  • Axis
  • EWS
  • JaxMe
  • jUDDI
    • jUDDI (pronounced "Judy") is an open source Java implementation of the Universal Description, Discovery, and Integration (UDDI) specification for Web Services.
  • Kandula
  • Mirae
  • Muse
  • Pubscribe
  • Sandesha
  • Scout
  • SOAP
  • TSIK
  • Woden
  • WSIF
    • The Web Services Invocation Framework (WSIF) is a simple Java API for invoking Web services, no matter how or where the services are provided.
  • WSRF
  • WSS4J
apache axis
Apache Axis
  • Apache Axis is an Open Source SOAP server and client
  • It is completely written in Java
  • The server can be executed as a web application into servlet engines such as Jakarta Tomcat
publishing web services with axis
Publishing Web Services with Axis
  • Let’s say we have a simple Java class like the following:

public class Converter {

public double toLire(double euro) {

return euro * 1936.27;


public double toEuro(double lire) {

return lire / 1936.27;



publishing web services with axis39
Publishing Web Services with Axis
  • JWS (Java Web Service) files – Instant deploying
    • Step 1
      • Copy Converter.java file into your axis webapp directory, and rename it as Converter.jws
    • Step 2
      • You should now be able to access the service at the following URL (assuming your Axis web application is on port 8080): http://localhost:8080/axis/Converter.jws
consuming web services with axis
Consuming Web Services with Axis

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import javax.xml.namespace.QName;

publicclass ConverterClient {

publicstaticvoid main(String args[]) {

try {

String endpoint = "http://localhost:8080/axis/Converter.jws";

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(endpoint));


QName("http://localhost:8080/axis/Converter.jws", "toLire"));

Double ret = (Double)call.invoke(new Object[] {new Double(10.0)});

System.out.println("10 euro = " + ret.doubleValue() + " lire");

} catch (Exception e) {





consuming web services with net 1 2
Consuming Web Services with .NET (1/2)
  • C# Client
    • Create a new C# console application project
    • Add a class called ConverterClient
    • Add a web reference to http://localhost:8080/axis/Converter.jws?wsdlin the project, otherwise the class ConverterService will not be found.
consuming web services with net 2 2
Consuming Web Services with .NET (2/2)

using System;

using ConsoleApplication.localhost;

namespace ConsoleApplication {

/// <summary>

/// Summary description for Class1.

/// </summary>

class ConverterClient {

/// <summary>

/// The main entry point for the application.

/// </summary>


static void Main(string[] args) {

ConverterService converter = new ConverterService();

System.Console.WriteLine("10 euro = {0}", converter.toLire(10));





using the axis tcp monitor tcpmon
Using the Axis TCP Monitor (tcpmon)
  • The tcpmon utility keeps a log of all request/response SOAP messages
  • It can be found in the org.apache.axis.utils package
  • To run it from the command line:
    • java org.apache.axis.utils.tcpmon
publishing web services with net 1 2
Publishing Web Services with .NET (1/2)
  • Visual Studio .NET 2003
    • From the File menu, point to New, and click New Project
    • Select ASP.NET Web service
    • Change the Location if necessary
    • Click OK
    • Open the code window
    • Add the following code
publishing web services with net 2 2
Publishing Web Services with .NET (2/2)


public double toLire(double euro)


return euro * 1936.27;



public double toEuro(double lire)


return lire / 1936.27;


the java client 1 2
The Java client (1/2)
  • Generate the stub to access to the Web Servicejava org.apache.axis.wsdl.WSDL2Javahttp://localhost/Converter/Service1.asmx?WSDL
  • This tool generates the following files:
    • Service1.java
    • Service1Locator.java
    • Service1Soap.java
    • ServiceSoapStub.java
the java client 2 2
The Java Client (2/2)

import org.tempuri.*;

publicclass DotNetConverterClient {

publicstaticvoid main(String args[]) {

try {

Service1 service = new Service1Locator();

Service1Soap calculator = service.getService1Soap();

System.out.println("10 euro = " + calculator.toLire(10) + " lire");

} catch (Exception e) {





web services challenges
Web Services Challenges
  • The standards that drive Web services are still in draft form.
  • Web services need standard securityprocedures (a common problem to all of the distributed computing solutions).
  • The leading registry, based on the UDDI specification, has some key limitations, and alternative discovery methods are needed.
  • Web services need Quality of Service (QoS) support from Web Services Registries, Brokerages, and Network Providers.
  • Web Services Activity
    • http://www.w3.org/2002/ws/
  • W3C Web Services glossary
    • http://www.w3.org/TR/ws-gloss/