Slide show

Web services

Web services

What are Web Services?

Many answers:

We only use the last definition

Gartner software state

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

Web Service Structure

Web Service Components

Example Web Services

The site XMethods (www.xmethods.com) is an open site for registering Web services. It includes

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

What's Missing

Session management


Data types

Web services use data types that can be supported by a range of languages. Typically, these are the XML Schema Standard Data Types

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);
};

Components of WSDL Specification

Data types
Messages
Ports
Bindings
Service

      name: Converter
      
address: http://... ...
This is poor design: the location of a service should not be part of the specification of the service

WSDL Specification


<?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


SOAP

What SOAP Claims to be

What SOAP is

What SOAP isn't

SOAP HTTP Binding


SOAP Server

Apache Axis

SOAP client

Here is a part of a client that can run when the location of a WSDL document is known


    URL wsdlURL = ...;
    String   namespace = "http://www.getquote.com/StockQuoteService" ;
    QName    serviceQN = new QName( namespace, "SimpleStockQuoteService" );
    QName    portQN    = new QName( namespace, "Demo" );

    Service  service   = new Service(new URL(wsdlURL), serviceQN );

    call = (Call) service.createCall( portQN, "getQuote" );

    Float result = (Float) call.invoke( new Object[] { "XXX" } );

Classes are found in packages such as

  import java.net.URL;
  import org.apache.axis.client.Service ;
  import org.apache.axis.client.Call;
  import javax.xml.namespace.QName;


UDDI


UDDI (Universal Description, Discovery and Integration)

Registry Entry

UDDI and WSDL

Public/private Registries

Private Registries


UDDI registration of service


IBM UDDI registry


public class Publish{
    public static void main(String[] args) throws Exception {
	try {
	    //------------------------------------------------------
	    // let's collect the input arguments
	    //------------------------------------------------------
	    String serviceImplementationWSDL = args[0];
	    String serviceInterfaceWSDL = args[1];
	    String serviceDeployment = "";
	    String serviceMgr = "";
	    //------------------------------------------------------
	    // this will use whatever UDDI registry you selected
	    // in the WSTK Configuration Tool
	    //------------------------------------------------------
	    UDDIWSDLProxy uwp =
		new UDDIWSDLProxy(WSTKConstants.UDDI_INQUIRY_URL,
				  WSTKConstants.UDDI_PUBLISH_URL,
				  WSTKConstants.UDDI_USERID,
				  WSTKConstants.UDDI_CRED,
				  WSTKConstants.TRANSPORT_CLASS);
	    //------------------------------------------------------
	    // assuming that you haven't yet registered yourself as
	    // a Service Provider, do the following steps. If you
	    // have already registered as a service provider, you
	    // should use your existing registration
	    //------------------------------------------------------
	    KeyedReference keyedReference =
		new KeyedReference(TModelKeyTable.UNSPSC, "84.12.18.01.00");
	    keyedReference.setTModelKey(TModelKeyTable.UNSPSC_TMODEL_KEY);
	    Vector keyedReferenceVector = new Vector();
	    keyedReferenceVector.add(keyedReference);
	    // Create category bag
	    CategoryBag spCatList = new CategoryBag();
	    spCatList.setKeyedReferenceVector(keyedReferenceVector);
	    ServiceProvider sp = new ServiceProvider("WSTK 3.1 Tutorial",
						     "WSTK 3.1 Tutorial",
						     spCatList);
	    sp = uwp.publish(sp);
	    System.out.println();
	    System.out.println("Service Provider Published");
	    System.out.println("\t" + sp.getName());
	    System.out.println("\t" + sp.getBusinessKey());
	    System.out.println();
	    //------------------------------------------------------
	    // now we publish the service interface
	    //------------------------------------------------------
	    ServiceInterface si = new ServiceInterface(serviceInterfaceWSDL);
	    si = uwp.publish(si);
	    System.out.println();
	    System.out.println("Service Interface Published");
	    System.out.println("\t" + si.getName());
	    System.out.println("\t" + si.getTModelKey());
	    System.out.println();
	    //------------------------------------------------------
	    // now we deploy and publish the service itself
	    //------------------------------------------------------
	    keyedReference =
		new KeyedReference(TModelKeyTable.UNSPSC, "84.12.18.01.00");
	    keyedReference.setTModelKey(TModelKeyTable.UNSPSC_TMODEL_KEY);
	    keyedReferenceVector = new Vector();
	    keyedReferenceVector.add(keyedReference);
	    // Create category bag
	    CategoryBag sdCatList = new CategoryBag();
	    spCatList.setKeyedReferenceVector(keyedReferenceVector);
	    //
	    AxisServiceDefinition sd = new AxisServiceDefinition(
								 serviceImplementationWSDL,
								 sdCatList,
								 serviceDeployment,
								 serviceMgr);
	    uwp.publish(sp, sd);    //- publish the service
	    System.out.println();
	    System.out.println("Service Description Published");
	    System.out.println("\t" + sd.getName());
	    System.out.println("\t" + ceKey());
	    System.out.println("\t" + serviceImplementationWSDL);
	    System.out.println();
	    System.out.println("Done!");
	} catch (Exception e) {
	    System.err.println(e);
	}
    }		
}	       


Access to Registries

Java Client

IBM's IDDI4J client search


public static String findUDDI(String service) throws Exception {
    try {
        UDDIWSDLProxy uwp = new UDDIWSDLProxy(WSTKConstants.UDDI_INQUIRY_URL,
                                              WSTKConstants.UDDI_PUBLISH_URL,
                                              WSTKConstants.UDDI_USERID,
                                              WSTKConstants.UDDI_CRED,
                                              WSTKConstants.TRANSPORT_CLASS);
        Vector providerNameVector = new Vector();
        providerNameVector.add(new Name("WSTK 3.2 Tutorial"));
        ServiceProvider[] sps = uwp.findAllServiceProviders(null,
                                                            providerNameVector,
                                                            null,null,null,null,
                                                            true);
        if (sps.length > 0) {
            ServiceDefinition sd = sps[0].getServiceDefinition(service);
            return sd.getServiceImplementation().getWSDLFilename();
        } else {
            return null;
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        System.exit(0);
        return null;
    }
}

Web Services Dynamic Discovery

Summary

References


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Wed May 26 10:36:06 EST 2004
Copyright ©Jan Newmarch
Copyright © Jan Newmarch, Monash University, 2007
Creative Commons License This work is licensed under a Creative Commons License
The moral right of Jan Newmarch to be identified as the author of this page has been asserted.