56
Introduction to Introduction to XML, SOAP and XML, SOAP and Biztalk Biztalk M M Arie Leeuwesteijn [email protected]

Introduction to XML, SOAP and Biztalk M Arie Leeuwesteijn [email protected]

  • View
    226

  • Download
    0

Embed Size (px)

Citation preview

Introduction to XML, Introduction to XML, SOAP and BiztalkSOAP and Biztalk

MMArie [email protected]

               

ContentContent

XML use cases XML use cases What is XML ?What is XML ? XML syntaxXML syntax Document definitions and validationDocument definitions and validation XML parsersXML parsers XSL translationsXSL translations SOAP, a.k.a. Web ServicesSOAP, a.k.a. Web Services Biztalk overviewBiztalk overview

ObjectivesObjectives

Reading XML documentsReading XML documents Understanding XML terminology and Understanding XML terminology and

acronymsacronyms Examples of XML applicationsExamples of XML applications

XML Use CasesXML Use Cases

Application integrationApplication integration Generic format for data transfer for Generic format for data transfer for

E-commerce and other web applicationsE-commerce and other web applications Storing and accessing structured dataStoring and accessing structured data

Application IntegrationApplication Integration

High costs and effort because application High costs and effort because application data isdata is ProprietaryProprietary IncompatibleIncompatible Undocumented legacy dataUndocumented legacy data Different data formatsDifferent data formats

Same data, different formatSame data, different format

fifteenfifteen

XVXV

““15”15”

11111111

15.0015.00

0x0F0x0F

0001 01010001 0101

The InternetThe Internet

The ultimate integration environmentThe ultimate integration environment Many different systems and platformsMany different systems and platforms Time to market measured in internet timeTime to market measured in internet time Today XML is already integrated inToday XML is already integrated in

Operating systemsOperating systems ApplicationsApplications DatabasesDatabases Development toolsDevelopment tools BrowsersBrowsers ……

XML design goalsXML design goals

Flexible, extensible and support for wide Flexible, extensible and support for wide variety of applicationsvariety of applications

Must be simple and light weightMust be simple and light weight Straightforwardly usable over the internetStraightforwardly usable over the internet

What is XML?What is XML?

Meta language for self describing Meta language for self describing structured datastructured data

Consists of data and tagsConsists of data and tags Extensible language, users can define their Extensible language, users can define their

own specific tagsown specific tags Version 1.0 specification approved by W3C Version 1.0 specification approved by W3C

as recommendationas recommendation

XML HistoryXML History

Subset of Standard Generalized Markup Subset of Standard Generalized Markup Language (SGML)Language (SGML)

Far less complexFar less complex 20% of SGML features20% of SGML features 80% of SGML functionality 80% of SGML functionality (XML spec is 26 pages, SGML 500+)(XML spec is 26 pages, SGML 500+)

XML vs. HTMLXML vs. HTML

XMLXML Subset of SGMLSubset of SGML ExtensibleExtensible Focus on dataFocus on data

HTMLHTML SGML applicationSGML application FixedFixed Focus on presentationFocus on presentation

XML Document StructureXML Document Structure

<?xml version=“1.0” ?><?xml version=“1.0” ?>

<doc_root_element> <data_element> … </data_element></doc_root_element>

<!DOCTYPE name [ …]>

Document dataDocument dataDocument dataDocument data

Document definitionDocument definition(optional)(optional)

Document definitionDocument definition(optional)(optional)

XML declarationXML declaration(processing instructions)(processing instructions)

XML declarationXML declaration(processing instructions)(processing instructions)

Basic XML syntaxBasic XML syntax

Human “readable” textHuman “readable” text Support for Unicode character setSupport for Unicode character set Syntax is stricter than for example HTMLSyntax is stricter than for example HTML

Tags And DataTags And Data

Document consists of data marked up by Document consists of data marked up by tagstags

Tags describe meaning and structure of Tags describe meaning and structure of data data

An element is a group of start-tag/end-tag An element is a group of start-tag/end-tag with the data in between with the data in between

<Book>Essential XML</Book><Book>Essential XML</Book>

Start-tag End-tagData

Start- and End-TagsStart- and End-Tags

Element must have a matching start- and end-tagElement must have a matching start- and end-tag

<one>hello</one><two>world</two> <one>hello</one><two>world</two> <one>hello <two>world</two> <one>hello <two>world</two>

Empty elements can be written asEmpty elements can be written as

<tag></tag> <tag></tag> <tag/><tag/>

Tags are case sensitiveTags are case sensitive

XML Basic SyntaxXML Basic Syntax

XML elements can have nested child elements to XML elements can have nested child elements to structure to structure document in levelsstructure to structure document in levels

<outer><outer> <inner>text</inner><inner>text</inner>

</outer></outer>

<outer><outer> <inner></outer><inner></outer>

</inner></inner>

Root elementRoot element

A XML document must have A XML document must have oneone root element: root element:

<library><library> <book>XML in action</book><book>XML in action</book><book>Essential XML</book><book>Essential XML</book>

</ library ></ library >

< book > XML in action </ book >< book > XML in action </ book > < book > Essential XML </ book >< book > Essential XML </ book >

What is the document root ?What is the document root ?

CommentsComments

Syntax for comments is:Syntax for comments is:

<! -- This is a comment --><! -- This is a comment -->

Comments be placed everywhere in the Comments be placed everywhere in the document except inside element tagsdocument except inside element tags

<tag <!-- comment --> > <tag <!-- comment --> >

AttributesAttributes

Attributes associate named values to an Attributes associate named values to an elementelement

Attributes are part of the start-tag Attributes are part of the start-tag

<publication <publication type=“book”type=“book”>><title>XML in action</title><title>XML in action</title>

<price <price currency=“USD”currency=“USD”>49.99</price>>49.99</price></ publication ></ publication >

Values must be double or single quotedValues must be double or single quoted

XML ExampleXML Example

<?xml version=“1.0” encoding=”UTF-8” ?><?xml version=“1.0” encoding=”UTF-8” ?><library><library>

<book><book><title>XML in action</title><title>XML in action</title><price currency=“USD”>49.99</price><price currency=“USD”>49.99</price><isbn>0-7356-0562-9</isbn><isbn>0-7356-0562-9</isbn><rating scale=“5”>3</rating><rating scale=“5”>3</rating>

</book></book><book><book>

<title>Essentail XML</title><title>Essentail XML</title><price currency=“USD”>34.95</price><price currency=“USD”>34.95</price><isbn>0-201-70914-7</isbn><isbn>0-201-70914-7</isbn><rating scale=“5”>4</rating><rating scale=“5”>4</rating>

</book></book></ library > </ library >

RootRootRootRoot

Book elementBook elementBook elementBook element

Currency attribute for Currency attribute for price elementprice element

Currency attribute for Currency attribute for price elementprice element

Processing instructionProcessing instructionProcessing instructionProcessing instruction

Child elements Child elements of Bookof Book

Child elements Child elements of Bookof Book

Valid vs. Well Formed XMLValid vs. Well Formed XML

Well formed:Well formed:Valid XML Valid XML syntaxsyntax

Valid document:Valid document:ContentContent of document valid conform of document valid conform specification of documentspecification of document

A valid document is automatically a well A valid document is automatically a well formed documentformed document

A well formed document is not always a A well formed document is not always a valid documentvalid document

Document specificationsDocument specifications

Describes structure and contents of XML Describes structure and contents of XML documentdocument

Parsers can use schema’s to validate a Parsers can use schema’s to validate a documentdocument

Validation is optionalValidation is optional Think if/where validation should take placeThink if/where validation should take place Document Type Definitions (DTD), part of Document Type Definitions (DTD), part of

XML 1.0 standardXML 1.0 standard

DTD exampleDTD 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 IssuesDTD Issues

Good DTD’s are difficult to write (Good DTD’s are difficult to write (EExtended xtended BBackus ackus NNaur aur FForm notation)orm notation)

DTD’s are not extensible and many DTD’s are not extensible and many limitationslimitations

Most important limitation is lack of data Most important limitation is lack of data typestypes

XML SchemasXML Schemas

Alternative for DTD’sAlternative for DTD’s XML is used to describe the structure of the XML is used to describe the structure of the

document, no need to learn new language document, no need to learn new language or use other toolsor use other tools

Lifts most limitations of DTD’s (data types )Lifts most limitations of DTD’s (data types ) XSD, XSD,

XML schema specificationXML schema specification W3C recommendationW3C recommendation

XDRXDR Early MS version of XSDEarly MS version of XSD

<Schema ><Schema >

<ElementType name=“title" content="textOnly“><ElementType name=“title" content="textOnly“><ElementType name=“isbn" content="textOnly”/><ElementType name=“isbn" content="textOnly”/>

<ElementType name=“book" content="eltOnly"> <ElementType name=“book" content="eltOnly"> <element type=“title"/><element type=“title"/><element type=“isbn"/> <element type=“isbn"/>

</ElementType> </ElementType>

</Schema> </Schema>

XML-Data Schemas simple exampleXML-Data Schemas simple example

XML ParsersXML Parsers

Parse XML documentParse XML document Validate XML syntax (always)Validate XML syntax (always) Validate content (optional)Validate content (optional) Access dataAccess data Update dataUpdate data Translate data (XSL)Translate data (XSL)

XML Parser typesXML Parser types

Two different parser modelsTwo different parser models

Document Object Model (DOM)Document Object Model (DOM) Complete document in memoryComplete document in memory Easy access for applicationsEasy access for applications Queries on dataQueries on data TranslationsTranslations

Simple API for XML (SAX)Simple API for XML (SAX) Generates event per parsed elementGenerates event per parsed element Large documentsLarge documents Batch processingBatch processing More difficult to use than DOMMore difficult to use than DOM

Document Object ModelDocument Object Model

DOM defines logical structure of a parsed DOM defines logical structure of a parsed XML documentXML document

DOM defines how data can be accessed and DOM defines how data can be accessed and manipulatedmanipulated

Provides standardized API (level 1, 2 and 3)Provides standardized API (level 1, 2 and 3) DOM can also be used to create or modify DOM can also be used to create or modify

XML documentsXML documents

Document Object ModelDocument Object Model

documentdocument

root noderoot node

nodenode

nodenode

nodenode

nodenode

nodenode

nodenode

nodenodeNode lists

A node can contain child nodes or text

Querying the DOM through XPathQuerying the DOM through XPath

XPath declarative language for locating XPath declarative language for locating nodes and fragments in XML treesnodes and fragments in XML trees

Allow you to locate nodes by:Allow you to locate nodes by: Absolute or relative positionAbsolute or relative position Element or attribute typesElement or attribute types Element or attribute valuesElement or attribute values Combinations using boolean operatorsCombinations using boolean operators

Also used in XSL, XPointer and XLink Also used in XSL, XPointer and XLink specificationsspecifications

XPath examplesXPath examples

All books in the current contextAll books in the current contextbook (equal to ./book)book (equal to ./book)

All books anywhere in the documentAll books anywhere in the document//book//book

All books with specified element valueAll books with specified element valuebook[title=“Essential XML”]book[title=“Essential XML”]

or a specified attribute valueor a specified attribute valuebook[@type=“paperback”]book[@type=“paperback”]

or just having the attributeor just having the attributebook[@type]book[@type]

The first 3 booksThe first 3 booksbook[index()<4]book[index()<4]

Extended Stylesheet Language XSLExtended Stylesheet Language XSL

Similarities with CSS, but more powerfulSimilarities with CSS, but more powerful Applies translations to data that matches a Applies translations to data that matches a

patternpattern Close to becoming a standard (draft status Close to becoming a standard (draft status

W3C)W3C)

XSL translationsXSL translations

XSLT is based on pattern matching and XSLT is based on pattern matching and templatestemplates

A template rule consist of a pattern and a A template rule consist of a pattern and a templatetemplate

Processor finds best matching pattern and Processor finds best matching pattern and applies related template for translationapplies related template for translation

XSL stylesheet exampleXSL stylesheet example

<xsl:stylesheet….>… <xsl-template match=“title”> <tr><td><b><xsl-value-of select=“text()”/></td></tr>…</xsl:stylesheet>

<xsl:stylesheet….>… <xsl-template match=“title”> <tr><td><b><xsl-value-of select=“text()”/></td></tr>…</xsl:stylesheet>

<?xml-stylesheet type="text/xsl“ href=“books.xsl"?><?xml-stylesheet type="text/xsl“ href=“books.xsl"?> <books> <book><title>Essential XML</title></book> <book><title>XML in action</title></book></books>

<?xml-stylesheet type="text/xsl“ href=“books.xsl"?><?xml-stylesheet type="text/xsl“ href=“books.xsl"?> <books> <book><title>Essential XML</title></book> <book><title>XML in action</title></book></books>

<tr><td><b>Essential XML</td></tr><tr><td><b>XML in action</td></tr>

<tr><td><b>Essential XML</td></tr><tr><td><b>XML in action</td></tr>

XML DataXML Data

XSLXSLstyle sheetstyle sheet

(partial)(partial)

HTMLHTMLoutputoutput

++

==

XSL usageXSL usage

Formatting and displaying XML data as HTML, Formatting and displaying XML data as HTML, PDF, etc.PDF, etc.

Converting XML document:Converting XML document: Other XML document structures Other XML document structures

(XML->XML)(XML->XML) Other data formats (CSV, Edifact)Other data formats (CSV, Edifact)

MS Biztalk mapping editor generate XLS to MS Biztalk mapping editor generate XLS to convert XML, Flat file and Edifact documents to convert XML, Flat file and Edifact documents to XML and back.XML and back.

XML ApplicationsXML Applications

XML in real applicationsXML in real applications SSimple imple OObject bject AAccess ccess PProtocolrotocol Microsoft Biztalk 2000Microsoft Biztalk 2000

Note this is not a training on SOAP and BiztalkNote this is not a training on SOAP and Biztalk

Software integrationSoftware integration

Today’s middlewareToday’s middleware Vendor and language dependedVendor and language depended

• COM+ v.s. EJBCOM+ v.s. EJB• Interoperability problemsInteroperability problems

Was not designed to use over the internetWas not designed to use over the internet• Reliable communicationsReliable communications• FirewallsFirewalls

ComplexComplex

SOAPSOAP

Simple Object Access ProtocolSimple Object Access Protocol Invoking object methods using XML and HTTP Invoking object methods using XML and HTTP Specification written by Microsoft, IBM, Software Specification written by Microsoft, IBM, Software

and Developmentorand Developmentor Vendor and middleware independency (the end Vendor and middleware independency (the end

of middleware battles ?)of middleware battles ?) Supported and available Supported and available todaytoday from most major from most major

vendors (MS,IBM,IONA etc.)vendors (MS,IBM,IONA etc.) Core technology in Microsoft .NET web servicesCore technology in Microsoft .NET web services

SOAPSOAP

Vendor AVendor A Vendor BVendor B

This whole process is transparent for client and component

ClientClientapplicationapplication ComponentComponent

XML/HTTPXML/HTTP

22

2. Soap proxy intercepts call and constructs and transmits XML request message

SoapSoaplistenerlistener

33

3. Soap listener receives, parses and validates request

44

4. Listener calls component message

566

5. Listener takes result of call and constructs and transmits XML response

6. Proxy receives and parses response and returns result to client

SoapSoapproxyproxy

11

1. Client application makes call

Simple SOAP Request Simple SOAP Request

POST /StockQuote HTTP/1.1 POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8“ Content-Type: text/xml; charset="utf-8“ Content-Length: 323 Content-Length: 323 SOAPAction: Some-Namespace-URI#SOAPAction: Some-Namespace-URI#GetLastTradePrice GetLastTradePrice

<SQ:Envelope <SQ:Envelope xmlns: SOAP ="http://schemas.xmlsoap.org/soap/envelope/" xmlns: SOAP ="http://schemas.xmlsoap.org/soap/envelope/" SQ :encodingStyle="http://schemas.xmlsoap.org/soap/encoding/“> SQ :encodingStyle="http://schemas.xmlsoap.org/soap/encoding/“>

< SQ :Body>< SQ :Body>

<m:<m:GetLastTradePriceGetLastTradePrice xmlns:m="Some-Namespace-URI"> xmlns:m="Some-Namespace-URI"> <symbol> <symbol>MSFTMSFT</symbol></symbol> </m:GetLastTradePrice> </m:GetLastTradePrice>

</ SQ :Body></ SQ :Body>

</ SQ :Envelope> </ SQ :Envelope> GetLastTradePrice(“MSFT”)

EnvelopeEnvelope

BodyBody

HTTP headersHTTP headers

Simple SOAP ResponseSimple SOAP Response

HTTP/1.1 200 OKHTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8“Content-Type: text/xml; charset="utf-8“Content-Length: nnnnContent-Length: nnnn

<SP:Envelope<SP:Envelopexmlns:SP="http://schemas.xmlsoap.org/soap/envelope/"xmlns:SP="http://schemas.xmlsoap.org/soap/envelope/"SP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">SP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<SP:Body><SP:Body>

<m:<m:GetLastTradePriceResponseGetLastTradePriceResponse xmlns:m="Some-Namespace-URI">xmlns:m="Some-Namespace-URI">

<Price> <Price>160.95160.95</Price></Price> </m:GetLastTradePriceResponse> </m:GetLastTradePriceResponse>

</SP:Body></SP:Body>

</SP:Envelope></SP:Envelope>

Result

HTTP headersHTTP headers

EnvelopeEnvelope

BodyBody

What Is Biztalk ?What Is Biztalk ?

Biztalk Community (Biztalk.org)Biztalk Community (Biztalk.org) Library for business document specificationLibrary for business document specification Stimulate reuseStimulate reuse Submit and retrieve document specificationsSubmit and retrieve document specifications 400+ third-party XML business documents400+ third-party XML business documents 150+ registered organizations150+ registered organizations

Biztalk FrameworkBiztalk Framework XML Specification for document routing and exchange XML Specification for document routing and exchange

(SOAP 1.1 compliant)(SOAP 1.1 compliant)

Biztalk ServerBiztalk Server Microsoft server product for processing, transforming, Microsoft server product for processing, transforming,

signing, routing of documentssigning, routing of documents

B2B challengesB2B challenges

My companySuppliers

Customers

Business to BusinessBusiness to Business

Different data format (EDI, CSV, XML…)Different data format (EDI, CSV, XML…) Different document structuresDifferent document structures Different protocolsDifferent protocols Different encryption technologiesDifferent encryption technologies Different operating systems Different operating systems Legacy ERP and other back office systemsLegacy ERP and other back office systems

Design time toolsDesign time tools Schema, transformation definitionSchema, transformation definition

Document processing serverDocument processing server MessagingMessaging

CommunicationCommunication TransformationTransformation RoutingRouting EncryptionEncryption

WorkflowWorkflow OrchestrationOrchestration

Biztalk ServerBiztalk Server

Biztalk ServerBiztalk Server

XSL Engine

XSLmapXSL

Map

BiztalkMapper

ParserParser

InternalInternalXMLXMLdocdoc

SerializeSerializer

InternalInternalXMLXMLdocdoc

EDI EDI docdoc

CSVCSVfilefile

XML XML docdoc

InboundInbounddocumentdocument

EDI EDI docdoc

CSVCSVfilefile

XML XML docdoc

OutboundOutbounddocumentdocument

DocspecDocDoc

specspec

Biztalkeditoreditor

XML in BiztalkXML in Biztalk

XML in BiztalkXML in Biztalk

VisioVisioDiagramDiagram

SchedulerScheduler

XLANGRuntime

XLANGXLANGscheduleschedule

ApplicationsApplications

BiztalkBiztalkMessagingMessaging

CompileCompile

XML in Biztalk ServerXML in Biztalk Server

XML for describing all in- and outbound XML for describing all in- and outbound business documents as an extended Data-business documents as an extended Data-SchemaSchema

XSL for document translationsXSL for document translations XML as internal format for all processed XML as internal format for all processed

documents documents XLANG workflow schedulesXLANG workflow schedules

Biztalk demosBiztalk demos

Biztalk EditorBiztalk Editor Biztalk MapperBiztalk Mapper Biztalk OrchestrationBiztalk Orchestration

Things to read…Things to read…

XML in ActionXML in ActionMS-PressMS-Press

ISBN 0735605629ISBN 0735605629

Professional XMLProfessional XMLWROXWROX

ISBN 1861003110ISBN 1861003110

Understanding SOAPUnderstanding SOAPSAMSSAMS

ISBN 0672319225ISBN 0672319225

Essential XMLEssential XMLAddison WesleyAddison WesleyISBN 0201709147ISBN 0201709147

Places to go…Places to go…

http://www.w3c.orghttp://www.w3c.org (all mentioned standards)(all mentioned standards)

http://msdn.microsoft.com/http://msdn.microsoft.com/xmlxml (tutorials and reference on xml)(tutorials and reference on xml)

http://msdn.microsoft.com/soaphttp://msdn.microsoft.com/soap(tutorials and reference on xml)(tutorials and reference on xml)

http://www.biztalk.orghttp://www.biztalk.org(Biztalk organization)(Biztalk organization)

<QUESTIONS/><QUESTIONS/>

Biztalk OrchestrationBiztalk Orchestration

Biztalk EditorBiztalk Editor

Biztalk MapperBiztalk Mapper