Slideshow transcript
Slide 1: Web Services Michael Weiss Carleton University Web site for this tutorial: www.scs.carleton.ca/~weiss/talks/mcetech06
Slide 2: About Me • PhD (1993), U of Mannheim • Member of Strategic Technology Group, Mitel (1994-1999) • Assistant Professor, Carleton U (since 2000) • Areas of work: service-oriented architecture, feature interaction, patterns, business models, open source Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 2
Slide 3: Topics Covered • Service-Oriented Architecture • Core standards (WSDL, SOAP, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 3
Slide 4: Web Services • What are web services? In essence, a technology for application integration based on open standards (HTTP, XML) • In what sense are they related to the Web (capital “W” to refer to the WWW)? • In fact, deploying web services over the web is more of an artefact than a necessity ... • What we care about is the web of services (services assembled from other services) Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 4
Slide 5: Application Integration User Portal Bus Applications Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 5
Slide 6: Defining Web Service • Loosely coupled, document-based • Application functionality packaged as a single unit and exposed to the network • Authentication service • Flight departure monitoring service • Mobile payment service • The first generation of web services were “simple”, in the sense of non-composite, and closed (over existing, trusted relationships) Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 6
Slide 7: Second Generation Services • Complex, and aggregated from web services provided by third parties (hence, open) Service Shipping Organizational <<uses>> Boundaries Print Shipping Rate Quotes Labels Duty and Transit Times Taxation Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 7
Slide 8: Web of Services Service user • In second generation Service provider services, applications are assembled from Composite services dynamically services • Roles of service user and provider blend into what others call Servent servents (eg in P2P) Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 8
Slide 9: Vision • Build your applications on demand • Dynamically discover and orchestrate the execution of services on the network • Will be able to choose between alternative implementations of the same service Application s ic Interface nt a m Se Implementation Services Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 9
Slide 10: Service-Oriented Architecture • Objectives • Implementation transparency (common structure, neutral service description) • Location transparency (no hard binding, web-service agnostic interfaces) • Roles • Service Provider • Service User • Service Registry Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 10
Slide 11: Service-Oriented Architecture UDDI Service Service Registry Registry Describe + Publish Find Service Service Service Service WSDL SOAP Provider Provider User User Bind + Invoke Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 11
Slide 12: Web Services Layers Application Services Application Services (transaction - eg ticket purchase, information - eg tourist guide) (transaction - eg ticket purchase, information - eg tourist guide) Collaboration Services Collaboration Services (orchestration, matchmaking, translation) (orchestration, matchmaking, translation) Utility Services Utility Services (security, billing, QoS, metering, routing, transactions, messaging) (security, billing, QoS, metering, routing, transactions, messaging) SOAP, WSDL, UDDI SOAP, WSDL, UDDI XML, HTTP XML, HTTP Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 12
Slide 13: Topics Covered • Service-Oriented Architecture • Core standards (SOAP, WSDL, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 13
Slide 14: SOAP • Simple Object Access Protocol • Cross-platform remote calls (de facto, while technically also document exchange) • Remote calls (typically) using HTTP as the transport and XML as the encoding • Designed to be as simple as possible, so to make it easily understood and adopted • But also complete enough to allow complex data structures to be transmitted Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 14
Slide 15: SOAP Messages • SOAP messages are XML documents usually sent over HTTP with a certain format Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 15
Slide 16: SOAP Messages • Components of a SOAP message optional required (one) 1+ required (one or more) Envelope Body Header Payload Fault Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 16
Slide 17: SOAP Containers • Container accepts incoming requests and dispatches them to the service • Translates between SOAP and the native language of the service (Java, C#, ...) • Clients only need to know the address of the service, and messages it understands, but not what language, platform, or location Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 17
Slide 18: SOAP Containers Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 18
Slide 19: Binding to a Service • Clients get address and messages from a WSDL description of the service Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 19
Slide 20: Client Proxy • The binding process (dynamically) returns a proxy to the remote web service Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 20
Slide 21: WSDL • Web Service Description Language • Neutral format for services to advertise themselves on the network • In future, we can choose between competing providers of same service (price, ...) • Components of a WSDL description • Service > Ports > Operations > Messages • Generating a WSDL description Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 21
Slide 22: WSDL Decription • Components of a web service description optional Description required (one) 1+ required (one or more) 1+ 1+ 1+ 1+ Type Message Port Type Binding Service 1+ 1+ Operation Protocol Style Port Request Response Binding Endpoint Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 22
Slide 23: Interface • Consider the interface for a Caching service that allows users to cache content Caching findInCache cache public String findInCache(String key); public void cache(String key, String content) Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 23
Slide 24: Messages <wsdl:message name=\"findInCacheRequest\"> <wsdl:part name=\"key\" type=\"soapenc:string\"/> </wsdl:message> <wsdl:message name=\"findInCacheResponse\"> <wsdl:part name=\"result\" type=\"soapenc:string\"/> </wsdl:message> <wsdl:message name=\"cacheRequest\"> <wsdl:part name=\"key\" type=\"soapenc:string\"/> <wsdl:part name=\"content\" type=\"soapenc:string\"/> </wsdl:message> <wsdl:message name=\"cacheResponse\"/> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 24
Slide 25: Port Type <wsdl:portType name=\"Caching\"> • Port Type <wsdl:operation name=\"cache\" parameterOrder=\"key content\"> <wsdl:input name=\"cacheRequest\" message=\"impl:cacheRequest\"/> <wsdl:output name=\"cacheResponse\" message=\"impl:cacheResponse\"/> </wsdl:operation> <wsdl:operation name=\"findInCache\" parameterOrder=\"key\"> <wsdl:input name=\"findInCacheRequest\" message=\"impl:findInCacheRequest\"/> <wsdl:output name=\"findInCacheResponse\" message=\"impl:findInCacheResponse\"/> </wsdl:operation> </wsdl:portType> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 25
Slide 26: Service Binding <wsdl:binding name=\"CachingSoapBinding\" type=\"impl:Caching\"> <wsdlsoap:binding style=\"rpc\" • Port Type transport=\"http://schemas.xmlsoap.org/soap/http\"/> <wsdl:operation name=\"cache\"> <wsdlsoap:operation soapAction=\"\"/> <wsdl:input name=\"cacheRequest\"> <wsdlsoap:body use=\"encoded\" encodingStyle=\"http:// schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:Cache\"/> </wsdl:input> <wsdl:output name=\"cacheResponse\"> <wsdlsoap:body use=\"encoded\" encodingStyle=\"http:// schemas.xmlsoap.org/soap/encoding/\" namespace=\"urn:Cache\"/> </wsdl:output> </wsdl:operation> <!-- SAME FOR findCache operation --> </wsdl:binding> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 26
Slide 27: Service • Service ties it all together: it defines one or more ports, with binding and endpoint <wsdl:service name=\"CachingService\"> <wsdl:port name=\"Caching\" binding=\"impl:CachingSoapBinding\"> <wsdlsoap:address location= \"http://localhost:9090/axis/services/Caching\"/> </wsdl:port> </wsdl:service> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 27
Slide 28: UDDI • Universal Discovery and Directory Interface • Service discovery protocol • Kind of yellow pages which allows applications to obtain information about businesses and their web services • Helps potential business partners to find each others’ business services • A system will have some kind of directory, but not always need all UDDI features Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 28
Slide 29: Service Directory • A service directory allows publishers to publish information about their services, and users to locate them (and receive updates) User Directory Service Information publish delete update locate: ServiceInformation Service subscribe Provider Implementation Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 29
Slide 30: UDDI Structure • UDDI stores service information in the form of business entities, business services, binding templates and technical models Binding Technical Template Model 0,,* 0,,* 0,,* 0,,* Business Business 0,,* Entity Service Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 30
Slide 31: Topics Covered • Service-Oriented Architecture • Core standards (WSDL, SOAP, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 31
Slide 32: 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 • A detailed discussion of its architecture can be found at http://ws.apache.org/axis Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 32
Slide 33: Apache Axis Architecture Tomcat Servlet Container Web Service 1 Apache Client Web Axis Service 2 Servlet Web Service 3 Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 33
Slide 34: Architecture Adapter • Frameworks such as Apache Axis allow you to be fully web service-agnostic: to access web services from Java use method calls via architecture adapters (eg Java2WS) Java B eg .Net Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 34
Slide 35: Step by Step Guide to Axis 1. Provide a Java interface or class that describes the service interface 2. Create WSDL using Java2WSDL tool 3. Create bindings through WSDL2Java tool 4. Implement the service interface 5. Deploy the service 6. Implement clients using generated stubs Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 35
Slide 36: Axis Artefacts and Flow Service Interface Java2WSDL WSDL WSDL2Java WSDL2Java (optional) Client-side files Server-side files Service Service Service Service Service Service Interface Locator Stub Skeleton Binding WSDD WSDD Deploy Undeploy User- Generated defined Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 36
Slide 37: Provide a Java Interface • Define the functionality you want to expose 1 as a web service using an interface package cache; public interface Caching { public String findInCache(String key); public void cache(String key, String content) } Caching findInCache cache Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 37
Slide 38: Interface Segregation • Achieve greater coherence by limiting your interfaces to related methods • Implement multiple ports in one service Retrieval ContentProvider Billing Retrieval Billing retrieveArticle processBilling Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 38
Slide 39: Create WSDL from Java • Create the WSDL (Caching.wsdl) from the 2 Java interface defined earlier • -o name of output file • -l location of web service • -n target namespace of the WSDL document • -p mapping of namespace to packages step2.sh java org.apache.axis.wsdl.Java2WSDL -o \"cache/Caching.wsdl\" -l \"http://localhost:8080/axis/services/Caching\" -n \"urn:Cache\" -p\"cache\" \"urn:Cache\" cache.Caching Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 39
Slide 40: Create WSDL from Java • Conversion to WSDL will also generate XML types (using XML Schema) for all non- primitive types references in the interface • Supports bean classes, enumeration classes, arrays, and holder classes (inout) • No types in this simple example, but a more complex one will be presented later Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 40
Slide 41: Create Bindings from WSDL • While we can create our SOAP messages to 3 invoke a service at runtime (more later), ... • ... it is generally better to use WSDL2Java to convert a WSDL file into Java stubs Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 41
Slide 42: Create Bindings from WSDL • Create a (static) client-side architecture adapter using the WSDL2Java tool • -o name of output file • -N mapping of namespace to target package • Adapter classes created • public interface CachingService • public class CachingServiceLocator step3.sh java org.apache.axis.wsdl.WSDL2Java -o . \\ -Nurn:Cache cache.stubs cache/Caching.wsdl Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 42
Slide 43: Implement Service Interface • Implement the service by implementing the 4 interface Caching public class Cache implements Caching { protected LinkedHashMap cache = LinkedHashMap(100); public String findInCache(String key) { return (String) cache.get(key); } public void cache(String key, String content) { cache.put(key, content); } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 43
Slide 44: Interface-Implementation Separation • Separating interface from implementation is a core element of loose coupling Caching Client findInCache cache Dependency Inversion Principle Cache findInCache cache Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 44
Slide 45: Deploy the Service • In a Web Service Deployment Descriptor 5 (WSDD) tell Axis how to route requests to the correct target (service) class <deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" xmlns: java=\"http://xml.apache.org/axis/wsdd/providers/java\"> <service name=\"Caching\" provider=\"java:RPC\"> <parameter name=\"className\" value=\"cache.Cache\"/> <parameter name=\"scope\" value=\"Application\"/> <parameter name=\"allowedMethods\" value=\"findInCache cache\"/> </service> </deployment> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 45
Slide 46: Start the Axis Server • If the Axis engine is not running start it: • as a servlet from within a servlet engine (eg Tomcat): code in webapps/axis • or as a standalone server (here ... and for testing and simple applications) • Invoking the standalone SimpleAxisServer java org.apache.axis.transport.http.SimpleAxisServer \\ -p 9090 axis.sh Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 46
Slide 47: AdminClient • Make the service available to clients by deploying it using the AdminClient • If deploying to the standalone Axis server, also supply the port number admin.sh > java org.apache.axis.client.AdminClient \\ -p 9090 deploy.wsdd Processing file cache/deploy.wsdd <Admin>Done processing</Admin> • Now we are ready to invoke the service Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 47
Slide 48: Create the Client • There are two ways to invoke a service 5 • Dynamic client:atcreate a Call object for each method runtime • Static client: generate a static proxy from the WSDL description Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 48
Slide 49: Dynamic Client public class DirectCachingClient { public static void main(String[] args) { try { String endpoint = \"http://localhost:9090/axis/services/Caching\"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperation(\"findCache\"); call.setReturnType(XMLType.XSD_STRING); String ret = (String) call.invoke( new String[] {\"theAnswer\"}); System.out.println(\"Received: \" + ret); } catch (Exception e) { System.err.println(\"Exception: \" + e); } } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 49
Slide 50: Static Client public class CachingClient { public static void main(String[] args) { try { CachingService service = new CachingServiceLocator(); Caching port = service.getCaching(); // to access the service at a different endpoint: // Caching port = service.getCaching(url); String answer = port.findInCache(\"theAnswer\"); if (answer == null) { port.cache(\"theAnswer\", \"42\"); } answer = port.findInCache(\"theAnswer\"); System.out.println(answer); } catch (Exception e) { System.err.println(\"Exception: \" + e); } } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 50
Slide 51: Setting up Axis • Download Apache Axis from website • http://ws.apache.org/axis • Latest stable release is axis-bin-1_4.zip • Install in a directory and put the .jar files in the axis/lib directory into your class path • In my Unix shell, I would say set AXIS_HOME=\"$home/axis\" set CLASSPATH=\"${CLASSPATH}:$AXIS_HOME/lib/axis-ant.jar\" set CLASSPATH=\"${CLASSPATH}:$AXIS_HOME/lib/axis.jar\" ... Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 51
Slide 52: http://ws.apache.org/axis/java/user-guide.html Axis User Guide for more information Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 52
Slide 53: Case Study: Bookstore • As a larger example, consider an application for ordering books from multiple stores • This application needs to provide a portal through which users can place orders • It invokes the (different?) order processing services provided by the bookstores • First, the big picture ... Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 53
Slide 54: Actors and Interactions 1 Invoke 4 Client Stubs WSDL Repository/ Portal UDDI Registry 2 Actual OrderProcessing 5 calls OrderProcessing Stub 1 OrderProcessing Stub 1 WSDL 1 Stub(s) Axis Engine Deploy 3 Bookstore Bookstore Bookstore 2 3 1 Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 54
Slide 55: Interface • The bookstore exposes an OrderProcessing interface through which to place orders • Orders can also be canceled given their OID OrderProcessing Bookstore processOrder cancel public interface OrderProcessing { public String processOrder(String customer, String[] isbns, int[] quantities); public void cancel(String oid); } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 55
Slide 56: WSDL and Stubs • Generate the WSDL from the interface step2.sh bookstore_v1 OrderProcessing Bookstore \\ bookstore_v1 OrderProcessing.wsdl • Generate client stubs from the WSDL step3.sh bookstore_v1 OrderProcessing Bookstore \\ bookstore_v1.stubs OrderProcessingServiceLocator OrderProcessingService OrderProcessing OrderProcessingStub Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 56
Slide 57: Service (1) • Much of the following code is stubbed out, as it is not related to web services public class Bookstore implements OrderProcessing { // ... public String processOrder(String customer, String[] isbns, int quantities[]) { String oid = generateOid(); Order order = new Order(customer, isbns, quantities); orders.put(oid, order); // do whatever else to initiate payment processing // and shipping (not shown ...) return oid; } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 57
Slide 58: Service (2) • And to finish off ... // ... public void cancel(String oid) { Order o = (Order) orders.get(oid); if (o != null) { orders.remove(oid); // do whatever is needed to cancel the order } } private String generateOid() { return \"o\" + nextOid++; } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 58
Slide 59: Deploy the Service • Deployment descriptor for the bookstore is similar to that for the Caching service <deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\"> <service name=\"OrderProcessing\" provider=\"java:RPC\"> <parameter name=\"className\" value=\"bookstore_v1.Bookstore\"/> <parameter name=\"scope\" value=\"Application\"/> <parameter name=\"allowedMethods\" value=\"processOrder cancel\"/> </service> </deployment> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 59
Slide 60: Client public class BookstoreClient { public static void main(String[] args) { try { OrderProcessingService service = new OrderProcessingServiceLocator(); OrderProcessing port = service.getOrderProcessing(); String oid = port.processOrder(\"joe@doe.com\", new String[] {\"123456\", \"732541\"}, new int[] {2, 1}); System.out.println(\"order \" + oid + \" placed\"); port.cancel(oid); System.out.println(\"order \" + oid + \" canceled\"); } catch (Exception e) { System.err.println(\"Exception: \" + e); } } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 60
Slide 61: Topics Covered • Service-Oriented Architecture • Core standards (WSDL, SOAP, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 61
Slide 62: Business Objects • Represent highly cohesive business concepts such as order, line item, or address • Also known as data objects or beans, ie they only contain data access operations • Business objects often collected in groups • But rich object structures are in conflict with the flat nature of web services • Focus of web services on loose coupling, so unlike CORBA or RMI no OO focus Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 62
Slide 63: Taking Orders now! • Business objects can contain primitive and complex data as in the Order example Order LineItem customer: String isbn: String lineItems: LineItem[] quantity: int * setIsbn setCustomer getCustomer: String getIsbn: String setLineItems setQuantity getLineItems: LineItem[] getQuantity: int Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 63
Slide 64: Data Mapping to XML • Basic mapping defined by JAX-RPC spec • Mapping of primitive types • Complex types that follow the JavaBeans convention (BeanSerializer) • Arrays and some Collection types • Exceptions • Key consideration is the interoperability between SOAP implementations ! Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 64
Slide 65: Mapping of Primitive Types • Primitive types defined in standard SOAP encoding Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 65
Slide 66: Complex Types • Axis can serialize and deserialize any classes that follow the JavaBeans convention ... • ... without requiring you to write any code ! • Simple properties • setAddress and getAddress • Indexed properties (arrays of values) • Customer[] • setCustomers and getCustomers Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 66
Slide 67: Bean Mapping • Need to define a bean mapping in WSDD by adding a <beanMapping> tag <beanMapping qname=\"ns:Order\" xmlns:ns=\"urn:Bookstore\" languageSpecificType=\"java:bookstore_v2.Order\"/> • Maps a Java bean to an XML qualified name (qname) associated with a namespace Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 67
Slide 68: Orders in XML • XML schema for the Order type <complexType name=\"Order\"> <sequence> <element name=\"customer\" type=\"soapenc:string\" .../> <element name=\"lineItems\" type=\"impl:ArrayOfLineItem\" .../> </sequence> </complexType> <complexType name=\"LineItem\"> <sequence> <element name=\"isbn\" type=\"soapenc:string\" .../> <element name=\"quantity\" type=\"xsd:int\" .../> </sequence> </complexType> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 68
Slide 69: Order (simple) • The Java Beans convention distinguishes simple and indexed properties public class Order { protected String customer; public String getCustomer() { return customer; } public void setCustomer(String customer) { this.customer = customer; } // ... Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 69
Slide 70: Order (indexed) • In the Order class, line items are indexed // ... private LineItem[] lineItems; public LineItem[] getLineItems() { return lineItems; } public void setLineItems(LineItem[] lineItems) { this.lineItems = lineItems; } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 70
Slide 71: Arrays and Collections • Some Java collections (Vector, Hashtable, ...) have serializers, but interoperability between SOAP implementations in not guaranteed • Most reliable way, thus, is to use arrays <complexType name=\"ArrayOfLineItem\"> <complexContent> <restriction base=\"soapenc:Array\"> <attribute ref=\"soapenc:arrayType\" wsdl:arrayType=\"impl:LineItem[]\"/> </restriction> </complexContent> </complexType> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 71
Slide 72: Bookstore • New interface to our bookstore that uses business objects (ie Order) public class Bookstore implements OrderProcessing { // ... public String processOrder(Order order) { String oid = generateOid(); orders.put(oid, order); // do whatever else to initiate payment processing // and shipping (not shown ...) return oid; } // ... } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 72
Slide 73: Bookstore Client public class BookstoreClient { public static void main(String[] args) { try { OrderProcessingService service = new OrderProcessingServiceLocator(); OrderProcessing port = service.getOrderProcessing(); Order order = new Order(\"joe@doe.com\", new LineItem[] { new LineItem(\"123456\", 2), new LineItem(\"732541\", 1) }); String oid = port.processOrder(order); System.out.println(\"order \" + oid + \" placed\"); port.cancel(oid); System.out.println(\"order \" + oid + \" canceled\"); } catch (Exception e) { System.err.println(\"Exception: \" + e); } } } Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 73
Slide 74: WSDD for Bookstore • Define complex types on which the service implementation relies in the WSDD • namespace (urn:Bookstore) • serializers (beanMapping to ns:Order) <deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\"> <service name=\"OrderProcessing\" provider=\"java:RPC\"> <parameter name=\"className\" value=\"bookstore_v2.Bookstore\"/> <parameter name=\"allowedMethods\" value=\"processOrder cancel\"/> <beanMapping qname=\"ns:Order\" xmlns:ns=\"urn:Bookstore\" languageSpecificType=\"java:bookstore_v2.Order\"/> <beanMapping qname=\"ns:LineItem\" xmlns:ns=\"urn:Bookstore\" languageSpecificType=\"java:bookstore_v2.LineItem\"/> </service> </deployment> Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 74
Slide 75: Topics Covered • Service-Oriented Architecture • Core standards (WSDL, SOAP, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 75
Slide 76: Business Processes • Means by which one or more activities are accomplished in an operating business • Business process models include • Roles of users • Definition of activities • Can be represented diagrammatically as as activity diagrams, use case maps, ... • Concerned with structure and interfaces Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 76
Slide 77: Business Process Components • Business processes model business operation, vs business objects which model (data) entities within a business • Purely look at a business from the aspect of the activities the business conducts • Activities can be composed into larger business processes, and may be business processes themselves, or web services • We are concerned with composition Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 77
Slide 78: Ordering Process Customer Store Select Products to Order Enter Customer Information Submit Product Create Order Order Remove from Warehouse Receive Ship Products Products Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 78
Slide 79: Business Processes in Practice • Business process concepts overlap with existing architectures and styles • The tended to be part of the custom logic outside the business object model • Business process implementations differ largely between organizations • Large business processes often span multiple companies (need to integrate processes) • Motivates need to support fluidity Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 79
Slide 80: Business Process Modeling • Several standards for modeling and representing business processes • Business Process Execution Language (BPEL) • IBM, Microsoft, BEA • Business Process Modeling Language (BPML) • XML-based explicit representation of business process flow model Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 80
Slide 81: Marginalized Objects • We have discussed this before ... • Applied to business processes this means that business processes require a flat component model with interface definition and implementation • Each interface is implemented as the composition of web services • Also applied to flow logic by moving it out from the programming language (BPEL !) Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 81
Slide 82: Process Logic in BPEL BPEL Container invoke() receive() reply() Client Web Service businessProcess() wait() terminate() sequence() pick() flow() BPEL Flows Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 82
Slide 83: Business Process Pattern <<interface>> BusinessActivity run() Data BusinessActivityImpl <<interface>> ActivitySequence get() run() next() BusinessProcess run() set() get() BusinessProcessImpl run() Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 83
Slide 84: Participants • BusinessProcess • Interface to the business process • BusinessProcessImpl • Logic of the business process, which can be a simple ActivitySequence • ActivitySequence • Sequence of business activities that must occur before process is complete Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 84
Slide 85: More Participants • Data • Captures side effects of business activities (in this pattern: a shared data pool) • BusinessActivity • Unit of work in the business process, which may itself be a process, a service, or just a single method on an object Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 85
Slide 86: Ordering Process • Customer submits an order • Business process puts order into data pool • ... determines if products exist (success) in warehouse, and reserves them • ... checks state of data pool and launches create order business activity • ... notifies warehouse staff to ship • ... returns an order identifier to the user Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 86
Slide 87: Product Order Process <<interface>> BusinessActivity setData() run() isComplete() getReturnValue() isSuccessful() CreateOrder ActivitySequence RemoveProduct ShipProducts BusinessProcess run() next() run() run() Quantity run() get() Hashtable ProductOrderImpl createProductOrder() run() ProductOrderWeb Service createProductOrder() Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 87
Slide 88: Topics Covered • Service-Oriented Architecture • Core standards (WSDL, SOAP, UDDI) • Creating, deploying, and invoking web services with Apache Axis • Data mapping and business objects • Service composition • A look at some advanced issues Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 88
Slide 89: Advanced Issues Mobile Services Workflows QoS/Policy Web Services Semantics Security Coordination Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 89
Slide 90: Convergence Desktops 1990's Client-Server N-Tier Distributed Objects P2P Social Computing 2000's } Grids Utility } Semantic Grid Web services Semantic Web Agents } Spaces Coordination Media MirrorWorld Embedded Networks Ubiquitous Computing 20??'s Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 90
Slide 91: Summary • Concepts • Service-oriented architecture, core standards, data mapping, and business processes • Principles • Interface/implementation separation, top-down/ bottom-up design, interface segregation, ... • Patterns • SOA, Architecture Adapter, Service Directory, Business Object, Service Composition • Tools • Apache Axis Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 91
Slide 92: Further Reading • Taylor, From P2P to Web Services and Grids: Peers in a Client/Server World, Springer • Monday, Web Service Patterns, APress • Pashtan, Mobile Web Services, Cambridge • Sotomayor, Globus Toolkit 4: Programming Java Services, Morgan Kaufmann • Papazoglou, Web Services and Cross Enterprise Computing, Addison-Wesley Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 92




Add a comment on Slide 1
If you have a SlideShare account, login to comment; else you can comment as a guest- Favorites & Groups
Showing 1-50 of 6 (more)