Eben Hewitt - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

Eben Hewitt

Description:

street 20225 N SCOTTSDALE /street street2 STE #305 /street2 city SCOTTSDALE /city state AZ /state postalCode 85255 /postalCode /usAddress ... – PowerPoint PPT presentation

Number of Views:103
Avg rating:3.0/5.0
Slides: 53
Provided by: ehew
Category:

less

Transcript and Presenter's Notes

Title: Eben Hewitt


1
XML-Based Technologies in SOAXML, Schema, SOAP,
WSDL, BPEL
  • Eben Hewitt

2
Presentation Goals
  • Provide a quick introduction to the WS
    technologies used to do SOA
  • XML, Schema, SOAP, WSDL, BPEL, and ESB
  • Give users and participants head-start
  • Foundation for next presentation

3
Service-Oriented Review
  • Platform agnostic
  • Not procedural or OO
  • Business Documents
  • Loose coupling
  • Law of Demeter

4
XML
5
XML Overview
  • eXtensible Markup Language
  • Describes data
  • Invent your own tags

6
Problem with Non-XML Data
  • What is this?
  • 1998070420071110hih053280142187
  • A purchase order?
  • We can make good guesses

7
XML
  • ltinvoicegt
  • ltidgt19980704lt/idgt
  • ltdategt20071110ltdategt
  • ltstoregthih05lt/storegt
  • ltterminalgt3lt/terminalgt
  • ltprod-codegt28014lt/prod-codegt
  • ltqtygt2ltqtygt
  • lttotal-amtgt187lttotal-amtgt
  • lt/invoicegt
  • Self-describing
  • Typed

8
Working with XML
  • XML does nothing
  • So you have to write software to process it
  • But you can do so in any language
  • Thats why XML is used in our SOA to represent
    business documents

9
Doing Stuff With XML
  • Can store it as plain text in a
  • Flat file
  • SQL Database database as text or XML type
  • Native XML database
  • Can transmit it over
  • HTTP or SOAP
  • FTP

10
Common Uses
  • Standard Enterprise Data
  • Traverse the tree of nodes
  • CRUD
  • Transform it into another XML document
  • new version
  • vendor-specific
  • Create new custom languages
  • WML
  • MathML

11
XML Document Requirements
  • Declaration
  • lt?xml version"1.0" encodingUTF-8"?gt
  • Attributes must be quoted
  • Must include closing tag
  • XML is case-sensitive
  • Proper nesting. OK
  • ltbgtltigtIts bold and italiclt/igtlt/bgt

12
XML Constructs
  • Elements lttaggtvaluelt/taggt
  • Attributes lttag attributeNamevalue /gt
  • Comments lt!-- my comment --gt
  • Documents are Trees

13
Use Attributes Sparingly
  • attributes cannot contain multiple values
  • child elements can
  • attributes are not easily expandable
  • consider future changes
  • attributes cannot describe structures
  • child elements can

14
Well-Formed and Valid
  • Well-Formed
  • this XML document conforms to all syntax rules
  • Valid
  • this XML document is Valid AND conforms to a
    Schema

15
Parsing XML
  • SAX is event-based parsing
  • Every time a tag, attribute, text, comment,
    whitespace or other XML item is encountered, a
    call-back is fired.
  • Then your code can do something if its
    interested in that event
  • Must implement certain interfaces
  • DOM creates in-memory tree
  • Not as fast as SAX, but makes sense when
  • You need random access to your document
  • You need access to sibling elements
  • Not appropriate for huge documents
  • New StAX pull-parser
  • Like SAX, but you ask for the events youre
    interested in.
  • Very fast
  • Unlike SAX, can write

16
XPath and XQuery
  • XPath
  • Navigate the elements and attributes in the tree
  • /person/name/_at_title
  • Not own file type, used within BPEL, Xquery, Java
    APIs
  • Must know Xpath!
  • XQuery
  • To XML what SQL is to database tables
  • Shares datatypes with Schema
  • Advanced constructs
  • FLOWR"For, Let, Order by, Where, Return
  • Save in separate .xqy file
  • Requires Implementation like Saxon-B

17
XML Schema
18
XML Schemas
  • Describe the structure of XML documents!
  • Written in XML themselves
  • Support Reuse
  • Do nothing on their own.
  • Get a validating parser (later slide)

19
Schemas Also...
  • Dictate data constraints
  • Default values
  • Fixed values (enums)
  • Regular Expressions
  • Order of elements
  • Define datatypes
  • Built-in
  • Custom
  • Support namespaces

20
Schema Example Store.xsd
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltschema xmlns"http//www.w3.org/2001/XMLSchema"
  • xmlnsdte"http//schemas.dte.com/dte/general"
  • targetNamespace"http//schemas.dte.com/dte/gener
    al"gt
  • ltannotationgt
  • ltdocumentation xmllang"engtA standard DTC
    Store.lt/documentationgt
  • lt/annotationgt
  • ltinclude schemaLocation"Address.xsd"/gt
  • ltelement name"store" type"dteStore"/gt
  • ltcomplexType name"Store"gt
  • ltsequencegt
  • ltelement name"storeCode"gt
  • ltsimpleTypegt
  • ltrestriction base"string"gt
  • ltpattern value"A-Z3A-Z_\s
    \d2"/gt
  • lt/restrictiongt
  • lt/simpleTypegt
  • lt/elementgt
  • ltelement name"address"
    type"dteAddress"/gt

21
aStore.xml
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltdtestore xmlnsdte"http//schemas.dte.com/dte/g
    eneral"
  • xmlnsxsi"http//www.w3.org/2001/XMLSchema-in
    stance"
  • xsischemaLocation"http//schemas.dte.com/dte
    /general

  • home/ehewitt/schemas/dte/general/Store.xsd"gt
  • ltstoreCodegtAZP 23lt/storeCodegt
  • ltaddressgt
  • ltstreetgt555 Some Streetlt/streetgt
  • ltcitygtPhoenixlt/citygt
  • ltstategtAZlt/stategt
  • ltzipgt86001lt/zipgt
  • lt/addressgt
  • lt/dtestoregt
  • Note that Store.xsd reuses Address.xsd

22
The Importance of Built-in DataTypes
  • Programs or locales can use data differently.
  • When is 07-11-2007?
  • The XML built-in data type "date" requires the
    format "YYYY-MM-DD".
  • ltdate type"date"gt2007-07-11lt/dategt
  • Important datatypes include
  • String and Token
  • Date and Time, Duration
  • Signed and Unsigned Decimal, Integer, byte, short
  • Boolean
  • Binary data in hex and base64

23
Using XML on iSeries
  • Built-in SAX Parser built into COBOL
  • XML Toolkit for iSeries
  • contains DOM and SAX parsers
  • XMLPR400 for ILE COBOL
  • See www.mowyourlawn.com and www.web400.com for
    easier wrappers
  • XML Parser QSYS/QXML4PR310
  • See API spec in library/file/memberQSYSINC/QCBLLE
    SRC/QXML4PR310
  • The linkage file to facilitate your COBOL
    application code is library/file/member
  • QSYSINC/QCBLLESRC/QXML4PRLNK
  • For the COBOL ILE compiler, use the CL command
    Create COBOL Module (CRTCBLMOD.
  • Use one of the following commands, specifying the
    parser service program on the bind
  • CRTPGM PGM(ltyour_librarygt/ltyour_programgt)
    MODULE(ltyour_librarygt/ltyour_modulesgt)
  • BNDSRVPGM(QSYS/QXML4PR310)
  • See http//publib.boulder.ibm.com/iseries/v5r1/ic2
    924/index.htm?info/rzakl/rzakltools.htm

24
Schema Conclusion
  • Schemas are very flexible, but very complex
  • There are entire books written on schemas
  • Schemas describe the valid structure of XML
    documents, which includes
  • SOAP documents
  • WSDLs
  • BPELs
  • Our custom business objects
  • We use Schemas to perform validation at runtime
  • You must understand schemas!

25
SOAP
26
SOAP
  • Simple Object Access Protocol
  • Reuses HTTP
  • Stateless
  • Request-Response
  • One way
  • Or other bindings (SMTP, RMI, JMS)
  • Transfer XML documents between disparate apps
  • Requires SOAP implementation

27
SOAP Basic Unit The Envelope
  • ltsoapenvelopegt
  • Header
  • directives
  • meta-data
  • Body
  • required
  • contains payload
  • Attachments
  • just like in email, usually for binary data
  • Fault

28
SOAP Message
  • ltsoapenvEnvelope xsischemaLocation"http//schem
    as.xmlsoap.org/soap/envelope/ http//schemas.xmlso
    ap.org/soap/envelope/"
  • xmlnsxsi"http//www.w3.org/2001/XMLSchema-instan
    ce"
  • xmlnsxsd"http//www.w3.org/2001/XMLSchema"
  • xmlnssoapenv"http//schemas.xmlsoap.org/soap/env
    elope/"
  • xmlnsqs"http//ns.dte.com/dtc/quickscreen"gt
  • ltsoapenvBodygt
  • ltqscc1PreApproveApplicationgt
  • ltpersongt
  • ltnamegt
  • ltfirstNamegtEbenlt/firstName
    gt
  • ltmiddleInitialgtMlt/middleIn
    itialgt
  • ltlastNamegtHewittlt/lastName
    gt
  • lt/namegt
  • ltusAddressgt
  • ltstreetgt20225 N
    SCOTTSDALElt/streetgt
  • ltstreet2gtSTE
    305lt/street2gt
  • ltcitygtSCOTTSDALElt/citygt
  • ltstategtAZlt/stategt
  • ltpostalCodegt85255lt/postalC
    odegt

29
SOAP Faults
  • ltenvEnvelope xmlnsenv"http//www.w3.org/2003/05
    /soap-envelope"
  • xmlnsm"http//www.example.org/time
    outs"
  • xmlnsxml"http//www.w3.org/XML/199
    8/namespace"gt
  • ltenvBodygt
  • ltenvFaultgt
  • ltenvCodegt
  • ltenvValuegtenvSenderlt/envValuegt
  • ltenvSubcodegt
  • ltenvValuegtmMessageTimeoutlt/envValuegt
  • lt/envSubcodegt
  • lt/envCodegt
  • ltenvReasongt
  • ltenvText xmllang"en"gtSender
    Timeoutlt/envTextgt
  • lt/envReasongt
  • ltenvDetailgt
  • ltmMaxTimegtP5Mlt/mMaxTimegt
  • lt/envDetailgt
  • lt/envFaultgt
  • lt/envBodygt

30
Using SOAP
  • Requires a host language API
  • Java using GlassFish, WebLogic
  • On mainframes IBM has SupportPac for CICS
  • On iSeries COBOL, use Java wrappers and WebSphere
  • Next presentation...

31
WSDL 2.0
32
WSDL 2.0
  • Stands for Web Services Description Language
  • Written in XML
  • WSDLs define the interface or contract of a Web
    Service
  • ContractWhat must be done, not how it must be
    done.
  • Because no implementation is given, the client
    and the service can be written in any language.
  • (Client in Python, Service in .NET, Client in
    COBOL, Service in Java, etc)
  • Like an interface or an abstract class
  • Tells you only what the services API is

33
Using WSDL
  • A client program connecting to a web service can
    read the WSDL to determine what functions are
    available on the server.
  • Any custom datatypes used ("DTC Store") are
    embedded in the WSDL file in the form of XML
    Schema.
  • The client can then use SOAP to invoke one of the
    functions listed in the WSDL.
  • That process can be automated with tools.

34
WSDL Document Overview
35
WSDL Elements (3 of 5)
  • lttypesgt
  • Describes all data types used by the web service,
    defined as Schemas (default).
  • When a WSDL file specifies a targetNamespace of
    'X', all the things defined within that WSDL file
    are considered defined under the namespace 'X'.
  • Not necessary if you only use built-in data types
    (string, integer, boolean, etc)
  • ltmessagegt
  • Defines the SOAP messages exchanged in using this
    Web Service.
  • Each is a one-way SOAP message, either a request
    or response.
  • Child element is ltpartgt.
  • ltportTypegt
  • Defines the operations performed by the web
    service.
  • Like a class with a collection of methods.
  • Combines multiple ltmessagegt elements.

36
WSDL Elements cont.
  • ltservicegt
  • What is the actual address (URL) of the service?
  • Points to a ltportTypegt.
  • Nothing at that URL if you merely pull it up in a
    browser.
  • You can specify multiple ltservicegt types for the
    same binding (ie, for a mirror).
  • ltbindinggt
  • How will the physical transportation of the
    messages occur? What protocol details do we need
    to know?
  • transport"http//schemas.xmlsoap.org/soap/http"
    means "use SOAP over HTTP"

37
WSDL SOAP Binding
  • ltbinding name"CustomerManagementPortBinding"
    type"tnsCustomerManagement"gt
  • ltsoapbinding transport"http//schemas.xmlsoap.or
    g/soap/http" style"document" /gt
  • ltoperation name"lookupCustomer"gt
  • ltsoapoperation soapAction"" /gt
  • ltinputgtltsoapbody use"literal" /gtlt/inputgt
  • ltoutputgtltsoapbody use"literal" /gtlt/outputgt
  • lt/operationgt
  • lt/bindinggt
  • How many namespaces are going on here?
  • Why are some names NS-qualified?
  • Is the output required?

38
WSDL RPC and Document
  • RPC
  • The SOAP request will include a wrapper XML
    element indicating the function name.
  • The name of the element taken from the operation
    name attribute and the namespace taken from the
    operation namespace attribute.
  • Document
  • Request and response messages will consist simply
    of XML documents, which is flatter.
  • Client should use pass-through documents defined
    with XML schemas rather than RPC calling
    conventions.
  • The message is placed directly into the body
    portion of the SOAP envelope, either as-is or
    encoded.

39
Debate RPC vs Document Style
  • Document Style
  • Allows full use of XML, described in an open
    format that is human readable, self-describing,
    and self-validating.
  • does not require a rigid contract
  • RPC Style
  • requires that the structure of the SOAP request
    body contain both the operation name and the set
    of method parameters.
  • Use document style for
  • asynchronous processing
  • maintaining application state
  • publishing services for outside partners
  • easier validation and use of complex documents
  • minimize in-memory processing (can choose
    DOM/SAX/StAX)
  • We use document

40
Encoding Use Models Literal or Encoded
  • Dictates how to translate a WSDL binding to a
    SOAP message
  • Literal
  • The body contents should conform to a
    user-defined XML Schema structure.
  • Advantages
  • you can validate the message body with the
    user-defined XML Schema
  • you can transform the message using a
    transformation language like XSLT.
  • Encoded
  • The message has to use Schema datatypes, BUT the
    message structure need not conform to any
    user-defined XML schema.
  • This makes it difficult to validate the message
    body or use XSLT based transformations on the
    message body.
  • We use literal.

41
BPEL
42
BPEL 2.0 Overview
  • Business Process Execution Language
  • Standard that defines State Transitions
  • Executable XML-based language for Business
    Process Modeling
  • Requires a BPEL Engine to execute
  • Allows "orchestration" of Web Services via WSDL
    ltportTypegts

43
Orchestration
  • Individual Services are built to last a long
    time.
  • Orchestrations composed of services are built for
    change.
  • This is where you get agility.
  • Just like WSDL defines the contract for a Web
    Service, BPEL defines the contract for service
    compositions.

44
Three BPEL Constructs
  • Programming logic - BPEL
  • Data types - XSD
  • Input/Output (I/O) - WSDL
  • The BPEL is responsible for invoking services as
    defined here

45
Using Compositions
  • Four Individual Services
  • CreateEmployee (HR)
  • CreateAccount (Payroll)
  • CreateEmailAccount
  • ProvisionWorkstation
  • One Service Composition
  • NewHire
  • CreateEmployee (HR)
  • CreateAccount (Payroll)
  • CreateEmailAccount
  • ProvisionWorkstation

46
BPEL ltProcessgt
1.) Declare namespaces (reuse) ltprocess
xmlnsemesb"http//ns.dte.com/dtc/esb/email . .
. xmlnsemailws"http//ns.dte.com/dtc/ws/email"gt
ltimport namespace"http//ns.dte.com/dtc/general
" location"commonsvc/EmailService/Email.xs
d importType"http//www.w3.org/2001/XMLSchem
a"/gt 2.) Define inputs and outputs
(reuse) ltpartnerLinksgt ltpartnerLink
name"EmailPartner"
partnerLinkType"ns1EmailLinkType"
partnerRole"EmailRole"/gt ltpartnerLink
name"EmailEsb partnerLinkTypeemesbEmai
lPL" myRole"EmailEsbPortTypeRole"/gt lt/partnerLink
sgt Maps to a WSDL ltportTypegt 3.) Declare
variables (local and temporary) ltvariable
name"SendEmailIn" messageType"emailwssendEmail"
/gt Used to pass data to services and to BPEL
constructs 4.) Define the workflow using
ltsequencegt
47
Partner Links
  • ltpartnerLinksgt
  • ltpartnerLink name"EmailEsb
    partnerLinkTypeemesbEmailPL
  • myRole"EmailEsbPortTypeRole"/gt
  • ltpartnerLink name"EmailPartner
    partnerLinkType"ns1EmailLink"
  • partnerRole"EmailRole"/gt
  • lt/partnerLinksgt
  • All services are Partners
  • EmailEsb uses myRole because thats what the
    BPELs own clients invoke in the ESB
  • EmailPartner uses partnerRole because that
    represents the invocation of the service
  • The ESB is acting as the service

48
BPEL ltsequencegt
  • ltsequencegt
  • ltreceive name"ReceiveEmail" createInstance"yes"
  • partnerLink"EmailEsb operation"EmailOperatio
    n
  • portTypeemesbEmailPortType
  • variable"EmailOpIn"/gt
  • ltassign name"Assign1"gt
  • ltcopygt
  • ltfrom variable"EmailOpIn part"emailMsg"/gt
  • ltto variable"SendMe" part"emailMsg/gt
  • lt/copygt
  • lt/assigngt
  • ltinvoke name"InvokeEmailSendingService"
  • partnerLink"EmailPartner"
  • operation"sendEmail" portType"emailwsEmail"
  • inputVariable"SendMe /gt
  • lt/sequencegt

49
BPEL Design View
50
What Can You Do in BPEL?
  • Invoke Services
  • Variables
  • Create local variables
  • XML and WSDL typed variables
  • Access with XPath
  • Transform with XSLT
  • Structured Programming Constructs
  • If-then-elseif-else
  • while, forEach
  • Life Cycle
  • sequences, processes
  • repeatUntil
  • Fault handlers
  • Bindings for Given Protocol
  • HTTP External support for SOAP over HTTP
  • File Transport service to a file system
  • FTP
  • JMS

51
Next Presentation
  • SOA III Working with Web Services Technologies
    in Java
  • ESB JAX WS 2.0
  • SOAP APIs including SAAJ, JAXB
  • Ant tools
  • GlassFish v2
  • Common Dispatcher and client libraries
  • ESB

52
Questions
  • Thank you!
Write a Comment
User Comments (0)
About PowerShow.com