200 likes | 436 Views
Module 2: Creating Schemas. Overview. Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas. Lesson 1: Introduction to BizTalk Schemas . Reviewing XML Terminology What Are XML Namespaces? How Does BizTalk Use XML Namespaces? What Is a BizTalk XML Schema?
E N D
Overview • Lesson 1: Introduction to BizTalk Schemas • Lesson 2: Creating XML and Flat File Schemas
Lesson 1: Introduction to BizTalk Schemas • Reviewing XML Terminology • What Are XML Namespaces? • How Does BizTalk Use XML Namespaces? • What Is a BizTalk XML Schema? • Supported BizTalk Schema Types • Flat File Structures
Reviewing XML Terminology XML Standards Elements Attributes Namespaces in XML XML Schema (XSD) XML Path Language (XPath) Extensible Stylesheet Language Transformations (XSLT) Document Object Model (DOM) SOAP Web Services Description Language (WSDL)
What Are XML Namespaces? Namespaces Provide unique names for elements and attributes Prevent naming conflicts with other schemas Use the xmlns attribute to declare the namespace the element belongs to A prefix is added to the declaration to remove ambiguity <salesReport> <customerid="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer> </salesReport> <salesReportxmlns="http://adventure-works.com/salesReport"> <customerid="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer> </salesReport> <salesReportxmlns="http://adventure-works.com/salesReport"xmlns:prod="http://adventure-works.com/products"> <customerid="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer> </salesReport> <salesReportxmlns="http://adventure-works.com/salesReport"xmlns:prod="http://adventure-works.com/products"> <customerid="Fabrikam"> <sales> <prod:id>widget1004</prod:id> <prod:unitsSold>100</prod:unitsSold> <prod:price prod:currency="USD">35</prod:price> </sales> </customer> </salesReport>
How Does BizTalk Use XML Namespaces? Message ATargetNamespace=“NewOrders” BizTalk Server Schema ATargetNamespace=“NewOrders” Message BTargetNamespace=“OrderUpdate” Schema BTargetNamespace=“OrdersUpdate” Message CTargetNamespace=“Inventory” No Match
What Is a BizTalk XML Schema? <xs:schematargetNamespace="http://contoso.com/invoice"xmlns:xs=“http://www.w3.org/2001/XMLSchema”> </xs:schema> • <xs:schematargetNamespace="http://contoso.com/invoice"xmlns:xs=“http://www.w3.org/2001/XMLSchema”attributeFormDefault="unqualified“elementFormDefault="qualified"> • </xs:schema> • <xs:schematargetNamespace="http://contoso.com/invoice"xmlns:xs=“http://www.w3.org/2001/XMLSchema”attributeFormDefault="unqualified“elementFormDefault="qualified"> • <xs:elementname="Item"> • </xs:element> • </xs:schema> • <xs:schematargetNamespace="http://contoso.com/invoice"xmlns:xs=“http://www.w3.org/2001/XMLSchema”attributeFormDefault="unqualified“elementFormDefault="qualified"> • <xs:elementname="Item"> • <xs:complexType> • <xs:sequence> • </xs:sequence> • </xs:complexType> • </xs:element> • </xs:schema> • <xs:schematargetNamespace="http://contoso.com/invoice"xmlns:xs=“http://www.w3.org/2001/XMLSchema”attributeFormDefault="unqualified“elementFormDefault="qualified"> • <xs:elementname="Item"> • <xs:complexType> • <xs:sequence> • <xs:elementname="Description"type="xs:string" /> • <xs:elementname="Quantity"type="xs:integer" /> • <xs:elementname="UnitPrice"type="xs:decimal" /> • <xs:elementname="ItemID"type="xs:string"/> </xs:sequence> • </xs:complexType> • </xs:element> • </xs:schema> BizTalk uses the XML schema definition language (XSD) <!-- XML Instance --> <Item xmlns="http://contoso.com/invoice"> <Description>Widget</Description> <Quantity>10</Quantity> <UnitPrice>1.04</UnitPrice> <ItemID>A1234</ItemID> </Item>
Supported BizTalk Schema Types Node Structure Start Length Description Delimited 0 50 UnitPrice Delimited 50 10 Quantity Delimited 60 10 Item TotalPrice Delimited 70 10 Description Quantity Delimited 80 10 ItemID UnitPrice Delimited 99 1 Status TotalPrice ItemID Status ISA:00: :00: :01:1515151515 :01:515151 :041201:1217:U:00403:000032123:0:P:*~GS:CT:9988776655:1122334455:20041201:1217:128:X:004030~ST:831:00128001~BGN:00:88200001:20041201~N9:BT:88200001~TRN:1:88200001~AMT:2:10
Flat File Structures Delimited flat files Fields separated by a specified delimiter Have a common end-of-record terminator John, Smith, 123 Main St., “Learning BizTalk Server 2010” Positional flat files Fields are fixed length Have a common end-of-record terminator John Smith 123 Main St. Learning BizTalk Server 2010
Lesson 2: Creating XML and Flat File Schemas • Methods for Creating BizTalk XML Schemas • Generating Schemas • Creating a Schema by Using the BizTalk Editor • Using Multiple Schemas • Testing a Schema • Demonstration: Creating and Testing a Schema • Using the Flat File Schema Wizard • Demonstration: Creating and Testing a Flat File Schema • Building a BizTalk Project
Methods for Creating BizTalk XML Schemas Schema creation methods Create from scratch using BizTalk Editor Import or include existing types Generate from an instance message Migrate an older XDR schema to an XSD schema
Generating Schemas Schema creation methods XDR schema DTD A well-formed XML document
Creating a Schema by Using the BizTalk Editor Schema Tree View XSD View
Using Multiple Schemas Purchase Order Date Ship To Contact Item Company Part Number City Description State Unit Cost Zip Weight
Testing a Schema Validate XSD Validate XML Create XML
Demonstration: Creating and Testing a Schema In this demonstration, you will see how to: • Use the BizTalk Editor to createa schema • Validate and test a schema
Using the Flat File Schema Wizard Flat File Schema Wizard Graphical tool for defining flat file schemas Can define schemas for delimited or positional flat files
Demonstration: Creating and Testing a Flat File Schema In this demonstration, you will see how to: • Create a schema by using theFlat File Schema Wizard • Validate and test a flat file schema
Building a BizTalk Project Build Project BizTalk Project .NETAssembly XSD Schema Compile .DLL Building a project Compiles the project items (schemas, maps, orchestrations, pipelines) Creates an assembly (DLL file) Stores the assembly in the project subfolder (…\bin\Development) Displays any errors or warnings in the task list
Lab: Creating and Configuring BizTalk Schemas Exercise 1: Creating a New BizTalk Project Exercise 2: Creating an XML Schema Exercise 3: Creating a Flat File Schema Exercise 4: Generating a Schema from an XML Message Instance