BizTalk Server- Schema

18
8/30/2014 1 BizTalk Message Schemas AboorvaRaja Ramar BizTalk Tutor

Transcript of BizTalk Server- Schema

Page 1: BizTalk Server-  Schema

8/30/2014

1

BizTalk – Message

Schemas

AboorvaRaja Ramar

BizTalk Tutor

Page 2: BizTalk Server-  Schema

CONTENTS

• XML schema in BizTalk Server

• BizTalk Schema Editor

• Document Schemas

• Envelop Schemas

• Property Schemas

• Flat File schemas

• Best Practices

8/30/2014

2

Page 3: BizTalk Server-  Schema

OVERVIEW OF SCHEMA

• BizTalk Server uses the XML Schema definition (XSD) language to define the structure of all messages that it processes, and refers to these definitions of message structure as schemas.

• Structured Messages are instances of schema created which is actual data organized in a xml format, which can take any form, large or small, and target a wide array of back-end systems and data stores.

• BizTalk Editor is designed to simplify the process of defining a message schema and validating whether a particular message conforms to that schema. In the process of defining schemas and validating messages.

8/30/2014

3

Page 4: BizTalk Server-  Schema

XML SCHEMA AND XML INSTANCE

8/30/2014

4

BizTalk uses the XML schema definition language (XSD)

An XML schema defines:

• Elements

• Attributes

• Data types

• Order of tags

• Mandatory fields

• Multiple occurrences

XML Schema

- - -

<xs:element name="Item">

<xs:complexType>

<xs:sequence>

<xs:element name="Description“ type="xs:string" />

<xs:element name="Quantity" type="xs:int" />

<xs:element name="UnitPrice" type="xs:string" />

<xs:element name="TotalPrice" type="xs:decimal" />

<xs:element name="ItemID" type="xs:long" />

</xs:sequence>

</xs:complexType>

</xs:element>

XML Instance

- -

<Item> <Description>Description_0</Description>

<Quantity>10</Quantity>

<UnitPrice>UnitPrice_0</UnitPrice>

<TotalPrice>10.4</TotalPrice>

<ItemID>10</ItemID>

</Item>

Page 5: BizTalk Server-  Schema

ABOUT SCHEMA

8/30/2014

5

• Schema Types:

XML: Supports native XML message types

Flat file: Supports both delimited and positional files

Envelope: Supports all the above file types

Property: Schema in which properties or attributes are promoted so that they can be used as key elements

Multiple Schemas:

Multiple schemas can be present in a Biztalk solution

Import: Schema from other namespaces can be imported into another schema (Data structure type)

Include: Schema from the same namespace can be included in another schema (Data structure type)

Redefine: Schemas from the same namespace can be can be included into another schema to derive the properties (Base data type)

Page 6: BizTalk Server-  Schema

CREATING BIZTALK XML SCHEMAS

8/30/2014

6

• Schema creation steps:

Create schema from scratch using BizTalk Editor

Promoting a schema property

Validating a schema

Generate an instance message from schema

Building a Schema Project

Page 7: BizTalk Server-  Schema

CREATING SCHEMA USING BIZTALK EDITOR

8/30/2014

7

Schema Tree View

XSD View

Page 8: BizTalk Server-  Schema

PROMOTING A SCHEMA PROPERTY

8/30/2014

8

Page 9: BizTalk Server-  Schema

TESTING A SCHEMA

8/30/2014

9

9

Validate XSD

Create XML Create XML

Page 10: BizTalk Server-  Schema

CREATING SCHEMA AND INSTANCE

8/30/2014

10

• Validate Schema: --

• In Solution Explorer, right-click the schema that you want to validate, and then click Validate Schema.

• In the Output window, view the results. Success and error messages are displayed in this window.

• Validate Instance:--

• In Solution Explorer, right-click the schema, and then click Properties. The <Schema file name.xsd> Property Pages dialog box opens.

• If necessary, in the <Schema file name.xsd> Property Pages dialog box, expand the Generalsection of the General tab by clicking its plus (+) icon.

• In the Input Instance Filename property value field, either type the name of a file or use the ellipsis (...) button at the right end of the value field to browse for a file that contains the instance message to be validated against the schema, and then click OK.

• In Solution Explorer, right-click the schema name, and then click Validate Instance.

• In the Output window, view the results. Success and error messages are displayed in this window.

• Generate Instance:--

• In Solution Explorer, right-click the schema for which you want to generate an instance message, and then click Generate Instance.

• In the Output window, view the results. Success and error messages are displayed in this window.

Page 11: BizTalk Server-  Schema

BUILDING A SCHEMA PROJECT

8/30/2014

11

• Build Project

BizTalk Project

XSDSchema

Compile

.NETAssembly

DLL

Building a Project

Compiles the project items (schemas)

Creates an assembly (DLL file)

Stores the assembly DLL in the project subfolder (…\bin\Development)

Displays any errors or warnings in the task list

Page 12: BizTalk Server-  Schema

DOCUMENT SCHEMAS

8/30/2014

12

• An XML Schema described the structure of an XML document.

• A document schema is like any regular schema.

• A document schema is used to define a message. It is a definition on an Xml

message with optional extensions for flat files, EDI file, etc that enable the parsers to

convert the native format into Xml.

Page 13: BizTalk Server-  Schema

ENVELOPE SCHEMAS

8/30/2014

13

• XML Envelope can be used to combine multiple XML documents into single, valid

XML instance message. Without an envelope to wrap multiple documents within a

single root tag, an XML instance message containing multiple documents would not

qualify as well- formed XML.

• You can create an envelope schema in all of the same ways that you can create

an XML schema for a business document.

• To define a schema as an envelope schema, you need to set the Envelope

property of the Schema node to the value Yes.

Page 14: BizTalk Server-  Schema

PROPERTY SCHEMAS

8/30/2014

14

• A property schema enables you to define promoted properties in a common location and

have them referenced by other schemas.

• A property schemas can have namespace but not record or attributes.

• Elements define in the property schema have a name and type.

Promoted property Vs Distinguished fields

• In BizTalk you can promote a property as either distinguished or promoted properties.

Distinguished fields

• In general use distinguished fields if you want to just use them in Orchestration.

• No restriction in filed length.

• No participation in routing

• No separate property schema

Promoted Properties

• These are generally used with routing (send port filters), tracking, correlation etc.

• Field restriction (255)

• Separate property schema

Page 15: BizTalk Server-  Schema

FLAT FILE SCHEMAS

8/30/2014

15

Although BizTalk is based on the use of XML message formats internally, and you are strongly encouraged to use XML for the creation of new messages, in some circumstances you need to work with flat files.

A flat file, unlike an XML file, does not have any visible inherent structure. A flat file's structure is evident from its usage and also requires some domain knowledge to understand its representation.

Creating structure also applies to flat files, as does the information regarding record and field node properties.

But where data fields in XML messages are known to be delimited with tags and attributes of known syntax, we know little more about delimited and positional files than that they follow certain conventions.

A flat file structure is of several types: Delimited flat file, Positional flat file, A flat file with combination of Delimited and Positional records.

Page 16: BizTalk Server-  Schema

BEST PRACTICES

8/30/2014

16

Always assign a unique root name for each schema

Use versioning information in the root node name

Promote only the properties needed for content based routing

Use distinguished fields only when required in an orchestration

Test the validity of a schema by using a known document instance

Included schemas must be from the same namespace

Imported schemas must be from different namespaces

Page 17: BizTalk Server-  Schema

8/30/2014

17

Page 18: BizTalk Server-  Schema

8/30/2014

18