Title: Distributed Programming in Java
1Distributed Programming in Java
2WSDL
- Web Services Description Language interface
description language for Web services - Functionality? (operations, types of arguments)
- Access? (data encoding, communication protocols)
- Location?
- Necessary information for writing clients
- Automatic generation of stubs and skeletons
3The Architectural Models
4Definitions
- A message is the basic unit of data sent from one
Web service agent to another in the context of
Web services - A service description is a set of documents that
describe the interface to and semantics of a
service - A policy is a constraint on the behavior of
agents or people or organizations
5Resoure
- a resource has an identifier
- a resource may have
- zero or more representations
- a resource may have
- zero or more resource descriptions
- a resource is owned by
- a person or organization
- a resource may be governed by
- zero or more policies
6Message Oriented Model
focuses on messages, message structure, message
transport and so on without particular
reference as to the reasons for the messages, nor
to their significance. the agent that sends and
receives messages
7Message Structure
8Service Oriented Model
focuses on aspects of service, action and so on.
While clearly, in any distributed system,
services cannot be adequately realized without
some means of messaging, the converse is not the
case messages do not need to relate to
services A service is realized by an agent and
used by another agent. Services are mediated by
means of the messages exchanged between requester
agents and provider agents.
9Service Structure
10Resource Oriented Model
focuses on resources that exist and have owners
11Policy Model
focuses on constraints on the behavior of agents
and services
12The Architectural Models
13WSDL Specification
types
message
message
message
operation
operation
operation
binding
service
port
14Structure of a WSDL Description
15A Recipe Web Service
- Ad hoc, RPC-style
- Recipes getRecipes()
- Lock lockRecipe(ID)
- void writeRecipe(Lock,Recipe)
- void unlockRecipe(Lock)
16Recipe Server with WSDL and SOAP (1/6)
17Recipe Server with WSDL and SOAP (2/6)
18Recipe Server with WSDL and SOAP (3/6)
19Recipe Server with WSDL and SOAP (4/6)
20Recipe Server with WSDL and SOAP (5/6)
21Recipe Server with WSDL and SOAP (6/6)
22Interface Descriptions
- In-Only one message is received
- Robust In-Only same but a fault may be triggered
- In-Out one message is received followed by one
message being returned (may be a fault message) - In-Optional-Out same but response is optional
- Out-Only one message is sent
- Robust Out-Only same but a faulty may be
triggered - Out-In one message is sent followed by one
message being received (may be a fault message) - Out-Optional-In same but response is optional
23RPC RPC-Style Operations
- Can be used with In-Out, In-Only, Robust In-Only
- Input/output types must describe
- element sequences only
- Wrapper element in request names the operation
- ...
24Binding Descriptions
- Encodings and protocols for an interface
- Predefined
- SOAP binding (often using SOAPs HTTP binding)
- HTTP binding (raw HTTP, no SOAP)
25SOAP Binding
26HTTP Binding
27Service Descriptions
28Summary of WSDL
- Description of interfaces of Web services
- message types
- operations
- encodings and communication protocols
- location
29Example 2- WSDL Types
- lt?xml version"1.0"?gt
- ltdefinitions name"StockQuote" targetNamespace"ht
tp//example.com/stockquote.wsdl"
xmlnstns"http//example.com/stockquote.wsdl"
xmlnsxsd1"http//example.com/stockquote.xsd"
xmlnssoap"http//schemas.xmlsoap.org/wsdl/soap/"
xmlns"http//schemas.xmlsoap.org/wsdl/"gt - lttypesgt
- ltschema targetNamespace"http//example.com/stockq
uote.xsd" xmlns"http//www.w3.org/2000/10/XMLSche
ma"gt - ltelement name"TradePriceRequest"gt
- ltcomplexTypegt ltallgt ltelement name"tickerSymbol"
type"string"/gt lt/allgt - lt/complexTypegt
- lt/elementgt
- ltelement name"TradePrice"gt
- ltcomplexTypegt ltallgt ltelement name"price"
type"float"/gt lt/allgt lt/complexTypegt - lt/elementgt
- lt/schemagt
- lt/typesgt
30WSDL Operations
- ltmessage name"GetLastTradePriceInput"gt
- ltpart name"body" element"xsd1TradePriceReque
st"/gt - lt/messagegt
- ltmessage name"GetLastTradePriceOutput"gt
- ltpart name"body" element"xsd1TradePrice"/gt
- lt/messagegt
- ltportType name"StockQuotePortType"gt
- ltoperation name"GetLastTradePrice"gt
- ltinput message"tnsGetLastTradePriceInput"/gt
- ltoutput message"tnsGetLastTradePric
eOutput"/gt - lt/operationgt
- lt/portTypegt
-
31WSDL Bindings, Services, Ports
- ltbinding name"StockQuoteSoapBinding"
type"tnsStockQuotePortType"gt - ltsoapbinding style"document"
transport"http//schemas.xmlsoap.org/soap/http"/gt
- ltoperation name"GetLastTradePrice"gt
ltsoapoperation soapAction"http//example.com/Get
LastTradePrice"/gt ltinputgt ltsoapbody
use"literal"/gt lt/inputgt ltoutputgt ltsoapbody
use"literal"/gt lt/outputgt - lt/operationgt
- lt/bindinggt
- ltservice name"StockQuoteService"gt
ltdocumentationgtMy first servicelt/documentationgt - ltport name"StockQuotePort" binding"tnsStockQuo
teBinding"gt ltsoapaddress location"http//example
.com/stockquote"/gt lt/portgt - lt/servicegt
- lt/definitionsgt
32WSDL
http//localhost8004/soap/exchange.wsdl
33WSDL Messages
Request
Response
34WSDL Port Type
- Defines operations offered by a service
35WSDL Binding
- How messages will be handled
36WSDL Service Definition
- How to access the service (defines port, binding,
and service URL)
37Apache Axis
- Open source web service framework
- Client programming model of Axis provides
components for client to invoke a service
endpoint and receive the response message - Server programming model based on a listener for
each transport protocol, a set of message
handlers, and service handlers - Let us have a closer look at its architecture
38Axis Engine Architecture
HTTP, JMS, etc.
SOAP, XML-RPC
javaRPC
http//www.enterpriseintegrationpatterns.com/Compo
sedMessagingWS.html
39Creating a Service
- Implement the service in a web service agnostic
manner (as a regular class)
40Deploying the Service
- In Axis you use a Web Service Deployment
Descriptor (WSDD) to tell Axis how to route
requests to the correct target class - SmallCompanyImpl.wsdd
41Starting the Axis Server
- Two options for running Axis
- as a servlet from within a servlet engine (eg
Tomcat) code in webapps/axis - as a standalone server (for testing and simple
applications only) - Invoking the standalone server
42Deploying the Service
- Make the service available to clients by
deploying it using the AdminClient - If deploying to the standalone Axis server, also
supply the port number - Now we are ready to invoke the service
43Create the Client
- Again two options
- Dynamic web service client create a Call object
for each method at runtime - Static web service client generate a proxy from
a WSDL description - First we will use the dynamic option
- Most interesting from the perspective of
understanding low level operation
44Client
45Appendix
- This appendix collects information you may find
useful setting up Apache Axis
46Installation
- Download Apache Axis from website
- http//ws.apache.org/axis/
- Latest stable release is axis-1_4.zip (2006.4)
- Install in a directory and put the jar files in
the axis/lib directory into your classpath - Can also install in Eclipse by adding all jar
files to the Eclipse project - Should also set default output directory to put
compiled classes into webapps/axis
47Setting up Axis in Tomcat
- Axis as a servlet
- Install axis into thewebapps directory
- Set up classpath asshown in appendix
- Services classes inWEB-INF/classes
48Setting up the Classpath
49Axis User Guide
http//ws.apache.org/axis/java/user-guide.html