14 sep 2004 nvo summer school1 introduction to web services technology matthew j. graham...

23
14 Sep 2004 NVO Summer School 1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech THE US NATIONAL VIRTUAL OBSERVATORY

Upload: hilary-lawson

Post on 05-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 1

Introduction to Web Services Technology

Matthew J. GrahamCACR/Caltech

THE US NATIONAL VIRTUAL OBSERVATORY

Page 2: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 2

Overview

• SOA• SOAP, WSDL and UDDI• Infrastructures: AXIS, .Net (Mono),

Python, Perl, PHP• Invocation• Interoperability• Emerging topics: attachments, state,

security, asynchronous

Page 3: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 3

Service Oriented Astronomy

• An application architecture within which all functions are defined as independent services with well-defined invocable interfaces which can be called in defined sequences to form scientific processes.

• Web Services are an implementation

Page 4: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 4

Technological challenges

• WS technologies need to address four basic challenges:– Service Description– Service Implementation– Service Publishing, Discovery and Binding– Service Invocation and Execution

Page 5: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 5

What’s wrong with HTTP GET?

• “Things should be made as simple as possible, but no simpler” - Albert Einstein

• Highly scalable, predominantly read-only data • REST (Representational State Transfer)• Amazon.com:

– has both REST and SOAP APIs – 85% of requests are REST – REST response is 6 times faster than SOAP

Page 6: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 6

Why is SOAP better?

• Send and receive complex datatypes to invoke a particular method not just key-value pairs

• Security - not URI parameters • Guaranteed or exact execution • Binds to other protocols

Page 7: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 7

What is SOAP?

• Simple Object Access Protocol• An XML-based communication protocol

and encoding format for exchanging structured information in a decentralized, distributed environment

• W3C specification (http://www.w3.org/TR/soap)

Page 8: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 8

Anatomy of a SOAP message

• An envelope to encapsulate data which defines formatting conventions for describing the message contents and routing directions

• A request/response message exchange pattern (RPC mechanism)

• A transport or binding protocol• Data encoding rules for describing the

mapping of application-defined datatypes into an XML tag-based representation

Page 9: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 9

SOAP example

Request:<soap:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>

<ComovingLineOfSight xmlns="http://skyservice.pha.jhu.edu"> <z>float</z> <hubble>float</hubble> <omega>float</omega> <lambda>float</lambda>

</ComovingLineOfSight> </soap:Body>

</soap:Envelope>

Response:<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>

<ComovingLineOfSightResponse xmlns="http://skyservice.pha.jhu.edu"> <ComovingLineOfSightResult>float</ComovingLineOfSightResult>

</ComovingLineOfSightResponse></soap:Body>

</soap:Envelope>

Page 10: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 10

What is WSDL?

• Web Services Description Language• An XML grammar for describing a web

service as a collection of endpoints capable of exchanging messages in a particular fashion

• W3C specification (http://www.w3.org/TR/wsdl)

Page 11: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 11

Anatomy of a WSDL file

<definitions><import>*<types>

<schema></schema>*</types><message>*

<part></part>*</message><portType>*

<operation>*<input></input><output></output><fault></fault>*

</operation></portType><binding>*

<operation>*<input></input><output></output>

</operation></binding><service>*

<port></port>*</service>

</definitions>

- include other WSDLS- define datatypes used in <message> elements

- model data exchanged

- a subset of operations supported for an endpoint

- define input and output messages

- concrete protocol and data format specification for a <portType> element

- identifies actual endpoint for WS

Page 12: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 12

WSDL example (I)

<?xml version="1.0" encoding="utf-8"?><definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://skyservice.pha.jhu.edu" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://skyservice.pha.jhu.edu" xmlns="http://schemas.xmlsoap.org/wsdl/">

<types> <s:schema elementFormDefault="qualified" targetNamespace="http://skyservice.pha.jhu.edu"> <s:element name="ComovingLineOfSight"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="z" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="hubble" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="omega" type="s:float" /> <s:element minOccurs="1" maxOccurs="1" name="lambda" type="s:float" /> </s:sequence> </s:complexType> </s:element> <s:element name="ComovingLineOfSightResponse">

<s:complexType>

<s:sequence> <s:element minOccurs="1" maxOccurs="1" name="ComovingLineOfSightResult"

type="s:float" /> </s:sequence> </s:complexType> </s:element> </s:schema></types>

Page 13: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 13

WSDL example (II)<message name="ComovingLineOfSightSoapIn">

<part name="parameters" element="s0:ComovingLineOfSight" /> </message> <message name="ComovingLineOfSightSoapOut">

<part name="parameters" element="s0:ComovingLineOfSightResponse" /> </message> <portType name="DistanceSoap">

<operation name="ComovingLineOfSight"> <documentation>Return the comoving line of sight distance...</documentation>

<input message="s0:ComovingLineOfSightSoapIn" /> <output message="s0:ComovingLineOfSightSoapOut" />

</operation></portType><binding name="DistanceSoap" type="s0:DistanceSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /><operation name="ComovingLineOfSight”>

<soap:operation soapAction="http://skyservice.pha.jhu.edu/ComovingLineOfSight" style="document" />

<input><soap:body use="literal" />

</input><output>

<soap:body use="literal" /></output>

</operation></binding><service name="Distance">

<documentation>...</documentation><port name="DistanceSoap" binding="s0:DistanceSoap">

<soap:address location="http://voservices.net/Cosmology/ws_v1_0/Distance.asmx" /></port>

</service></definitions>

Page 14: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 14

WSDL binding flavours (I)

<message name=“Request”><part name=“x” type=“xs:int”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

<message name=“Request”><part name=“x” type=“xs:int”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

<types><schema>

<element name=“xElement” type=“xs:int”/>

</schema></types>

<message name=“Request”><part name=“x” element=“xElement”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType>

RPC Document

Literal

Encoding

Page 15: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 15

WSDL binding flavours (II)

<soap:envelope><soap:body>

<method><x xsi:type=“xs:int”>5</x>

</method></soap:body>

</soap:envelope>

<soap:envelope><soap:body>

<method><x>5</x>

</method></soap:body>

</soap:envelope>

<soap:envelope><soap:body>

<xElement>5</xElement></soap:body>

</soap:envelope>

RPC Document

Literal

Encoding

Page 16: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 16

<types><schema>

<element name=“method”><complexType>

<sequence> <element name=“x” type=“xs:int”/></sequence>

</complexType></element>

</schema></types>

<message name=“Request”><part name=“parameters” element=“method”/>

</message>

<message name=“empty”/>

<portType name=“foo”><operation name=“method”>

<input message=“Request”/><output message=“empty”/>

</operation></portType

WSDL binding flavours (III)

<soap:envelope><soap:body>

<method><x>5</x>

</method>></soap:body>

</soap:envelope>

Document/literal wrapped

Page 17: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 17

UDDI

• Universal Description, Discovery and Integration

• A platform-independent, open framework for publishing and discovering information about web services

• OASIS specification (http://www.uddi.org)

Page 18: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 18

What do I need?

• SOAP library• WSDL parser• Client and server stub code generator• Service container• (UDDI library)

Page 19: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 19

What’s available?

• Java (http://www.javaskyline.com/webservices):– Axis (http://ws.apache.org/axis)– Globus (http://www.globus.org)

• C#:– .Net; Mono (http://www.go-mono.com)– OGSI.NET / WSRF.NET

(http://www.cs.virginia.edu/~gsw2c/wsrf.net.html)• Perl:

– SOAP::Lite (http://www.soaplite.com)– OGSI::Lite / WSRF::Lite

(http://www.sve.man.ac.uk/Research/AtoZ/ILCT)• Python:

– SOAPpy / ZSI (http://pywebsvcs.sourceforge.net)– Twisted (http://www.twistedmatrix.com/products/twisted)– PyGlobus/PyGridWare

• PHP– NuSOAP (http://dietrich.ganx4.com/nusoap)

• XForms (http://www.w3.org/MarkUp/Forms)

Page 20: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 20

Client Invocation Models

• Static: use generated stubs• Dynamic:

– no generated code– a proxy dynamically generates a class at

runtime that conforms to a particular interface, proxying all invocations to a single ‘generic’ method

– standard Java : use javax.xml.rpc.Service.getPort() and createCall()

– .Net : use RealProxy class (must extend ContextBound) or Reflection.Emit

Page 21: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 21

Interoperability

• Suitable for and capable of being implemented in a neutral manner on multiple operating systems and in multiple programming languages

• Not all web services are interoperable!• Web Services Interoperability

Organisation (http://www.ws-i.org)• WS-I Testing Tools

Page 22: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 22

Emerging technologies

• Attachments:– DIME vs. MTOM (http://www.w3.org/TR/soap12-mtom)

• Security:– WS-Security

(http://www-106.ibm.com/developerworks/webservices/library/ws-secure)

– WSS4J?

• State:– WSRF (http://www.globus.org/wsrf)

• Asynchronous:– WS-CAF (http://www.arjuna.com/standards/ws-caf”)– WSRF

Page 23: 14 Sep 2004 NVO Summer School1 Introduction to Web Services Technology Matthew J. Graham CACR/Caltech T HE US N ATIONAL V IRTUAL O BSERVATORY

14 Sep 2004

NVO Summer School 23

Conclusions

• Make sure a web service is the best solution to an application requirement

• Focus on the WSDL• Use your favourite language and

platform• Interoperability is a great idea• Be aware of emerging and converging

technologies