Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

02 a xml_foundations


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

02 a xml_foundations

  1. 1. 95-843: Service Oriented Architecture1Master of Information SystemManagementService OrientedArchitectureWeek 2: TechnicalFoundations
  2. 2. 95-843: Service Oriented Architecture2Master of Information SystemManagementToday’s Topics• Review of EIP and Oracle OSBslides• Discuss Homework 1• XML Schema• XPATH Expressions• WSDL• SOAP• ESB
  3. 3. 95-843: Service Oriented Architecture3Master of Information SystemManagementXML Schema• SOA involves the passing of messagesfrom one process to another. Messagesmay be document style or tightlycoupled RPC style (not in vogue.)• Each process needs to know the overallmessage structure as well as the lowlevel data types.• XML Schema is a W3CRecommendation.
  4. 4. 95-843: Service Oriented Architecture4Master of Information SystemManagementType Systems• Found in many programming languages• Specify a set of values and operations on thosevalues• Classify values and expressions,e.g.,3.0 * 2.4 is of type real• In C, the types are packaged up in header filesand we include them in our code with#include<stdio.h>• In Java, we use the import statement along witha classpath to be searched.• XML Schema is used by web services to describethe types of messages sent and received
  5. 5. 95-843: Service Oriented Architecture5Master of Information SystemManagementPO Example From W3C (1)<?xml version="1.0"?><purchaseOrder orderDate="1999-10-20"><shipTo country="US"><name>Alice Smith</name><street>123 Maple Street</street><city>Mill Valley</city><state>CA</state><zip>90952</zip></shipTo>
  6. 6. 95-843: Service Oriented Architecture6Master of Information SystemManagementPO Example From W3C (2)<billTo country="US"><name>Robert Smith</name><street>8 Oak Avenue</street><city>Old Town</city><state>PA</state><zip>95819</zip></billTo><comment>Hurry, my lawn is going wild<!/comment>
  7. 7. 95-843: Service Oriented Architecture7Master of Information SystemManagementPO Example From W3C (3)<items><item partNum="872-AA"><productName>Lawnmower</productName><quantity>1</quantity><USPrice>148.95</USPrice><comment>Confirm this is electric</comment></item>
  8. 8. 95-843: Service Oriented Architecture8Master of Information SystemManagementPO Example From W3C (4)<item partNum="926-AA"><productName>Baby Monitor</productName><quantity>1</quantity><USPrice>39.98</USPrice><shipDate>1999-05-21</shipDate></item></items></purchaseOrder>
  9. 9. 95-843: Service Oriented Architecture9Master of Information SystemManagementPO Schema Example FromW3C (1)<xsd:schema xmlns:xsd=""><xsd:annotation><xsd:documentation xml:lang="en">Purchase order schema for 2000 All rights reserved.</xsd:documentation></xsd:annotation><xsd:element name="purchaseOrder"type="PurchaseOrderType"/><xsd:element name="comment" type="xsd:string"/>
  10. 10. 95-843: Service Oriented Architecture10Master of Information SystemManagementPO Schema Example FromW3C (2)<xsd:complexType name="PurchaseOrderType"><xsd:sequence><xsd:element name="shipTo" type="USAddress"/><xsd:element name="billTo" type="USAddress"/><xsd:element ref="comment" minOccurs="0"/><xsd:element name="items" type="Items"/></xsd:sequence><xsd:attribute name="orderDate" type="xsd:date"/></xsd:complexType>
  11. 11. 95-843: Service Oriented Architecture11Master of Information SystemManagementPO Schema Example FromW3C (3)<xsd:complexType name="USAddress"><xsd:sequence><xsd:element name="name" type="xsd:string"/><xsd:element name="street" type="xsd:string"/><xsd:element name="city" type="xsd:string"/><xsd:element name="state" type="xsd:string"/><xsd:element name="zip" type="xsd:decimal"/></xsd:sequence><xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/></xsd:complexType>
  12. 12. 95-843: Service Oriented Architecture12Master of Information SystemManagementPO Schema Example FromW3C (4)<xsd:complexType name="Items"><xsd:sequence><xsd:element name="item" minOccurs="0" maxOccurs="unbounded"><xsd:complexType><xsd:sequence><xsd:element name="productName" type="xsd:string"/><xsd:element name="quantity"><xsd:simpleType><xsd:restriction base="xsd:positiveInteger"><xsd:maxExclusive value="100"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name="USPrice" type="xsd:decimal"/><xsd:element ref="comment" minOccurs="0"/><xsd:element name="shipDate" type="xsd:date" minOccurs="0"/></xsd:sequence><xsd:attribute name="partNum" type="SKU" use="required"/></xsd:complexType> </xsd:element></xsd:sequence></xsd:complexType>
  13. 13. 95-843: Service Oriented Architecture13Master of Information SystemManagementPO Schema Example FromW3C (5)<!-- Stock Keeping Unit, a code for identifying products --><xsd:simpleType name="SKU"><xsd:restriction base="xsd:string"><xsd:pattern value="d{3}-[A-Z]{2}"/></xsd:restriction></xsd:simpleType></xsd:schema>
  14. 14. 95-843: Service Oriented Architecture14Master of Information SystemManagementXML SchemaData TypesW3C
  15. 15. 95-843: Service Oriented Architecture15Master of Information SystemManagementXPATH• With XML Schema, we can describemessages with program level specificity.• We still need a general way to addresscomponent parts from these messages.• The primary purpose of XPath is to addressparts of an XML document (W3C).
  16. 16. 95-843: Service Oriented Architecture16Master of Information SystemManagementThe Tree Structure of anXML Document<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" href = "pi.xsl" ?><people><person born="1912" died = "1954" id="p342"><name><first_name>Alan</first_name><last_name>Turing</last_name></name><!-- Did the word "computer scientist" exist in Turings day? --><profession>computer scientist</profession><profession>mathematician</profession><profession>cryptographer</profession></person>See Harold Pg. 147
  17. 17. 95-843: Service Oriented Architecture17Master of Information SystemManagement<person born="1918" died = "1988" id="p4567"><name><first_name>Richard</first_name><middle_initial>M</middle_initial><last_name>Feynman</last_name></name><profession>physicist</profession><hobby>Playing the bongoes</hobby></person></people>Unicode ‘M’
  18. 18. 95-843: Service Oriented Architecture18Master of Information SystemManagement/personborn = “1914”died = “1952”id=“p342”personnamefirst_nameAlan<!– Did the word“computer scientist”exist in Turing’s day?”-- ><?xml-stylesheet type="text/xsl" href = “some.xsl" ?>profession
  19. 19. 95-843: Service Oriented Architecture19Master of Information SystemManagementXPATH• Location Paths such as a/b/c that drilldown into the XML tree• Axes allow us to specify the direction oftravel through the treee.g., child, ancestor, previous-sibling.• Node Tests and predicates allow us toselect parts of the XML based onconditions
  20. 20. 95-843: Service Oriented Architecture20Master of Information SystemManagementXPATH ExamplesThe XPATH expression “//name/last_name/text()” means tosearch from the root to the text under the name/last_nameelements and return that result.The XPATH expression “//profession[.=physicist]/../name”means to search from the root for any profession elementwhose content is physicist and then travel to the parent of theprofession element and select, along the child axis, the nameelement.
  21. 21. 95-843: Service Oriented Architecture21Master of Information SystemManagementWSDL2.0• Web Service Description Language• W3C Recommendation June 2005• Tools are readily available thatautomatically generate WSDL fromexisting applications.• Tools are readily available thatgenerate client side proxy codefrom the WSDL description
  22. 22. 95-843: Service Oriented Architecture22Master of Information SystemManagementWSDL2.0• Two parts to a WSDL document- abstract partWhat needs doneInterfaces and MEPS- concrete partHow it’s done and where
  23. 23. 95-843: Service Oriented Architecture23Master of Information SystemManagementFrom W3C XML Infoset for a WSDL 2.0 document.
  24. 24. 95-843: Service Oriented Architecture24Master of Information SystemManagementKey Abstract WSDLElements (1)<types>XML Schema constructs or theimport of existing XML Schemadocuments<interface>represents service interfacesand can reference multipleoperationsNotes from Erl
  25. 25. 95-843: Service Oriented Architecture25Master of Information SystemManagementKey Abstract WSDLElements(2)<operations>represents web service functionsand can reference multiplemessagesHave inputs and outputs and maygenerate faultsNotes fromErl
  26. 26. 95-843: Service Oriented Architecture26Master of Information SystemManagementKey Concrete WSDLElements(3)<binding>This element specifies the transportand wire formats forinterfaces<service><endpoint>These elements associate themselveswith operation constructs and specifya locationNotes fromErl modifiedFor wsdl 2.0
  27. 27. 95-843: Service Oriented Architecture27Master of Information SystemManagementProblem Description(1)Hotel GreatH (a fictional hotel) is located in a remote island.It has been relying on fax and phone to provide room reservations.Even though the facilities and prices at GreatH are better than whatits competitor offers, GreatH notices that its competitor is gettingmore customers than GreatH. After research, GreatH realizes thatthis is because the competitor offers a Web service that permitstravel agent reservation systems to reserve rooms directly overthe Internet. GreatH then hires us to build a reservation Webservice with the following functionality:From W3C WSDL2.0primer
  28. 28. 95-843: Service Oriented Architecture28Master of Information SystemManagementCheckAvailability. To check availability, the client mustspecify a check-in date, a check-out date, and room type.The Web service will return a room rate (a floating pointnumber in USD$) if such a room is available, or a zeroroom rate if not. If any input data is invalid, the serviceshould return an error. Thus, the service will accept acheckAvailability message and return acheckAvailabilityResponse or invalidDataFault message.Problem Description (2)
  29. 29. 95-843: Service Oriented Architecture29Master of Information SystemManagementMakeReservation. To make a reservation, a client mustprovide a name, address, and credit card information,and the service will return a confirmation number ifthe reservation is successful. The service will returnan error message if the credit card number or anyother data field is invalid.Thus, the service will accept a makeReservation message andreturn a makeReservationResponse or invalidCreditCardFaultmessage.Problem Description (3)
  30. 30. 95-843: Service Oriented Architecture30Master of Information SystemManagementWe know that we will later need to build a complete systemthat supports transactions and secured transmission, butinitially we will implement only minimal functionality.In fact, to simplify our first example, we will implementonly the CheckAvailability operation.Problem Description (4)
  31. 31. 95-843: Service Oriented Architecture31Master of Information SystemManagementHotel WSDL<?xml version="1.0" encoding="utf-8" ?><descriptionxmlns=""targetNamespace= ""xmlns:tns= ""xmlns:ghns = ""xmlns:wsoap= ""xmlns:soap=""xmlns:wsdlx= "">From W3C WSDL2.0primer
  32. 32. 95-843: Service Oriented Architecture32Master of Information SystemManagement<documentation>This document describes the GreatH Web service. Additionalapplication-level requirements for use of this service --beyond what WSDL 2.0 is able to describe -- are availableat</documentation>
  33. 33. 95-843: Service Oriented Architecture33Master of Information SystemManagement<types><xs:schemaxmlns:xs=""targetNamespace=""xmlns=""><xs:element name="checkAvailability"type="tCheckAvailability"/><xs:complexType name="tCheckAvailability"><xs:sequence><xs:element name="checkInDate" type="xs:date"/><xs:element name="checkOutDate" type="xs:date"/><xs:element name="roomType" type="xs:string"/></xs:sequence></xs:complexType>WSDL uses XML Schema.
  34. 34. 95-843: Service Oriented Architecture34Master of Information SystemManagement<xs:element name="checkAvailabilityResponse" type="xs:double"/><xs:element name="invalidDataError" type="xs:string"/></xs:schema></types>
  35. 35. 95-843: Service Oriented Architecture35Master of Information SystemManagement<interface name = "reservationInterface" ><fault name = "invalidDataFault"element = "ghns:invalidDataError"/><operation name="opCheckAvailability"pattern=""style=""wsdlx:safe = "true"><input messageLabel="In"element="ghns:checkAvailability" /><output messageLabel="Out"element="ghns:checkAvailabilityResponse" /><outfault ref="tns:invalidDataFault" messageLabel="Out"/></operation></interface>Operations andfaults are described.Note the Messageexchange patternin-out is specified.
  36. 36. 95-843: Service Oriented Architecture36Master of Information SystemManagement<binding name="reservationSOAPBinding"interface="tns:reservationInterface"type=""wsoap:protocol=""><fault ref="tns:invalidDataFault"wsoap:code="soap:Sender"/><operation ref="tns:opCheckAvailability"wsoap:mep=""/></binding>Above we specified whatgets exchanged now wespecify how.The binding specifiesthe format andtransmissionprotocol for eachoperation in aninterface.
  37. 37. 95-843: Service Oriented Architecture37Master of Information SystemManagement<service name="reservationService"interface="tns:reservationInterface"><endpoint name="reservationEndpoint"binding="tns:reservationSOAPBinding"address =""/></service></description>The above tells us what and how.The service element tells us where.A WSDL 2.0 service specifies a singleinterface that the service will support, and alist of endpoint locations where that servicecan be accessed. Each endpoint must alsoreference a previously defined binding toindicate what protocols and transmissionformats are to be used at that endpoint. From theW3C Primer
  38. 38. 95-843: Service Oriented Architecture38Master of Information SystemManagementWSDL2.0 MessageExchange PatternsIn-only One message received no fault generatedRobust In-only One message received with a possible errorsentIn-out One message received in and one sentout (fault replaces out)In-Optional-Out One message received in with one possiblysent out (fault replaces out)Out-Only One message sent no fault return expectedRobust Out-Only One message sent fault return expectedOut-In One message sent and return expected(fault replaces return)Out-Optional-In One message sent and may receive a return(fault replaces return)
  39. 39. 95-843: Service Oriented Architecture39Master of Information SystemManagementSOAP• Was “Simple Object Access Protocol”• Now people are using “Service OrientedApplication Protocol”• May be fine grained RPC style messages<foo>34</foo> where foo is thename of a method• Or may be course grained documentstyle where the input message is anentire document.
  40. 40. 95-843: Service Oriented Architecture40Master of Information SystemManagementSOAP XML Structure<Envelope><Header> WS-* specifications: are placed in theheader area and will be</Header> handled by intermediaries<Body>: Message payload includingfault messages</Body> as well-formed XML.</Envelope>
  41. 41. 95-843: Service Oriented ArchitectureFigure 1-2. Breakdown of service componentsUnderstanding SOA with Web Services, Eric Newcomer and Greg Lomow, p. 9NET JEECORBA IMSServiceDescriptionsMappingLayersServiceImplementation/Executable AgentServiceRequesterServiceImplementation/Executable AgentServiceImplementation/Executable AgentServiceRequestsThe JEE agent mayprovide a coarsegrained service whilethe legacy servicesmay be fined grained.
  42. 42. 95-843: Service Oriented ArchitectureFigure 1-2. Breakdown of service componentsUnderstanding SOA with Web Services, Eric Newcomer and Greg Lomow, p. 9NET JEECORBA IMSServiceDescriptionsMappingLayersServiceImplementation/Executable AgentServiceRequesterServiceImplementation/Executable AgentServiceImplementation/Executable AgentServiceRequestsWith web service basedSOA we can, for the firsttime, easily mix and matchexecutable agents.
  43. 43. 95-843: Service Oriented ArchitectureFigure 1-2. Breakdown of service componentsUnderstanding SOA with Web Services, Eric Newcomer and Greg Lomow, p. 9NET JEECORBA IMSServiceDescriptionsMappingLayersServiceImplementation/Executable AgentServiceRequesterServiceImplementation/Executable AgentServiceImplementation/Executable AgentServiceRequestsThe mapping layersare stubs and skeletons thattransform the SOAP requeststo requests specific to theexecutable agents.
  44. 44. 95-843: Service Oriented Architecture44Master of Information SystemManagement44Master of Information SystemManagement• Many vendors have an ESB product.• JBoss has an open source ESB.• CMU has recently chosen Oracle’s ESB.• An ESB usually includes:- Content Transformations (often via XSLT)- Queuing and waiting until services areavailable- Routing (often using WS-Addressing)- Event driven publish/subscribe- Protocol mediation- Monitoring and loggingWhat is an ESB?
  45. 45. 95-843: Service Oriented ArchitectureIntegration Styles45Master of Information SystemManagementFrom “RESTFul Web Services vs. “Big Web Services”: Making theRight architectural decision by Paufasso, Zimmerman and Leymann.
  46. 46. 95-843: Service Oriented ArchitectureAn Open Source ESB from JBoss- See You can purchase support from RedHat.- It’s the next generation of EAI.- Business logic is left to higher levels.- Its about infrastructure logic.- An ESB is needed when we mapabstract SOA to a concreteimplementation.46Master of Information SystemManagementFrom JBOSS ESB Documentation
  47. 47. 95-843: Service Oriented Architecture47Master of Information SystemManagementFrom JBoss ESB Documentation
  48. 48. 95-843: Service Oriented Architecture48Master of Information SystemManagementFrom JBoss ESB Documentation
  49. 49. 95-843: Service Oriented ArchitectureTo Ensure Loose Coupling:- Use one-way messages rather than request-responsestyle.- Do not expose service back-end implementationchoices.- Use an extensible message structure so that it maybe versioned over time, for backward compatibility.- Do not use the distributed object approach of finegrained services.- One way message delivery requires that we encodereturn address information in the message. Use WS-Addressing.49Master of Information SystemManagementFrom JBoss ESB DocumentationJBoss Recommendations
  50. 50. 95-843: Service Oriented ArchitectureSome JBoss ESBComponents- The Message Store ServiceA pluggable persistence service designed for audittracking. Every event is recorded.- Data Transformation ServiceOften clients and services will use the same vocabulary.If not, on the fly transformation is provided.JBoss uses Smooks and XSLT (Smooks can read an EDImessage and generate a corresponding Java object).- Content based routingJBossESB can route messages based on arbitrarilycomplex rules. It uses XPath and JBoss Rules (Drools).50Master of Information SystemManagementFrom JBoss ESB Documentation
  51. 51. 95-843: Service Oriented ArchitectureSome JBoss ESBComponents (2)- Registry Service (UDDI) is at the heart of JBossESB.Services can self-publish their endpoint references(EPRs) into the Registry when they are activated, andremove them when they are taken out of service.- Consumers can introspect over the Registryto determine the EPR for the right service for the workat hand.51Master of Information SystemManagementFrom JBoss ESB Documentation
  52. 52. 95-843: Service Oriented Architecture52Master of Information SystemManagementSimple WS Without anESBAlice BobSOAPSOAPBob’s WSDL is available to Alice.
  53. 53. 95-843: Service Oriented Architecture53Master of Information SystemManagementSimple WS With an ESBAlice BobBob’s WSDL availableto ESB.ESB’s WSDL availableto Alice.Bob may be a legacyapplication with aweb service front end.The backend protocol maybe different from the front end.
  54. 54. 95-843: Service Oriented Architecture54Master of Information SystemManagementOracle’s ESB (OSB)Alice BobJEEWeblogicAlice may be calling Bob as part of a business orchestration. She mightbe running BPEL. Another orchestration may exist within the ESB - butworking at a lower level.
  55. 55. 95-843: Service Oriented Architecture55Master of Information SystemManagementProtocol MediationAlice BobJEEWeblogicAlice may be passing an XML message to the ESB. The ESB may becommunicating with Bob via sftp.
  56. 56. 95-843: Service Oriented Architecture56Master of Information SystemManagement
  57. 57. 95-843: Service Oriented ArchitectureAnd From Microsoft57Master of Information SystemManagement
  58. 58. 95-843: Service Oriented ArchitectureESB’s From IBM (1)58Master of Information SystemManagement
  59. 59. 95-843: Service Oriented Architecture59Master of Information SystemManagementESB’s From IBM (2)
  60. 60. 95-843: Service Oriented Architecture60Master of Information SystemManagement60Master of Information SystemManagementIBM’s Solution Stack View