module 2: creating schemas. overview lesson 1: introduction to biztalk schemas lesson 2: creating...

20
Module 2: Creating Schemas

Upload: mateo-oliver

Post on 01-Apr-2015

237 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Module 2:Creating Schemas

Page 2: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Overview

Lesson 1: Introduction to BizTalk Schemas

Lesson 2: Creating XML and Flat File Schemas

Page 3: 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?

Supported BizTalk Schema Types

Flat File Structures

Page 4: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

XML StandardsXML Standards

Reviewing XML Terminology

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)

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)

Page 5: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

<salesReport> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport"> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport"> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport" xmlns:prod="http://adventure-works.com/products"> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport" xmlns:prod="http://adventure-works.com/products"> <customer id="Fabrikam"> <sales> <id>widget1004</id> <unitsSold>100</unitsSold> <price currency="USD">35</price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport" xmlns:prod="http://adventure-works.com/products"> <customer id="Fabrikam"> <sales> <prod:id>widget1004</prod:id> <prod:unitsSold>100</prod:unitsSold> <prod:price prod:currency="USD">35</prod:price> </sales> </customer></salesReport>

<salesReport xmlns="http://adventure-works.com/salesReport" xmlns:prod="http://adventure-works.com/products"> <customer id="Fabrikam"> <sales> <prod:id>widget1004</prod:id> <prod:unitsSold>100</prod:unitsSold> <prod:price prod:currency="USD">35</prod:price> </sales> </customer></salesReport>

NamespacesNamespaces

What Are XML 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

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

Page 6: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

BizTalk Server

How Does BizTalk Use XML Namespaces?

Schema ATargetNamespace=“NewOrders”

Schema BTargetNamespace=“OrdersUpdate”

Message ATargetNamespace=“NewOrders”

Message ATargetNamespace=“NewOrders”

Message BTargetNamespace=“OrderUpdate”

Message BTargetNamespace=“OrderUpdate”

Message CTargetNamespace=“Inventory”

Message CTargetNamespace=“Inventory”

No Match

Page 7: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

What Is a BizTalk XML Schema?

BizTalk uses the XML schema definition language (XSD)

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema”>

</xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema”>

</xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified">

</xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified">

</xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item">

</xs:element></xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item">

</xs:element></xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item"> <xs:complexType> <xs:sequence>

</xs:sequence> </xs:complexType> </xs:element></xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item"> <xs:complexType> <xs:sequence>

</xs:sequence> </xs:complexType> </xs:element></xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item"> <xs:complexType> <xs:sequence> <xs:element name="Description" type="xs:string" /> <xs:element name="Quantity" type="xs:integer" /> <xs:element name="UnitPrice" type="xs:decimal" /> <xs:element name="ItemID" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element></xs:schema>

<xs:schema targetNamespace="http://contoso.com/invoice" xmlns:xs=“http://www.w3.org/2001/XMLSchema” attributeFormDefault="unqualified“ elementFormDefault="qualified"> <xs:element name="Item"> <xs:complexType> <xs:sequence> <xs:element name="Description" type="xs:string" /> <xs:element name="Quantity" type="xs:integer" /> <xs:element name="UnitPrice" type="xs:decimal" /> <xs:element name="ItemID" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element></xs:schema> <!-- XML Instance -->

<Item xmlns="http://contoso.com/invoice"> <Description>Widget</Description> <Quantity>10</Quantity> <UnitPrice>1.04</UnitPrice> <ItemID>A1234</ItemID></Item>

<!-- XML Instance -->

<Item xmlns="http://contoso.com/invoice"> <Description>Widget</Description> <Quantity>10</Quantity> <UnitPrice>1.04</UnitPrice> <ItemID>A1234</ItemID></Item>

Page 8: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Supported BizTalk Schema Types

Message Type DetailsXML

Supports native XML message typesDefined in XML Schema definition language (XSD)

Flat FileSupports delimited or positional file formatsXML tags used to represent valuesTag information stored using the annotation capabilities of XSD

EDISpecially formatted text message BizTalk supports EDIFACT and X12 formatsXSD annotations used to define format

Node Structure Start Length

Description Delimited 0 50

UnitPrice Delimited 50 10

Quantity Delimited 60 10

TotalPrice Delimited 70 10ItemID Delimited 80 10Status Delimited 99 1

UnitPrice

ItemDescriptionQuantity

TotalPriceItemID

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

Page 9: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Flat File Structures

Delimited flat filesDelimited flat files

Fields separated by a specified delimiter

Have a common end-of-record terminator

Fields separated by a specified delimiter

Have a common end-of-record terminator

John, Smith, 123 Main St., “Learning BizTalk Server 2010”John, Smith, 123 Main St., “Learning BizTalk Server 2010”

Positional flat filesPositional flat files

Fields are fixed length

Have a common end-of-record terminator

Fields are fixed length

Have a common end-of-record terminator

John Smith 123 Main St. Learning BizTalk Server 2010John Smith 123 Main St. Learning BizTalk Server 2010

Page 10: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

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

Page 11: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Methods for Creating BizTalk XML Schemas

Schema creation methodsSchema 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

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

Page 12: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Schema creation methodsSchema creation methods

XDR schema

DTD

A well-formed XML document

XDR schema

DTD

A well-formed XML document

Generating Schemas

Page 13: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Creating a Schema by Using the BizTalk Editor

XSD ViewXSD View

Schema Tree ViewSchema Tree View

Page 14: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Using Multiple Schemas

Method Usage

Import Accesses and uses types defined in the imported schemaProvides for using types from schemas in other namespaces

Include Accesses and uses types defined in the included schemaProvides for using types from schemas in the same namespace

Redefine Accesses and uses types defined in the redefined schema Provides for using types derived from a schema in the same namespace

Purchase Order

Date

Company

City

Ship ToContact

State

Zip

Unit Cost

ItemPart Number

Description

Weight

Page 15: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Testing a Schema

Create XML Create XML

Validate XSD Validate XSD

Validate XML Validate XML

Page 16: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

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

Page 17: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Flat File Schema WizardFlat File Schema Wizard

Using the Flat File Schema Wizard

Graphical tool for defining flat file schemasCan define schemas for delimited or positional flat files

Graphical tool for defining flat file schemasCan define schemas for delimited or positional flat files

Page 18: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

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

Page 19: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

Building a BizTalk Project

Building a projectBuilding 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

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

Compile

Build Project Build Project

.NETAssembly

.DLL

BizTalk ProjectBizTalk Project

XSD Schema

Page 20: Module 2: Creating Schemas. Overview Lesson 1: Introduction to BizTalk Schemas Lesson 2: Creating XML and Flat File Schemas

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