Web services

11,931 views

Published on

A pattern-based introduction to web services. Covers core web service standards, the Axis framework, data mapping and service composition.

Published in: Business, Technology
1 Comment
29 Likes
Statistics
Notes
  • web services
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
11,931
On SlideShare
0
From Embeds
0
Number of Embeds
523
Actions
Shares
0
Downloads
1,884
Comments
1
Likes
29
Embeds 0
No embeds

No notes for slide

Web services

  1. 1. Web Services Michael Weiss Carleton University Web site for this tutorial: www.scs.carleton.ca/~weiss/talks/mcetech06
  2. 2. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 2
  3. 3. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 3
  4. 4. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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) 4
  5. 5. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Application Integration 5 Bus Portal Applications User
  6. 6. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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) 6
  7. 7. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Second Generation Services • Complex, and aggregated from web services provided by third parties (hence, open) 7 Rate Quotes Transit Times Duty and Taxation Print Shipping Labels Shipping <<uses>> Organizational Boundaries Service
  8. 8. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Web of Services • In second generation services, applications are assembled from services dynamically • Roles of service user and provider blend into what others call servents (eg in P2P) Service user Service provider Composite services 8 Servent
  9. 9. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Vision • Build your applications • Dynamically discover and orchestrate the execution of services on the network • Will be able to choose between alternative implementations of the same service Application Services Implementation Interface 9 Semantics on demand
  10. 10. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 10
  11. 11. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service-Oriented Architecture 11 Service User Service User Service Registry Service Registry Service Provider Service Provider Find Bind + Invoke Describe + Publish UDDI WSDLSOAP
  12. 12. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Web Services Layers 12 Application Services (transaction - eg ticket purchase, information - eg tourist guide) Application ServicesApplication Services ((transactiontransaction -- egeg ticket purchase,ticket purchase, informationinformation -- egeg tourist guide)tourist guide) SOAP, WSDL, UDDISOAP, WSDL, UDDISOAP, WSDL, UDDI XML, HTTPXML, HTTPXML, HTTP Collaboration Services (orchestration, matchmaking, translation) Collaboration ServicesCollaboration Services (orchestration, matchmaking, translation)(orchestration, matchmaking, translation) Utility Services (security, billing, QoS, metering, routing, transactions, messaging) Utility ServicesUtility Services (security, billing,(security, billing, QoSQoS, metering, routing, transactions, messaging), metering, routing, transactions, messaging)
  13. 13. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 13
  14. 14. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 14
  15. 15. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 SOAP Messages • SOAP messages are XML documents usually sent over HTTP with a certain format 15
  16. 16. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 SOAP Messages • Components of a SOAP message 16 Envelope Header Body Payload Fault 1+ optional required (one) required (one or more)
  17. 17. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 17
  18. 18. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 SOAP Containers 18
  19. 19. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Binding to a Service • Clients get address and messages from a WSDL description of the service 19
  20. 20. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Client Proxy • The binding process (dynamically) returns a proxy to the remote web service 20
  21. 21. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 21
  22. 22. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 WSDL Decription • Components of a web service description 22 Description Type 1+ Message 1+ Port Type 1+ Operation 1+ Binding Style 1+ Service Protocol Port 1+ Binding EndpointRequest Response 1+ optional required (one) required (one or more)
  23. 23. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Interface • Consider the interface for a Caching service that allows users to cache content 23 public String findInCache(String key); public void cache(String key, String content) Caching findInCache cache
  24. 24. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Messages 24 <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"/>
  25. 25. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Port Type • Port Type 25 <wsdl:portType name="Caching"> <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>
  26. 26. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service Binding • Port Type 26 <wsdl:binding name="CachingSoapBinding" type="impl:Caching"> <wsdlsoap:binding style="rpc" 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>
  27. 27. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service • Service ties it all together: it defines one or more ports, with binding and endpoint 27 <wsdl:service name="CachingService"> <wsdl:port name="Caching" binding="impl:CachingSoapBinding"> <wsdlsoap:address location= "http://localhost:9090/axis/services/Caching"/> </wsdl:port> </wsdl:service>
  28. 28. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 28
  29. 29. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service Directory • A service directory allows publishers to publish information about their services, and users to locate them (and receive updates) 29 User Provider Directory publish delete update locate: ServiceInformation subscribe Service Information Service Implementation
  30. 30. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 UDDI Structure • UDDI stores service information in the form of business entities, business services, binding templates and technical models 30 Business Entity 0,,* Business Service Binding Template 0,,* 0,,* Technical Model 0,,*0,,*
  31. 31. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 31
  32. 32. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 32
  33. 33. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Apache Axis Architecture 33 Tomcat Servlet Container Apache Axis Servlet Web Service 1 Web Service 2 Web Service 3 Client
  34. 34. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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) 34 Java B eg .Net
  35. 35. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 35
  36. 36. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Axis Artefacts and Flow 36 Service Interface WSDL Java2WSDL Service Interface Service Locator Service Stub WSDL2Java Client-side files Server-side files WSDD Deploy Service Binding Service Skeleton Service WSDD Undeploy WSDL2Java (optional) Generated User- defined
  37. 37. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Provide a Java Interface • Define the functionality you want to expose as a web service using an interface package cache; public interface Caching { public String findInCache(String key); public void cache(String key, String content) } 37 Caching findInCache cache 1
  38. 38. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Interface Segregation • Achieve greater coherence by limiting your interfaces to related methods • Implement multiple ports in one service 38 ContentProviderRetrieval Billing Billing processBilling Retrieval retrieveArticle
  39. 39. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Create WSDL from Java • Create the WSDL (Caching.wsdl) from the 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 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 39 2 step2.sh
  40. 40. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 40
  41. 41. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Create Bindings from WSDL • While we can create our SOAP messages to invoke a service at runtime (more later), ... • ... it is generally better to use WSDL2Java to convert a WSDL file into Java stubs 41 3
  42. 42. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 java org.apache.axis.wsdl.WSDL2Java -o . -Nurn:Cache cache.stubs cache/Caching.wsdl 42 step3.sh
  43. 43. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Implement Service Interface • Implement the service by implementing the Caching interface 43 4 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); } }
  44. 44. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 • Separating interface from implementation is a core element of loose coupling Cache findInCache cache Caching findInCache cache Client Interface-Implementation Separation 44 Dependency Inversion Principle
  45. 45. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Deploy the Service • In a Web Service Deployment Descriptor (WSDD) tell Axis how to route requests to the correct target (service) class 45 5 <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>
  46. 46. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 46 java org.apache.axis.transport.http.SimpleAxisServer -p 9090 axis.sh
  47. 47. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 • Now we are ready to invoke the service 47 > java org.apache.axis.client.AdminClient -p 9090 deploy.wsdd Processing file cache/deploy.wsdd <Admin>Done processing</Admin> admin.sh
  48. 48. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Create the Client • There are two ways to invoke a service • Dynamic client: create a Call object for each method at runtime • Static client: generate a static proxy from the WSDL description 48 5
  49. 49. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Dynamic Client 49 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); } } }
  50. 50. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Static Client 50 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); } } }
  51. 51. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 51 set AXIS_HOME="$home/axis" set CLASSPATH="${CLASSPATH}:$AXIS_HOME/lib/axis-ant.jar" set CLASSPATH="${CLASSPATH}:$AXIS_HOME/lib/axis.jar" ...
  52. 52. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Axis User Guide http://ws.apache.org/axis/java/user-guide.html 52 for more information
  53. 53. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 ... 53
  54. 54. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 WSDL Repository/ UDDI Registry Bookstore 1 Bookstore 2 Bookstore 3 Axis Engine OrderProcessing Stub 1 OrderProcessing Stub 1 WSDL Client Stubs Portal OrderProcessing Stub(s) Deploy Invoke Actual calls 1 1 2 3 4 5 Actors and Interactions 54
  55. 55. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Interface • The bookstore exposes an OrderProcessing interface through which to place orders • Orders can also be canceled given their OID 55 public interface OrderProcessing { public String processOrder(String customer, String[] isbns, int[] quantities); public void cancel(String oid); } Bookstore processOrder cancel OrderProcessing
  56. 56. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 WSDL and Stubs • Generate the WSDL from the interface • Generate client stubs from the WSDL 56 step2.sh bookstore_v1 OrderProcessing Bookstore bookstore_v1 OrderProcessing.wsdl step3.sh bookstore_v1 OrderProcessing Bookstore bookstore_v1.stubs OrderProcessingServiceLocator OrderProcessingService OrderProcessing OrderProcessingStub
  57. 57. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service (1) • Much of the following code is stubbed out, as it is not related to web services 57 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; }
  58. 58. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Service (2) • And to finish off ... 58 // ... 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++; } }
  59. 59. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Deploy the Service • Deployment descriptor for the bookstore is similar to that for the Caching service 59 <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>
  60. 60. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Client 60 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); } } }
  61. 61. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 61
  62. 62. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 62
  63. 63. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Taking Orders now! • Business objects can contain primitive and complex data as in the Order example 63 Order customer: String lineItems: LineItem[] setCustomer getCustomer: String setLineItems getLineItems: LineItem[] LineItem isbn: String quantity: int setIsbn getIsbn: String setQuantity getQuantity: int *
  64. 64. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 ! 64
  65. 65. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Mapping of Primitive Types • Primitive types defined in standard SOAP encoding 65
  66. 66. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 66
  67. 67. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Bean Mapping • Need to define a bean mapping in WSDD by adding a <beanMapping> tag • Maps a Java bean to an XML qualified name (qname) associated with a namespace <beanMapping qname="ns:Order" xmlns:ns="urn:Bookstore" languageSpecificType="java:bookstore_v2.Order"/> 67
  68. 68. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Orders in XML • XML schema for the Order type 68 <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>
  69. 69. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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; } // ... 69
  70. 70. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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; } } 70
  71. 71. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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> 71
  72. 72. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Bookstore • New interface to our bookstore that uses business objects (ie Order) 72 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; } // ... }
  73. 73. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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); } } } 73
  74. 74. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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> 74
  75. 75. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 75
  76. 76. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 76
  77. 77. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 77
  78. 78. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Ordering Process 78 Select Products to Order Enter Customer Information Submit Product Order Create Order Remove from Warehouse Ship ProductsReceive Products Customer Store
  79. 79. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 79
  80. 80. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 80
  81. 81. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 !) 81
  82. 82. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Process Logic in BPEL Client Web Service businessProcess() BPEL Container invoke() receive() reply() wait() terminate() sequence() pick() flow() BPEL Flows 82
  83. 83. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Business Process Pattern <<interface>> BusinessActivity run() BusinessActivityImpl run() <<interface>> BusinessProcess run() ActivitySequence next() get() Data get() set() BusinessProcessImpl run() 83
  84. 84. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 84
  85. 85. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 85
  86. 86. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 86
  87. 87. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Product Order Process <<interface>> BusinessActivity setData() run() isComplete() getReturnValue() isSuccessful() CreateOrder run() RemoveProduct Quantity run() ActivitySequence next() get() ProductOrderImpl createProductOrder() run() ShipProducts run() BusinessProcess run() ProductOrderWeb Service createProductOrder() Hashtable 87
  88. 88. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 88
  89. 89. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Advanced Issues 89 Workflows Mobile Services QoS/Policy Security Coordination Semantics Web Services
  90. 90. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Client-Server Desktops N-Tier Spaces Embedded Networks Agents Web services Grids P2P Distributed Objects } Social Computing Utility Semantic Web Coordination Media } Semantic Grid } MirrorWorld 1990's 2000's 20??'sUbiquitous Computing Convergence 90
  91. 91. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 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 91
  92. 92. Michael Weiss • Montreal Conference on eTechnologies • May 17-19, 2006 Further Reading • Taylor, From P2P toWeb 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 92

×