Introduction to XML SOAP and Biztalk Arie Leeuwesteijn
Introduction to XML, SOAP and Biztalk Arie Leeuwesteijn ariele@microsoft. com M
Content § § § § XML use cases What is XML ? XML syntax Document definitions and validation XML parsers XSL translations SOAP, a. k. a. Web Services Biztalk overview
Objectives § Reading XML documents § Understanding XML terminology and acronyms § Examples of XML applications
XML Use Cases § Application integration § Generic format for data transfer for E-commerce and other web applications § Storing and accessing structured data
Application Integration § High costs and effort because application data is § Proprietary § Incompatible § Undocumented legacy data § Different data formats
Same data, different format fifteen 0 x 0 F “ 15” 15. 00 XV 1111 0001 0101
The Internet § § The ultimate integration environment Many different systems and platforms Time to market measured in internet time Today XML is already integrated in § Operating systems § Applications § Databases § Development tools § Browsers §…
XML design goals § Flexible, extensible and support for wide variety of applications § Must be simple and light weight § Straightforwardly usable over the internet
What is XML? § Meta language for self describing structured data § Consists of data and tags § Extensible language, users can define their own specific tags § Version 1. 0 specification approved by W 3 C as recommendation
XML History § Subset of Standard Generalized Markup Language (SGML) § Far less complex § 20% of SGML features § 80% of SGML functionality § (XML spec is 26 pages, SGML 500+)
XML vs. HTML XML HTML § § § Subset of SGML Extensible Focus on data SGML application Fixed Focus on presentation
XML Document Structure <? xml version=“ 1. 0” ? > <!DOCTYPE name [ … ]> <doc_root_element> <data_element> … </data_element> </doc_root_element> XML declaration (processing instructions) Document definition (optional) Document data
Basic XML syntax § § § Human “readable” text Support for Unicode character set Syntax is stricter than for example HTML
Tags And Data § Document consists of data marked up by tags § Tags describe meaning and structure of data § An element is a group of start-tag/end-tag with the data in between <Book>Essential XML</Book> Start-tag Data End-tag
Start- and End-Tags § Element must have a matching start- and end-tag <one>hello</one><two>world</two> <one>hello <two>world</two> § Empty elements can be written as <tag></tag> <tag/> § Tags are case sensitive
XML Basic Syntax § XML elements can have nested child elements to structure document in levels § <outer> <inner>text</inner> </outer> <inner></outer> </inner>
Root element § A XML document must have one root element: <library> <book>XML in action</book> <book>Essential XML</book> </ library > < book > XML in action </ book > < book > Essential XML </ book > § What is the document root ?
Comments § Syntax for comments is: <! -- This is a comment --> § Comments be placed everywhere in the document except inside element tags <tag <!-- comment --> >
Attributes § Attributes associate named values to an element § Attributes are part of the start-tag <publication type=“book”> <title>XML in action</title> <price currency=“USD”>49. 99</price> </ publication > § Values must be double or single quoted
XML Example Processing instruction <? xml version=“ 1. 0” encoding=”UTF-8” ? > <library> Book element <book> <title>XML in action</title> <price currency=“USD”>49. 99</price> Root <isbn>0 -7356 -0562 -9</isbn> <rating scale=“ 5”>3</rating> </book> Child elements <book> of Book <title>Essentail XML</title> <price currency=“USD”>34. 95</price> <isbn>0 -201 -70914 -7</isbn> <rating scale=“ 5”>4</rating> </book> Currency attribute for </ library > price element
Valid vs. Well Formed XML § Well formed: Valid XML syntax § Valid document: Content of document valid conform specification of document § A valid document is automatically a well formed document § A well formed document is not always a valid document
Document specifications § Describes structure and contents of XML document § Parsers can use schema’s to validate a document § Validation is optional § Think if/where validation should take place § Document Type Definitions (DTD), part of XML 1. 0 standard
DTD example <? xml version=“ 1. 0”? > <!DOCTYPE CATALOG [ <!ELEMENT BOOK (TITLE, PRICE)> <!ELEMENT TITLE(#PCDATA)> <!ELEMENT PRICE(#PCDATA) ]> < CATALOG > <BOOK> <TITLE>XML in action</TITLE> <PRICE>49. 95</PRICE> </BOOK> </ CATALOG >
DTD Issues § Good DTD’s are difficult to write (Extended Backus Naur Form notation) § DTD’s are not extensible and many limitations § Most important limitation is lack of data types
XML Schemas § Alternative for DTD’s § XML is used to describe the structure of the document, no need to learn new language or use other tools § Lifts most limitations of DTD’s (data types ) § XSD, § XML schema specification § W 3 C recommendation § XDR § Early MS version of XSD
XML-Data Schemas simple example <Schema > <Element. Type name=“title" content="text. Only“> <Element. Type name=“isbn" content="text. Only”/> <Element. Type name=“book" content="elt. Only"> <element type=“title"/> <element type=“isbn"/> </Element. Type> </Schema>
XML Parsers § § § Parse XML document Validate XML syntax (always) Validate content (optional) Access data Update data Translate data (XSL)
XML Parser types Two different parser models § Document Object Model (DOM) § § § Complete document in memory Easy access for applications Queries on data Translations Simple API for XML (SAX) 1. 2. 3. 4. Generates event per parsed element Large documents Batch processing More difficult to use than DOM
Document Object Model § DOM defines logical structure of a parsed XML document § DOM defines how data can be accessed and manipulated § Provides standardized API (level 1, 2 and 3) § DOM can also be used to create or modify XML documents
Document Object Model document root node A node can contain child nodes or text Node lists node node
Querying the DOM through XPath § XPath declarative language for locating nodes and fragments in XML trees § Allow you to locate nodes by: § Absolute or relative position § Element or attribute types § Element or attribute values § Combinations using boolean operators § Also used in XSL, XPointer and XLink specifications
XPath examples § All books in the current context book (equal to. /book) § All books anywhere in the document //book § All books with specified element value book[title=“Essential XML”] § or a specified attribute value book[@type=“paperback”] § or just having the attribute book[@type] § The first 3 books book[index()<4]
Extended Stylesheet Language XSL § Similarities with CSS, but more powerful § Applies translations to data that matches a pattern § Close to becoming a standard (draft status W 3 C)
XSL translations § XSLT is based on pattern matching and templates § A template rule consist of a pattern and a template § Processor finds best matching pattern and applies related template for translation
XSL stylesheet example <? xml-stylesheet type="text/xsl“ href=“books. xsl"? > <books> <book><title>Essential XML</title></book> <book><title>XML in action</title></book> </books> XML Data + <xsl: stylesheet…. > … <xsl-template match=“title”> <tr><td><b><xsl-value-of select=“text()”/></td></tr> … </xsl: stylesheet> XSL style sheet (partial) = <tr><td><b>Essential XML</td></tr> <tr><td><b>XML in action</td></tr> HTML output
XSL usage § Formatting and displaying XML data as HTML, PDF, etc. § Converting XML document: § Other XML document structures (XML->XML) § Other data formats (CSV, Edifact) § MS Biztalk mapping editor generate XLS to convert XML, Flat file and Edifact documents to XML and back.
XML Applications § XML in real applications § Simple Object Access Protocol § Microsoft Biztalk 2000 Note this is not a training on SOAP and Biztalk
Software integration § Today’s middleware § Vendor and language depended • COM+ v. s. EJB • Interoperability problems § Was not designed to use over the internet • • Reliable communications Firewalls § Complex
SOAP § Simple Object Access Protocol § Invoking object methods using XML and HTTP § Specification written by Microsoft, IBM, Software and Developmentor § Vendor and middleware independency (the end of middleware battles ? ) § Supported and available today from most major vendors (MS, IBM, IONA etc. ) § Core technology in Microsoft. NET web services
SOAP 2 Soap proxy 1 6 3 XML/HTTP 5 Soap listener Client application 4 Component Vendor A Vendor B 1. Client application makes call 2. Soap proxy intercepts call and constructs and transmits XML request message 3. Soap listener receives, parses and validates request 4. Listener calls component message 5. Listener takes result of call and constructs and transmits XML response 6. Proxy receives and parses response and returns result to client This whole process is transparent for client and component
Simple SOAP Request POST /Stock. Quote HTTP/1. 1 HTTP headers Host: www. stockquoteserver. com Content-Type: text/xml; charset="utf-8“ Content-Length: 323 SOAPAction: Some-Namespace-URI#Get. Last. Trade. Price <SQ: Envelope xmlns: SOAP ="http: //schemas. xmlsoap. org/soap/envelope/" SQ : encoding. Style="http: //schemas. xmlsoap. org/soap/encoding/“> < SQ : Body> <m: Get. Last. Trade. Price xmlns: m="Some-Namespace-URI"> <symbol>MSFT</symbol> Body </m: Get. Last. Trade. Price> </ SQ : Body> </ SQ : Envelope> Get. Last. Trade. Price(“MSFT”) Envelope
Simple SOAP Response HTTP headers HTTP/1. 1 200 OK Content-Type: text/xml; charset="utf-8“ Content-Length: nnnn <SP: Envelope xmlns: SP="http: //schemas. xmlsoap. org/soap/envelope/" SP: encoding. Style="http: //schemas. xmlsoap. org/soap/encoding/"> <SP: Body> Result Body <m: Get. Last. Trade. Price. Response xmlns: m="Some-Namespace-URI"> <Price>160. 95</Price> </m: Get. Last. Trade. Price. Response> </SP: Body> </SP: Envelope> Envelope
What Is Biztalk ? n Biztalk Community (Biztalk. org) n n n Biztalk Framework n n Library for business document specification Stimulate reuse Submit and retrieve document specifications 400+ third-party XML business documents 150+ registered organizations XML Specification for document routing and exchange (SOAP 1. 1 compliant) Biztalk Server n Microsoft server product for processing, transforming, signing, routing of documents
B 2 B challenges Customers Suppliers My company
Business to Business n Different data format (EDI, CSV, XML…) n Different document structures n Different protocols n Different encryption technologies n Different operating systems n Legacy ERP and other back office systems
Biztalk Server n n Design time tools n Schema, transformation definition Document processing server n Messaging n Communication n Transformation n Routing n Encryption n Workflow n Orchestration
Biztalk Mapper XSL map Map Internal XML doc XML in Biztalk Internal XML doc XSL Engine Biztalk Server Doc spec Parser XML doc EDI doc Inbound document Serializer Serialize CSV file XML doc Biztalk editor EDI doc Outbound document CSV file
XML in Biztalk Visio Diagram Compile XLANG schedule Applications Biztalk Messaging XLANG Runtime Scheduler
XML in Biztalk Server § XML for describing all in- and outbound business documents as an extended Data. Schema § XSL for document translations § XML as internal format for all processed documents § XLANG workflow schedules
Biztalk demos § § § Biztalk Editor Biztalk Mapper Biztalk Orchestration
Things to read… XML in Action MS-Press ISBN 0735605629 Essential XML Addison Wesley ISBN 0201709147 Professional XML WROX ISBN 1861003110 Understanding SOAP SAMS ISBN 0672319225
Places to go… § http: //www. w 3 c. org (all mentioned standards) § http: //msdn. microsoft. com/xml (tutorials and reference on xml) § http: //msdn. microsoft. com/soap (tutorials and reference on xml) § http: //www. biztalk. org (Biztalk organization)
<QUESTIONS/>
Biztalk Orchestration
Biztalk Editor
Biztalk Mapper
- Slides: 56