Title: ???? Web Services and Its Applications
1????Web Services and Its Applications
WSA
Li Yinsheng (021-51355352) Email
liys_at_fudan.edu.cn Institute of e-Business Fudan
University Software School http//eb.fudan.edu.cn
2Case Description
- This cased is produced based on examples by Sun
Microsystems, Inc. - Java WSDP
3Application Architecture
4Business Workflow Scenario
- Coffee Break server uses both JAXM messaging
(request/response model) and JAX-RPC to
communicate with its two distributors - Coffee Break server uses JAXR to send a query
searching for coffee distributors that support
JAX-RPC - Coffee Break server requests price lists from
each of the coffee distributors price list
delivered as JavaBean component (JAX-RPC)
price list delivered as XML document (JAXM)
5Business Workflow Scenario
Business Workflow Scenario
- Coffee Break Server creates a local database of
distributors - When an order is placed, suborders are sent to
one or more distributors using the distributor's
preferred protocol
6Architectural Modules
- JAX-RPC distributor service
- JAXM distributor service
- Web server module
- JAXR registry
7JAX-RPC Distributor Service
- Service interface
- Service implementation
- Service registration
8JAX-RPC Distributor Service
Service Interface
package com.sun.cb import java.rmi.Remote impor
t java.rmi.RemoteException public interface
SupplierIF extends Remote public
ConfirmationBean placeOrder(OrderBean order)
throws RemoteException public PriceListBean
getPriceList() throws RemoteException
9JAX-RPC Distributor Service
Service Implementation
public ConfirmationBean placeOrder(OrderBean
order) Date tomorrow com.sun.cb.DateHelper.add
Days(new Date(), 1) ConfirmationBean
confirmation new ConfirmationBean(order.getId(),
tomorrow) return confirmation public
PriceListBean getPriceList() PriceListBean
priceList loadPrices() return priceList
10JAX-RPC Distributor Service
Service registration using JAXR
public class OrgPublisher public static void
main(String args) ResourceBundle
registryBundle ResourceBundle.getBundle("com.
sun.cb.CoffeeRegistry") String queryURL
registryBundle.getString("query.url") String
publishURL registryBundle.getString("publish.url
") String username registryBundle.getString("r
egistry.username") String password
registryBundle.getString("registry.password")
String endpoint registryBundle.getString("endpo
int") String keyFile registryBundle.getString(
"key.file")
11JAX-RPC Distributor Service
Service registration using JAXR
JAXRPublisher publisher new JAXRPublisher()
publisher.makeConnection(queryURL, publishURL)
String key publisher.executePublish (username,
password, endpoint) try FileWriter out new
FileWriter(keyFile) out.write(key)
out.flush() out.close() catch (IOException
ex) System.out.println(ex.getMessage())
12JAX-RPC Distributor Service
Messaging Model Used
- Uses request/response messaging
- JAXM provider is not used
- Two request/response interactions
- request Requests for current wholesale coffee
prices - response Current price lists
- request Customer orders for coffee
- response Order confirmations
13JAX-RPC Distributor Service
Messages Being Exchanged
- Pre-agreed upon Message formats in DTD's
- request-prices.dtd
- price-list.dtd
- coffee-order.dtd
- confirm.dtd
- Sample Messages
- request-prices.xml
- price-list.xml
- coffee-order.xml
- confirm.xml
14JAX-RPC Distributor Service
JAXM Client
- Creating request message
- Extracting information from the response message
15JAX-RPC Distributor Service
JAXM Service
- Servlet based
- PriceListServlet for price list response
message - ConfirmationServlet for order confirmation
response message
16Web Server Modules
- For creating dynamic contents
- Uses
- Servlet
- JSP
- Template Tag library for common look and feel
- JSTL custom tags
- JavaBeans components
- Contains business logic
- Send requests to web services
- Handles responses from web services message
17Web Server Modules
MVC Pattern
- Coffee break web module is based on MVC pattern
- Dispatch servlet as Controller
- Examines the request URL
- Creates and initializes model JavaBeans
components - Dispatches requests to view JSP pages
18Web Server Modules
JSP Pages and Java Beans
- Update order data
- JSP page orderForm
- JavaBean ShoppingCart
- Update delivery and billing data
- JSP page checkoutForm
- JavaBean CheckoutFormBean
- Display order confirmation
- JSP page checkoutAck
- JavaBean OrderConfirmations
19Web Server Modules
Servlets
- RetailPriceListServlet
- Responds to requests to reload the price list
- Creates a new RetailPriceList and a new
ShoppingCart - Used only by administrator
- Protected resource
- In order to load the price list, a user must
authenticate (using basic authentication) and the
authenticated user must be in the admin role