Slide show

Web services

Jan Newmarch
Peninsula School of IT
Monash University
Email: jan@newmarch.name
Home page: http://jan.newmarch.name

Workshop content

Assignments
Workshops


Background


Knowledge management

The world wide web

Knowledge management on the Web

World Live Web

The Physical Web

XHTML

Semantic Web

Value of semantic web

Form filling

Web services


Web services


Web services

Web services definition

Examples

Web service interaction

Web Service Components

Base technology limitations

The web services zoo

The web services zoo

Current organisations

Money making?

Gartner hype cycle

Gartner regularly publishes a graph on the state of software. The latest (at August 2005) is


Web service background


Client-server paradigms

Base sockets
Remote Procedure Call web services, Sun RPC, COM+
Remote objects CORBA
Downloadable objects Java RMI
Mobile objects Aglets
Messaging JMS

Web Service Environmental Support

Web services are basically RPC across port 80. They require the following environmental support

Web Service Standards Requirements

Ordinary Procedure Call

Remote Procedure Call

Web Services Remote Procedure Call

Components of RPC

An RPC system consists of the following pieces

Web Services and Standardisation

RPC requirement SOAP
defined data types defined by SOAP
wire format for data defined by SOAP using XML
wire format for messages defined by SOAP over HTTP
an IDL defined by WSDL
generation of client stubs vendor specific
generation of server stubs vendor specific
linking implementation vendor specific
Address of service URL
Locating service UDDI

Competitors

Measurement converter service in Java


public class Converter implements java.rmi.Remote {
    public float inchToMM(float float_1) throws
         java.rmi.RemoteException {

        float _retVal = float_1 * 2.54;
        return _retVal;
    }
    public float mmToInch(float float_1) throws
         java.rmi.RemoteException {

        float _retVal = float_1 / 2.54;
        return _retVal;
    }
}

Measurement converter client in Perl


#!/usr/bin/perl

use SOAP::Lite;

print SOAP::Lite
    -> uri('http://localhost/Converter')  # Converter service
    -> proxy('http://localhost:8088/axis/Converter.jws') # Axis service
    -> inchToMM(1.0)
    -> result;
      

Google


WSDL


Role of Specification Languages

Simple Service

CORBA

A CORBA IDL specification would look like


    interface Converter {
        float inchToMM(in float value);
        float mmToInch(in float value);
    };

Java RMI

A Java RMI specification would look like


    public interface Converter implements Remote {
        public float inchToMM(float value)
                     throws RemoteException;
        public float mmToInch(float value)
                     throws RemoteException;
    }

WSDL

The WSDL specification looks like


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tns="urn:Converter" targetNamespace="urn:Converter" name="ConverterService">
    <message name="inchToMMRequest">
        <part name="param1" type="xsd:float"/>
    </message>
    <message name="inchToMMResponse">
        <part name="return" type="xsd:float"/>
    </message>
    <message name="mmToInchRequest">
        <part name="param1" type="xsd:float"/>
    </message>
    <message name="mmToInchResponse">
        <part name="return" type="xsd:float"/>
    </message>
    <message name="java_rmi_RemoteException">
        <part type="xsd:string" name="java_rmi_RemoteException"/>
    </message>
    <message name="com_iona_xmlbus_webservices_ejbserver_ConversionException">
        <part type="xsd:string" name="com_iona_xmlbus_webservices_ejbserver_ConversionException"/>
    </message>
    <portType name="ConverterPortType">
        <operation name="inchToMM">
            <input message="tns:inchToMMRequest" name="inchToMM"/>
            <output message="tns:inchToMMResponse" name="inchToMMResponse"/>
            <fault message="tns:java_rmi_RemoteException" name="java_rmi_RemoteException"/>
        </operation>
        <operation name="mmToInch">
            <input message="tns:mmToInchRequest" name="mmToInch"/>
            <output message="tns:mmToInchResponse" name="mmToInchResponse"/>
            <fault message="tns:java_rmi_RemoteException" name="java_rmi_RemoteException"/>
            <fault
                message="tns:com_iona_xmlbus_webservices_ejbserver_ConversionException" name="com_iona_xmlbus_webservices_ejbserver_ConversionException"/>
        </operation>
    </portType>
    <binding name="ConverterBinding" type="tns:ConverterPortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http/" style="rpc"/>
        <operation name="inchToMM">
            <soap:operation soapAction="" style="rpc"/>
            <input name="inchToMM">
                <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output name="inchToMMResponse">
                <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
            <fault name="java_rmi_RemoteException">
                <soap:fault name="java_rmi_RemoteException"
                    use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </fault>
        </operation>
        <operation name="mmToInch">
            <soap:operation soapAction="" style="rpc"/>
            <input name="mmToInch">
                <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output name="mmToInchResponse">
                <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
            <fault name="java_rmi_RemoteException">
                <soap:fault name="java_rmi_RemoteException"
                    use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </fault>
            <fault name="com_iona_xmlbus_webservices_ejbserver_ConversionException">
                <soap:fault
                    name="com_iona_xmlbus_webservices_ejbserver_ConversionException"
                    use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </fault>
        </operation>
    </binding>
    <service name="Converter">
        <port name="ConverterPort" binding="tns:ConverterBinding">
            <soap:address location="http://www.xmlbus.com:9010/ionasoap/servlet/Converter"/>
        </port>
    </service>
</definitions>

Components of WSDL Specification

Data types
Messages
These describe the messages that can be sent in amy direction, including parameter information
Ports
These link operations and the messages that make up an operation, and relate input/output abstract messages to actual messages
Bindings
These determine the wire transport mechanism, such as RPC
Service

      name: Converter
      
address: http://... ...

WSDL Specification Revisited


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tns="urn:Converter" targetNamespace="urn:Converter" name="ConverterService">
<message name="inchToMMRequest"> <part name="param1" type="xsd:float"/> </message> <message name="inchToMMResponse"> <part name="return" type="xsd:float"/> </message> <message name="mmToInchRequest"> <part name="param1" type="xsd:float"/> </message> <message name="mmToInchResponse"> <part name="return" type="xsd:float"/> </message> <message name="java_rmi_RemoteException"> <part type="xsd:string" name="java_rmi_RemoteException"/> </message> <message name="com_iona_xmlbus_webservices_ejbserver_ConversionException"> <part type="xsd:string" name="com_iona_xmlbus_webservices_ejbserver_ConversionException"/> </message>
<portType name="ConverterPortType"> <operation name="inchToMM"> <input message="tns:inchToMMRequest" name="inchToMM"/> <output message="tns:inchToMMResponse" name="inchToMMResponse"/> <fault message="tns:java_rmi_RemoteException" name="java_rmi_RemoteException"/> </operation> <operation name="mmToInch"> <input message="tns:mmToInchRequest" name="mmToInch"/> <output message="tns:mmToInchResponse" name="mmToInchResponse"/> <fault message="tns:java_rmi_RemoteException" name="java_rmi_RemoteException"/> <fault message="tns:com_iona_xmlbus_webservices_ejbserver_ConversionException" name="com_iona_xmlbus_webservices_ejbserver_ConversionException"/> </operation> </portType>
<binding name="ConverterBinding" type="tns:ConverterPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http/" style="rpc"/> <operation name="inchToMM"> <soap:operation soapAction="" style="rpc"/> <input name="inchToMM"> <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output name="inchToMMResponse"> <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> <fault name="java_rmi_RemoteException"> <soap:fault name="java_rmi_RemoteException" use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </fault> </operation> <operation name="mmToInch"> <soap:operation soapAction="" style="rpc"/> <input name="mmToInch"> <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output name="mmToInchResponse"> <soap:body use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> <fault name="java_rmi_RemoteException"> <soap:fault name="java_rmi_RemoteException" use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </fault> <fault name="com_iona_xmlbus_webservices_ejbserver_ConversionException"> <soap:fault name="com_iona_xmlbus_webservices_ejbserver_ConversionException" use="encoded" namespace="urn:Converter" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </fault> </operation> </binding>
<service name="Converter"> <port name="ConverterPort" binding="tns:ConverterBinding"> <soap:address location="http://www.xmlbus.com:9010/ionasoap/servlet/Converter"/> </port> </service>
</definitions>

WSDL Versions

Role of WSDL in Web Services

Apache Axis WSDL Tools

There and Back Again

Conclusion


SOAP


What SOAP Claims to be

What SOAP is

What SOAP isn't

XML Descriptions

XML DTDs

XML DTDs (Document Type Definitions) are good for describing document structure e.g.

XML Schema

XML Schema Standard Data Types


SOAP Messages

SOAP messages are either

Java mapping of data types

Sun has proposed a Java standard for mapping begtween XML and Java types

Most XML standard data type are represented by a Java data type

XML Java
boolean boolean
byte byte
dateTime java.util.Calendar
double double
float float
int int
integer java.math.BigInteger
string String

Some types can't be represented since they don't exist in Java, such as unsigned int. If a type can be "nillable" (that is, have a nil value) and it would be a Java primitive type, then it is wrapped in a Java class such as Integer.

SOAP Request

A SOAP request consists of

SOAP Response

A SOAP response is just like a request, except the body contains the result.

SOAP Message Structure

<?xml version="1.0" ?>
 <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
   <env:Header>
     ::::
   </env:Header>
   <env:Body >
     ::::
   </env:Body>
 </env:Envelope>

SOAP Header Blocks

SOAP Body for RPC Request

SOAP Body for RPC Response

SOAP HTTP Binding

SOAP HTTP Request


POST /Charging HTTP/1.1
Host: travelcompany.example.org
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" >
 <env:Body>
    <m:reserveAndCharge>
        ::::::
    </m:reserveAndCharge>
  </env:Body>
</env:Envelope>
      

SOAP HTTP Response


HTTP/1.1 200 OK
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" >
 <env:Body>
    <m:reserveAndChargeResponse>
        ::::::
    </m:reserveAndCharge>
 </env:Body>
</env:Envelope>
      


Calling SOAP Methods


Roll Your Own

Perl SOAP::Lite

Apache Axis Server

Apache Axis service and Perl client

Apache Axis Client - do it yourself


    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.namespace.QName;
   
    public class TestClient {
      public static void main(String [] args) {
          try {
              String endpoint =
                       "http://nagoya.apache.org:5049/axis/services/echo";
  
             Service  service = new Service();
             Call     call    = (Call) service.createCall();
  
             call.setTargetEndpointAddress( new java.net.URL(endpoint) );
             call.setOperationName(new QName("http://soapinterop.org/", "echoString"));
             String ret = (String) call.invoke( new Object[] { "Hello!" } );
  
             System.out.println("Sent 'Hello!', got '" + ret + "'");
         } catch (Exception e) {
             System.err.println(e.toString());
         }
     }
   }

Apache Axis client using WSDL


public class Tester
{
    public static void main(String [] args) throws Exception {
        // Make a service
        ConverterInterfaceService service = new ConverterInterfaceServiceLocator();
 
        // Now use the service to get a stub which implements the SDI.
        ConverterInterface port = service.getConverterInterface();
 
        // Make the actual call
        float mm = port.inchToMM(1.0);
    }
}

Browser access to Web services

Conclusion


Session management


HTTP and sessions

Cookies and other hacks

Sessions and SOAP

What is involved

Conclusion


Security


General

XML Encryption

Breaking the SOAP specifications

Conclusion


Curriculum issues


Distributed Computing using Java

This is the lecture syllabus for a course I teach in distributed programming

Comments


UDDI


UDDI (Universal Description, Discovery and Integration)

Registry Entry

UDDI and WSDL

Public/private Registries

Private Registries

Access to Registries

Perl client

Java Client


Computer science and web services


Paradigms

The REST criticisms

Other critcisms of SOAP

Over-flexibility in WSDL

Security as an afterthought

Borrowed technologies - UDDI


My research


General

Jini

UPnP

Jini/UPnP bridge

UPnP and REST

Web service session management using SIP

Audio

Dynamic class discovery

Lightweight grid

Flexible service discovery

Ownership

Intellectual property and courseware


Research issues


Computer science

Software engineering

Information systems


Internationalisation


Diversity

Internationalisation

Localisation

Culture specific properties

Locales

Locale representation - ASCII

Locales can be written in textual form

Issues with locales

Java PropertyResourceBundle

Common Locale Data Repository

Distributed versus local applications

RFC 1958

HTTP charset negotiation

HTTP language negotiation

Server-driven negotiation

From the HTTP 1.1 specification:

Agent-driven Negotiation

From the HTTP 1.1 specification:

Apache type-map negotiation

Common user negotiation

HTML and i18n

There is limited support for i18n in HTML

JavaScript


Web services and i18n


i18n

Lang information in header block

i18n Measures and Axis

Summary

References


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Fri Dec 9 15:58:04 EST 2005
Copyright ©Jan Newmarch