Distributed Programming in Java - PowerPoint PPT Presentation

1 / 49
About This Presentation
Title:

Distributed Programming in Java

Description:

soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/ operation name='GetLastTradePrice' soap:operation soapAction='http://example. ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 50
Provided by: protonScs
Category:

less

Transcript and Presenter's Notes

Title: Distributed Programming in Java


1
Distributed Programming in Java
  • Web Services (3)

2
WSDL
  • 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

3
The Architectural Models
4
Definitions
  • 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

5
Resoure
  • 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

6
Message 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
7
Message Structure
8
Service 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.
9
Service Structure
10
Resource Oriented Model
focuses on resources that exist and have owners
11
Policy Model
focuses on constraints on the behavior of agents
and services
12
The Architectural Models
13
WSDL Specification
types
message
message
message
operation
operation
operation
binding
service
port
14
Structure of a WSDL Description
15
A Recipe Web Service
  • Ad hoc, RPC-style
  • Recipes getRecipes()
  • Lock lockRecipe(ID)
  • void writeRecipe(Lock,Recipe)
  • void unlockRecipe(Lock)

16
Recipe Server with WSDL and SOAP (1/6)
17
Recipe Server with WSDL and SOAP (2/6)
18
Recipe Server with WSDL and SOAP (3/6)
19
Recipe Server with WSDL and SOAP (4/6)
20
Recipe Server with WSDL and SOAP (5/6)
21
Recipe Server with WSDL and SOAP (6/6)
22
Interface 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

23
RPC 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
  • ...

24
Binding Descriptions
  • Encodings and protocols for an interface
  • Predefined
  • SOAP binding (often using SOAPs HTTP binding)
  • HTTP binding (raw HTTP, no SOAP)

25
SOAP Binding
26
HTTP Binding
27
Service Descriptions
28
Summary of WSDL
  • Description of interfaces of Web services
  • message types
  • operations
  • encodings and communication protocols
  • location

29
Example 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

30
WSDL 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

31
WSDL 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

32
WSDL
http//localhost8004/soap/exchange.wsdl
33
WSDL Messages
Request
Response
34
WSDL Port Type
  • Defines operations offered by a service

35
WSDL Binding
  • How messages will be handled

36
WSDL Service Definition
  • How to access the service (defines port, binding,
    and service URL)

37
Apache 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

38
Axis Engine Architecture
HTTP, JMS, etc.
SOAP, XML-RPC
javaRPC
http//www.enterpriseintegrationpatterns.com/Compo
sedMessagingWS.html
39
Creating a Service
  • Implement the service in a web service agnostic
    manner (as a regular class)

40
Deploying 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

41
Starting 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

42
Deploying 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

43
Create 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

44
Client
45
Appendix
  • This appendix collects information you may find
    useful setting up Apache Axis

46
Installation
  • 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

47
Setting up Axis in Tomcat
  • Axis as a servlet
  • Install axis into thewebapps directory
  • Set up classpath asshown in appendix
  • Services classes inWEB-INF/classes

48
Setting up the Classpath
49
Axis User Guide
http//ws.apache.org/axis/java/user-guide.html
Write a Comment
User Comments (0)
About PowerShow.com