Presentation is loading. Please wait.

Presentation is loading. Please wait.

课堂讨论 Web Services and Its Applications

Similar presentations


Presentation on theme: "课堂讨论 Web Services and Its Applications"— Presentation transcript:

1 课堂讨论 Web Services and Its Applications
WSA Fall OCT 31, 2007 课堂讨论 Web Services and Its Applications Li Yinsheng ( ) Institute of e-Business Fudan University Software School

2 Case Description This cased is produced based on examples by Sun Microsystems, Inc. Java™ WSDP

3 Application Architecture

4 Business 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)

5 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

6 Architectural Modules
JAX-RPC distributor service JAXM distributor service Web server module JAXR registry

7 JAX-RPC Distributor Service
Service interface Service implementation Service registration

8 JAX-RPC Distributor Service
Service Interface package com.sun.cb; import java.rmi.Remote; import java.rmi.RemoteException; public interface SupplierIF extends Remote { public ConfirmationBean placeOrder(OrderBean order) throws RemoteException; public PriceListBean getPriceList() throws RemoteException; }

9 JAX-RPC Distributor Service
Service Implementation public ConfirmationBean placeOrder(OrderBean order) { Date tomorrow = com.sun.cb.DateHelper.addDays(new Date(), 1); ConfirmationBean confirmation = new ConfirmationBean(order.getId(), tomorrow); return confirmation; } public PriceListBean getPriceList() { PriceListBean priceList = loadPrices(); return priceList;

10 JAX-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("registry.username"); String password = registryBundle.getString("registry.password"); String endpoint = registryBundle.getString("endpoint"); String keyFile = registryBundle.getString("key.file");

11 JAX-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()); } } }

12 JAX-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”

13 JAX-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

14 JAX-RPC Distributor Service
JAXM Client Creating request message Extracting information from the response message

15 JAX-RPC Distributor Service
JAXM Service Servlet based – PriceListServlet for price list response message – ConfirmationServlet for order confirmation response message

16 Web 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

17 Web 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

18 Web 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

19 Web 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


Download ppt "课堂讨论 Web Services and Its Applications"

Similar presentations


Ads by Google