0% found this document useful (0 votes)
28 views38 pages

Module 02-Creating Schemas

Uploaded by

zanko67
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views38 pages

Module 02-Creating Schemas

Uploaded by

zanko67
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module 2

Creating Schemas

Contents:
Lesson 1: Introduction to BizTalk Schemas 2-2
Lesson 2: Creating XML and Flat File Schemas 2-13
Lab: Creating and Configuring BizTalk Schemas 2-27
Information in this document, including URL and other Internet Web site references, is subject to change
without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-
mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any
real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or
should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without
limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into
a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying,
recording, or otherwise), or for any purpose, without the express written permission of Microsoft
Corporation.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft
makes no representations and warranties, either expressed, implied, or statutory, regarding these
manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or
product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to
third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the
contents of any linked site or any link contained in a linked site, or any changes or updates to such sites.
Microsoft is not responsible for webcasting or any other form of transmission received from any linked site.
Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply
endorsement of Microsoft of the site or the products contained therein.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights
covering subject matter in this document. Except as expressly provided in any written license agreement
from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks,
copyrights, or other intellectual property.

©2006 Microsoft Corporation. All rights reserved.

Microsoft, ActiveX, BizTalk, Excel, InfoPath, IntelliSense, Internet Explorer, MSDN, Outlook, PivotTable,
PowerPoint, SharePoint, Visio, Visual Basic, Visual C#, Visual Studio, Windows, Windows NT, and Windows
Server are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or
other countries.

All other trademarks are property of their respective owners.


MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–1

Module objectives After completing this module, students will be able to:
■ Describe how BizTalk uses XML and identify the types of XML message types
supported by BizTalk.
■ Create an XML schema by using the BizTalk Editor and create a flat file
schema by using the Flat File Schema Wizard.

Overview Microsoft® BizTalk® Server 2006 can receive messages formatted as XML, flat files, or as
Electronic Document Interchange (EDI). Regardless of the format of the incoming
message, the BizTalk orchestration and messaging engine always processes messages in
XML format. This requires that a schema be defined in order to convert the message to
XML format that can be processed by BizTalk. In the case of flat file or EDI messages,
XSD (XML Schema Definition) annotations are used within the schemas to provide the
additional information required by the relevant parsers. This module provides the
knowledge and skills necessary for developers to create XML and flat file schemas.
MCT USE ONLY. STUDENT USE PROHIBITED
2–2 Module 2: Creating Schemas

Lesson 1: Introduction to BizTalk Schemas

Lesson objectives After completing this lesson, students will be able to:
■ Describe XML terminology as it pertains to BizTalk.
■ Explain what an XML namespace is.
■ Explain how BizTalk uses XML namespaces.
■ Describe how BizTalk uses XML and what is defined in BizTalk XML schema.
■ Identify the types of schemas that BizTalk supports.
■ Identify the types and characteristics of flat file messages that can be
processed by BizTalk.

Overview Creating schema definitions for the messages to be processed by BizTalk is usually the
first step in developing an integration solution. This lesson provides a review of XML
terminology that you may already be familiar with and identifies how BizTalk
implements XML standards. In this lesson, you will learn how BizTalk uses namespaces
as well as the various schema types that can be created for use by BizTalk.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–3

Reviewing XML Terminology

Overview BizTalk Server was one of the first applications specifically designed to work with data
in XML format. All documents (messages) that will be internally processed by BizTalk
must first be converted to XML. All XML artifacts that are created by BizTalk are fully
World Wide Web Consortium (W3C) compliant. This means that schemas created
using other tools can generally be used by BizTalk and vice versa.

XML Terminology The following are some of the terms and XML features supported by BizTalk Server
2006:

■ Namespace. An XML namespace is a W3C standard for providing uniquely named


elements and attributes in an XML instance. An XML instance may contain
element or attribute names from more than one XML vocabulary. If each
vocabulary is given a namespace, the ambiguity between identically named
elements or attributes can be resolved.
■ Element. An XML element is a construct used to organize information in a
hierarchical manner. XML elements can either be simple data types (such as
strings, decimals, and unsigned bytes) as defined in W3C standards, or they may
be a complex type containing other elements and/or attributes. Elements and
attributes are case sensitive; that is, Customer is not the same element name as
customer or CUSTOMER.
■ Attribute. An XML attribute is a construct used to associate additional information
contained with an XML element. Unlike elements, attributes cannot be nested.
Attributes can be associated with any of the simple data types, but because they
cannot be nested, they cannot be a complex type.
■ In the following example, Customer is an element with a value of Contoso. ID is an
attribute of the Customer element and has a value of 12345.

<Customer ID=“12345”>Contoso</Customer>
MCT USE ONLY. STUDENT USE PROHIBITED
2–4 Module 2: Creating Schemas

■ XML Schema Definition Language (XSDL). The XML schema definition language is
used to create schemas that represent the message formats that BizTalk will
process. Schemas define nodes such as required and optional fields, recurring
fields, and order. An instance message can be validated against an XSD to verify
that the format is valid.
■ XML Path Language (XPath). A language used for navigating through the hierarchy
of an XML document. For example, XPath can be used to select data in an XML
document that matches a certain criterion or to perform comparisons on retrieved
data.
■ Extensible Style Sheet Language Transformation (XSLT). A language definition for
XML data presentation and data transformations. Data presentation refers to how
data is formatted for display purposes in a specific format or style. Data
transformation refers to how data is transformed and exchanged. For example, a
purchase order could be converted from the format submitted by a trading partner
to the format required for your internal processes.
■ Document Object Model (DOM). The DOM provides a mechanism for navigating
through a message. When working with XML documents, the DOM is often used
to manipulate and query XML data. In BizTalk, when references are made to the
XML DOM, it is usually presumed that the message is being loaded into memory,
which results in slower processing than would be experienced if the data were
simply being streamed.
■ Web Services Description Language (WSDL). An XML format that describes the
capabilities and characteristics of a Web service. BizTalk can both publish and
consume Web services. That will be discussed in module 12.
■ Simple Object Access Protocol (SimpleSOAP). Defines a simple way of sending XML
messages across the Internet. SOAP is used in BizTalk Server in conjunction with
Web services.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–5

What Are XML Namespaces?

Overview An XML namespace is a W3C standard for providing uniquely named elements and
attributes in XML instances. XML namespaces help the BizTalk parser recognize the
proper schema or schemas as well as the tags that describe the structure of the data
inside the schema.

XML Namespaces XML messages (instances) may contain elements or attributes from more than one XML
vocabulary. If each vocabulary is given a namespace, the ambiguity between identically
named elements or attributes can be resolved. Element names within a namespace must
be unique.

A simple example of ambiguous elements would be to consider an XML instance that


contains references to a customer and an ordered product. Both the customer and
product elements could have a child element ID_number. References to the element
ID_number would therefore be ambiguous. By providing namespace references, the two
identically named but semantically different elements can be differentiated.

A namespace is declared by using the reserved XML attribute xmlns, the value of which
must be a Uniform Resource Identifier (URI). The declaration generally also includes a
short prefix with which elements and attributes can be identified, such as
xmlns:prod="http://adventure-works.com/customerOrderl". A maximum of one
namespace per schema (the default namespace) has no prefix. Any elements that are not
associated with a prefix will be presumed to belong to this namespace.
MCT USE ONLY. STUDENT USE PROHIBITED
2–6 Module 2: Creating Schemas

In the following example, the default namespace is http://adventure-works.com/


salesReport, whereas the products namespace (http://adventure-works.com/products)
has a prefix of prod. Without the namespace reference, the id identifier as used in the
customer and for the product would be ambiguous.

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

Many schemas used by BizTalk will have a reference to the W3C schema as shown
below. This reference adds support for W3C standards such as data types. Many BizTalk
schemas add references to other namespaces, as well."

xmlns:xs="http://www.w3.org/2001/XMLSchema"
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–7

How Does BizTalk Use XML Namespaces?

Overview As previously stated, BizTalk Server 2006 relies on the use of structured documents for
all internal messaging and orchestration operations. BizTalk uses W3C standard format
XSD but extends these by referencing additional namespaces. This results in schemas
that can still be used by other systems that understand XML and contain the additional
parameters required by BizTalk.

It should be noted that BizTalk can process strictly binary data—for example, .bmp files
and .pdf files through its routing functionality—from one location to another, and, in this
case, an XML schema is not required. This special handling requires the use of a pass-
through pipeline, which will be addressed in Module 5.

BizTalk Namespaces BizTalk adds the following namespaces to schemas as necessary to facilitate custom
functionality:

■ Target Namespace. When creating new schemas by using the BizTalk Editor, a
target namespace is added by default. This namespace is used in conjunction with
the root node name to uniquely identify the schema that relates to an inbound
message. Other operations within BizTalk also rely upon the target namespace.
■ Schema Extensions Namespace. When working with flat file and EDI schemas,
BizTalk will add a reference to the namespace shown below. This reference
provides the extensions necessary to define delimiters and positional settings
while still allowing the creation of XSD-compliant schemas that can be used by
applications other than BizTalk.

xmlns:b="http://schemas.microsoft.com/BizTalk/2003
MCT USE ONLY. STUDENT USE PROHIBITED
2–8 Module 2: Creating Schemas

How Does BizTalk Server When an XML message is received by BizTalk, the default namespace and root node
Determine Which name are extracted from the message. These values are concatenated
Schema Relates to an (targetNamespace#rootNodeName) and are referred to as the document type. It is
Incoming Message? important that the document type be unique so that BizTalk can non-ambiguously
determine the correct schema to be applied to the instance.

For non-XML message instances, a property defined in the pipeline will specify the
schema to be applied. Schemas used for flat file processing will have a root node name
and a target namespace and will therefore have a message type. These values should
provide for uniqueness but are not as critical. More information about these properties
will be provided later in this module.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–9

What Is a BizTalk XML Schema?

Overview XML schemas define the data structure for all XML business documents that you
exchange within and across organizations by using BizTalk. BizTalk also requires
schemas in order to have an XML representation of the flat file messages that it will be
processing.

BizTalk Schemas BizTalk can use schemas provided by trading partners or created by using other third-
party schema creation tools and applications. BizTalk includes tools for creating (or
modifying) schemas, including schemas to be used for flat file processing. Generally
speaking, it is a good idea to get in the habit of creating your schemas by using the
BizTalk Editor, which will be discussed in the next lesson.

A typical XML or flat file document might be a purchase order, an invoice, or any other
type of document representing a business transaction. Each unique document type
requires a separate schema that defines the records and fields contained in that
document.

The XML schema defines:

■ Elements and attributes, which are the building blocks of a schema.


■ Data types that appear in document instances, including simple and complex data
types.
■ Simple data types, which are data types that contain data and cannot be nested.
Examples of simple data types include xs:string, xs:int, and xs:long. Elements or
attributes can be simple data types.
MCT USE ONLY. STUDENT USE PROHIBITED
2–10 Module 2: Creating Schemas

■ Complex data types. Complex data types can contain both data and nested data.
For example, in the slide for this section, the Item element is a complex type
because it contains other elements. Only elements can be complex data types; an
attribute must be associated with one, and only one, element.
■ Namespace declarations and version information.
■ The ordering of tags in the document.
■ Fields that are mandatory or that may occur multiple times in a single document.

XSD Resources on the For more detailed information, go directly to the XSD specifications and primer
Web maintained on the W3C Web site.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–11

Supported BizTalk Schema Types

Schema Types BizTalk Server 2006 can natively process messages in XML flat file and EDI message
formats. BizTalk is extensible, and custom message types can be created in addition to
those supported out of the box.

XML Schema An XML schema defines the structure of XML messages. XML messages are arranged in
a hierarchical format that is defined by the schema. Messages are identified and
validated against their associated schema.

Flat File Schema A flat file schema defines the structure of messages that use a flat file format. Flat files
can be either delimited or positional. Because XSD does not natively support the flat file
structure, BizTalk uses the annotation capabilities of XSD to store this extra information
within the XSD schema. BizTalk defines a rich set of specific annotation tags that can be
used to store all of the required additional information.

EDI Schema BizTalk supports the creation and use of schemas that represent various EDI document
formats such as EDIFACT and X12. An EDI message is a variation of a text message and
does not use typical delimiters such as carriage returns and linefeeds. As with flat file
schemas, BizTalk uses the annotation capabilities of XSD to store the extra information
related to the format of the EDI messages.

EDI messages are beyond the scope of this course. Refer to the BizTalk help files for
additional information on EDI schemas and their uses.
MCT USE ONLY. STUDENT USE PROHIBITED
2–12 Module 2: Creating Schemas

Flat File Structures

Flat Files BizTalk Server is designed to make it easy to create schemas for positional flat files,
delimited flat files, and files that combine positional and delimited records. At the root
level, most flat files are delimited with a carriage return (for example UNIX files), a
linefeed, or, more frequently, both. For this reason, even files that contain mostly
positional data will be defined as delimited at the root.

Delimited Files A delimited file contains one or more fields separated by a delimiter character. This
character is frequently a comma (,) or pipe symbol (|) but could be any character.
BizTalk Editor does not read delimiters as part of the data. However, if the delimiter
character might appear within the instance as valid data, the data can be formatted so
that what would otherwise be a delimiter character is treated as valid data.

In the following example, the record contains four fields that are delimited with
commas. The fields are first name, last name, address, and a comment. The comment
contains a comma that would normally be interpreted as a delimiter. With the comment
enclosed in quotes (“”) the embedded comma is treated as part of the data.

John, Smith, 123 Main St, “BizTalk, Learning BizTalk Server 2006” ¶«

Positional Flat Files A positional flat file is made up of records that have a common end-of-record terminator
(delimiter), for example, a carriage return, and fields that have a fixed length. The
structure of an incoming file must be represented in the records and fields of the
schema so that the positional nature of the incoming file is preserved. Therefore, before
defining the structure of a flat file message, you must obtain a layout of the necessary
records and fields, and you must obtain a sample message for testing purposes.

In the following example, the record contains four fields that are positional delimited.
The first name is contained within the first 10 characters, the last name is the next 10
characters, the address is the following 20 characters, and 35 characters are left for the
comment. There is no need to enclose the comment in quotes because the position
within the instance is used to identify the separation between the fields. The record is
terminated with a combination of a carriage return and linefeed. Spaces in the example
were replaced by dots to make them more distinguishable.

John……Smith…..123.Main.St………Learning BizTalk Server 006…….¶«


MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–13

Lesson 2: Creating XML and Flat File Schemas

Lesson objectives After completing this lesson, students will be able to:
■ Identify the methods and tools available for creating XML and flat file schemas.
■ Generate a schema from an instance, an XDR schema, and a DTD file.
■ Create a schema by using the BizTalk Editor.
■ Create and combine schemas by using an existing schema structure.
■ Test and validate a schema and generate a sample instance message.
■ In this demonstration, you will see how to create a new BizTalk schema by using
BizTalk Editor. You will then see how to generate an instance of the schema and
test the schema against a sample message.
■ Create a schema by using the Flat File Schema Wizard.
■ In this demonstration, you will see how to create a flat file schema from a sample
message by using the Flat File Schema Wizard. You will then see how to test a flat
file schema.
■ Build a schema project into an assembly.

Overview In this lesson, students will learn how to use the BizTalk Editor and the Flat File Schema
Wizard to create BizTalk schemas. Students will also learn how to import existing
schemas and how to validate a schema and generate a schema instance.
MCT USE ONLY. STUDENT USE PROHIBITED
2–14 Module 2: Creating Schemas

Methods for Creating BizTalk XML Schemas

Schema Creation There are several ways in which you can create XML schemas in BizTalk Server 2006,
Methods and all will produce valid XSD schemas.

■ Generating a schema from an instance message. You can generate an XML schema
that corresponds to a particular instance message as long as that instance message
consists of well-formed XML.
■ Migrating an older XML-Data Reduced (XDR) schema to an XSD schema. You can
generate an XML schema for BizTalk Server 2006 from a schema that was
developed by using a previous version of BizTalk Server, which stored schemas in
XDR format. There is also an option to import from Document Type Definitions
(DTDs).
■ Creating a schema from scratch. You may use this method to create schemas for
messages for which no instances exist (possibly for internal use), or when the
other tools do not provide the necessary functionality. This would be a way of
creating schemas for XML, flat file, or EDI message types.
■ Creating a schema from scratch in conjunction with other schemas. When creating
complex schemas in the real world, you are more likely to build them by
modifying existing schemas by using the XSD language processes of importing,
including, and redefining schemas created previously.
■ Modify existing schemas. Regardless of the original source of any schema, the
BizTalk Schema Editor can be used to modify any valid XSD schemas.
■ Flat File Schema Wizard. The Flat File Schema Wizard is new to BizTalk Server
2006 and makes the creation of flat file schemas easier than ever before.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–15

Generating Schemas

Overview You can use the Generate Schemas dialog box to generate an XSD schema from one of
the following sources:

■ A well-formed XML instance message


■ A valid XDR schema
■ A valid DTD

In each of these cases, you would begin by adding a new generated item to the project
(right click the project, click Add, and then click New Generated Item) and then
browsing to locate the appropriate source file. A new schema with the same name as the
source file is created in the current solution. This schema can be renamed and, if
necessary, edited using the BizTalk Editor.

Generate a Schema from You may frequently be provided with an instance of an XML message for which no
an XML Instance schema is available. Because BizTalk always requires a schema for messages to be
processed, it will be necessary to generate a schema.

Generate Schemas from XDR was an early Microsoft standard for creating schemas. BizTalk Server 2000 and
XDR Schemas and DTD BizTalk Server 2002 used XDR to create schemas. XSD replaced XDR as the BizTalk
Files schema type starting with BizTalk Server 2004.

DTD was the first method used for validating documents, but it was not XML based and
has since been replaced by XSD. Although DTD was never a standard supported by
BizTalk, you may need to generate schemas that can validate messages generated using
DTD. This will produce a valid XSD to be used to validate instances that were created
based on a DTD.

Installing the Schema In the case of generating a schema from an XML instance or from a DTD file, it is
Generators for XML and necessary to install the schema generator before the first use. This is done by executing
DTD the appropriate script located at C:\Program Files\Microsoft BizTalk Server
2006\SDK\Utilities\Schema Generator. The script to install the schema generator for
well-formed XML messages is named InstallWFX.vbs. The script for generating a
schema from a DTD is named InstallDTD.vbs. After one of these scripts has been
executed, the appropriate generator is added in Microsoft Visual Studio®.
MCT USE ONLY. STUDENT USE PROHIBITED
2–16 Module 2: Creating Schemas

Creating a Schema by Using the BizTalk Editor

BizTalk Editor The BizTalk Editor automatically starts when you add a new schema to a BizTalk project
or open an existing schema in the project. You can use the BizTalk Editor to construct
and modify schemas without the need to learn all of the intricacies of XSD syntax. The
schema tree view is where you actively construct your schema. The XSD view is a read-
only view that represents the XSD syntax for the schema you are creating. When
creating or viewing flat file schemas, this view has an additional page named Flat File
that shows the delimiters and positional spacing in use.

BizTalk creates (and uses) fully W3C-compliant schemas. More information about
elements, attributes, data types, and schema design is available through many online
resources, including MSDN®.

Node Types The following menu choices are available when inserting nodes into a schema tree:

■ Field Element. Represents items of information that are simple in nature, such as
strings and numbers. You must use a record if the field has children or is repeated.
■ Field Attribute. Represents items of information that are simple in nature, such as
strings and numbers.
■ Child Record. A record is a container object (it cannot directly contain data) that
represents a collection of information. Records have the record icon associated
with them but are implemented as complex data type elements in the schema. A
record node can include element or attribute nodes based on simple data types
such as strings and numbers or can provide nesting of other complex data types
(sequence group or choice group).
■ Sequence Group. Contains other nodes that must appear in an instance message in
the same order in which they appear within the Sequence Group node.

Auto-Refresh When working with large schemas, auto-refresh might cause undesirable delays. In such
cases, you can disable automatic (continuous) refresh by clicking the link at the bottom
of the window. You can then click the refresh link as needed to refresh the XSD view.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–17

Using Multiple Schemas

Overview When your schemas become large and complex, or when schemas that represent
different types of instance messages have some sections in common, it can be useful to
include smaller schemas as building blocks in the larger ones. For example, you might
have several message types, each of which must contain a shipping address. You can
define the structure of a shipping address in a single smaller schema and then include
that schema within the other, larger schemas that define Order, Invoice, and Shipping
Notice messages. If this format changes, there is a single place to update rather than
having to update it at each occurrence.

Methods for Combining XSD provides the import, include, and redefine mechanisms for using multiple schemas
together. To be able to use schemas in this way, a target namespace must be specified for
the schema that will be imported. All three of these mechanisms are supported by
BizTalk Editor and are described here:

■ Import. Importing a schema provides a mechanism for using types defined in other
namespaces. An imported schema must have a Target Namespace that is different
from the importing schema, and no type modification is allowed to the imported
schema. This means that the imported schema cannot be modified in any way
once it has been imported. Use the import option to import a schema.
■ Include. Including a schema provides a mechanism for using types defined in the
same namespace as the including schema. The namespace of the included schema
can be empty, and, as in importing a schema, no type modification is allowed. Use
the include option to include a schema.
■ Redefine. Redefining a schema is similar to including a schema in that it provides a
mechanism for using types defined in the same namespace as the including
schema or for a namespace that is empty. However, you can use types defined in
the redefined schema as is, derive new types from them, or specify modifications
to them. Use the redefine option to redefine a schema.
MCT USE ONLY. STUDENT USE PROHIBITED
2–18 Module 2: Creating Schemas

Testing a Schema

Overview After you have constructed or added a schema into your BizTalk project, you can
perform several operations to make sure the newly created schema can correctly
validate data. Regardless of the format of the messages they represent, all schemas can
be tested using these methods. You can also generate sample instance documents,
which are helpful for comparing against provided instances.

Testing a Schema There are three tests that can be performed on any schema to validate that it is a well-
formed XSD and that it can be used to validate message instances. All of these tests can
be configured in the Microsoft .NET properties of the schema (accessed by right-clicking
the schema in Solution Explorer and then clicking Properties). To perform any of these
tests, right-click the schema in Solution Explorer, and then click the appropriate menu
command. The tests are as follows:

■ Validate Instance. This test is extremely useful when you have an XML or flat file
document with data that you would like to make sure is valid against a schema. In
many cases, you may find that one instance may validate while another will not,
for example, if the schema was generated with a message that had a single product
instance but you need to validate messages that also have multiple products.
■ Validate Schema. Schemas generated within BizTalk will always be valid XSD
because BizTalk enforces such rules as the schema is created; however, schemas
provided by others may not adhere to W3C standards as strictly. This step ensures
that the XSD has valid syntax. This step is most often necessary when adding an
existing schema into a project that was not built by the BizTalk Schema Editor.
■ Generate Instance. You can use this option to generate a sample instance message.
The sample instance message that is generated contains the element and attribute
structure specified by the schema and generates data type–specific sample data.
You can populate this generated instance with realistic data to use in the validate
instance process specified earlier or provide it to partners as a sample of the
messages your processes may output.

You might find it useful to add a folder named Messages inside the BizTalk project into
which the generated instances and test messages can be saved. In this way, the test
messages are always accessible for future testing and schema modification.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–19

Demonstration: Creating and Testing a Schema

Create a Schema 1. Start the Demos virtual machine.


2. In Microsoft Windows® Explorer, navigate to
C:\AllFiles\Democode\Module2\Demo, and then double-click Demo.sln.
3. In Solution Explorer, right-click the Messaging project, point to Add, and then
click New Item.
4. In the Add New Item dialog box, in the left pane, click Schema Files.
5. In the right pane, click Schema, change the Name to PurchaseOrder, and then
click Add.
6. In the left pane of BizTalk Editor, right-click the Root node, and then click
Rename.
7. Rename the node to PO.
The Root node should always be renamed.
8. Right-click the PO node, point to Insert Schema Node, and then click Child
Record.
9. Name the record Customer.
10. Right-click the PO node, point to Insert Schema Node, and then click Child
Record.
11. Name the record Address.
12. Right-click the PO node, point to Insert Schema Node, and then click Child
Record.
13. Name the record Items.
14. Right-click the Customer node, point to Insert Schema Node, and then click
Child Field Attribute.
15. Name the attribute FirstName.
MCT USE ONLY. STUDENT USE PROHIBITED
2–20 Module 2: Creating Schemas

16. Right-click the Customer node, point to Insert Schema Node, and then click
Child Field Attribute.
17. Name the attribute LastName.
18. Right-click the Customer node, point to Insert Schema Node, and then click
Child Field Attribute.
19. Name the attribute EmailAddress.
20. Right-click the Customer node, point to Insert Schema Node, and then click
Child Field Attribute.
21. Name the attribute PhoneNumber.
22. Right-click the Address node, point to Insert Schema Node, and then click Child
Field Element.
23. Name the element Street.
24. Right-click the Address node, point to Insert Schema Node, and then click Child
Field Element.
25. Name the element City.
26. Right-click the Address node, point to Insert Schema Node, and then click Child
Field Element.
27. Name the element State.
28. Right-click the Address node, point to Insert Schema Node, and then click Child
Field Element.
29. Name the element Zip.
30. Right-click the Items node, point to Insert Schema Node, and then click Child
Record.
31. Name the record Item.
32. Right-click the Item node, point to Insert Schema Node, and then click Child
Field Attribute.
33. Name the attribute SKU.
34. Right-click the Item node, point to Insert Schema Node, and then click Child
Field Attribute.
35. Name the attribute Description.
36. Click the Item record.
37. In the Properties window, scroll to the bottom of the list, set the Max Occurs
property to *, and then set the Min Occurs property to 1.
Setting the Min Occurs and Max Occurs properties as shown will make this a required
node within the message (it must occur at least once but can repeat infinitely).
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–21

Generate an Instance 1. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Properties.
2. In the Property Pages dialog box, click Output Instance Filename, and then click
the ellipsis button (…).
3. In the Select Input File dialog box, navigate to C:\AllFiles\DemoCode\
Module2, in the File name box, type PurchaseOrder-Gen, and then click Save.
4. In the Property Pages dialog box, click OK.
5. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Generate
Instance.
6. In Windows Explorer, navigate to C:\AllFiles\DemoCode\Module2, and then
open PurchaseOrder-Gen.xml.
Notice that each node has been populated with sample data.
7. Close Microsoft Internet Explorer®.

Test the Schema 1. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Properties.
2. In the Property Pages dialog box, click Input Instance Filename, and then click
the ellipsis button (…).
3. In the Select Input File dialog box, navigate to C:\AllFiles\Democode\Module2,
click Message1.xml, and then click Open.
This message represents a sample message from another system.
4. In the Property Pages dialog box, click OK.
5. In Solution Explorer, right-click PurchaseOrder.xsd, and then click Validate
Instance.
6. In the Output window, notice the message that reads Component invocation
succeeded, and then click the file:///C:\AllFiles\DemoCode\Module2\
Message1.xml link while holding CTRL.
The message is displayed.
MCT USE ONLY. STUDENT USE PROHIBITED
2–22 Module 2: Creating Schemas

Using the Flat File Schema Wizard

Overview The BizTalk Server toolset includes parsers and serializers for transforming data
between EDI or flat file formats and XML format. BizTalk Server 2006 solves the
problem of creating schemas for flat files by introducing a new tool called the Flat File
Schema Wizard.

Using the Flat File The Flat File Schema Wizard provides a series of steps that allow you to quickly generate
Schema Wizard an XSD for even quite complex flat file messages. Once this base XSD has been created,
it can then be opened by using either the BizTalk Schema Editor or another schema
design tool and edited further if necessary.

To launch the Flat File Schema Wizard, add a new item to an existing BizTalk project,
and choose the Flat File Schema Wizard option. In the BizTalk Flat File Schema Wizard
dialog box, browse to the flat file that you want to use as a source.

As you progress through the wizard, each record is identified, and then within these
records, each element or attribute is identified by name and data type. Each item that is
identified as a record or repeating record will cause the wizard to loop back through the
process until all nodes are identified.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–23

Demonstration: Creating and Testing a Flat File Schema

Create a Flat File Schema 1. If the Visual Studio solution is not already open, in Windows Explorer, navigate to
C:\AllFiles\Democode\Module2\Demo, and then double-click Demo.sln.
2. In Solution Explorer, right-click Messaging, point to Add, and then click New
Item.
3. In the Add New Item dialog box, in the left pane, click Schema Files.
4. In the right pane, click Flat File Schema Wizard, in the Name box, replace the
existing text with PurchaseOrderFF, and then click Add.
5. On the Welcome page of the Flat File Schema Wizard, click Next.
6. On the Flat File Schema Information page, click Browse.
7. In the Select a Flat File Document dialog box, browse to and click
C:\AllFiles\Democode\Module2\PurchaseOrderFF.txt, and then click Open.
8. On the Flat File Schema Information page, in the Record name box, replace the
existing text with Order, and then click Next.
9. On the Select Document Data page, ensure that the entire message is selected,
and then click Next.
10. On the Select Record Format page, ensure that By delimiter symbol is selected,
and then click Next.
11. On the Delimited Record page, ensure that the Child delimiter is set to {CR}{LF},
select the Record has a tag identifier check box, in the Tag box, type PO, and
then click Next.
MCT USE ONLY. STUDENT USE PROHIBITED
2–24 Module 2: Creating Schemas

12. On the Child Elements page, set the Element Type for each of the Elements in
the following table, and then click Next.
Element Name Element Type
PODetail Record
Address Record
Items Record

13. On the Schema View page, ensure that PODetail is selected, and then click Next.
14. On the Select Document Data page, click Next.
15. On the Select Record Format page, ensure that By delimiter symbol is selected,
and then click Next.
16. On the Delimited Record page, in the Child delimiter list, click the comma (,)
symbol, and then click Next.
17. On the Child Elements page, set the Element and Data Types for each of the
Elements in the following table, and then click Next.
Element Name Element Type Data Type
OrderNumber Field attribute string
CustomerName Field attribute string
OrderDate Field attribute date

18. On the Schema View page, ensure that Address is selected, and then click Next.
19. On the Select Document Data page, click Next.
20. On the Select Record Format page, click By relative positions, and then click
Next.
21. On the Positional Record page, click the position to the left of each of the
elements. You should have an arrow in each of the following positions: 0 (default),
24, 39, 41.
22. Click Next.
23. On the Child Elements page, set the Element Types for each of the Elements in
the following table, and then click Next.
Element Name Element Type
Street Field element
City Field element
State Field element
Postal Field element

24. On the Schema View page, ensure that Items is selected, and then click Next.
25. On the Select Document Data page, click Next.
26. On the Select Record Format page, ensure that By delimiter symbol is selected,
and then click Next.
27. On the Delimited Record page, using the drop-down list, change the Child
Delimiter to , (comma), and then click the Record has a tag identifier check box.
28. In the Tag box, type Items, and then click Next.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–25

29. In the error dialog box, click OK.


The Flat File Schema Wizard parses the message to verify that the tag identifier is valid
and case-sensitive. Because “Items” is not found within the record, an error is displayed.
30. In the Tag box, type ITEMS, and then click Next.
31. On the Child Elements page, set the Element Types for each of the Elements in
the following table, and then click Next.
Element Name Element Type
Item Repeating Record
Items_Child2 Ignore

32. On the Schema View page, ensure that Item is selected, and then click Next.
33. On the Select Document Data page, click Next.
34. On the Select Record Format page, ensure that By delimiter symbol is selected,
and then click Next.
35. On the Delimited Record page, using the drop-down list, change the Child
Delimiter to | (pipe symbol), and then click the Record has a tag identifier
check box.
36. In the Tag box, type ITEM, and then click Next.
37. On the Child Elements page, set the Element Types for each of the Elements in
the following table, and then click Next.
Element Name Element Type
ISBN Field element
Description Field element
Qty Field element
Price Field element

38. Click Finish.

Test the Flat File Schema 1. In Solution Explorer, right-click PurchaseOrderFF.xsd, and then click Properties.
In the PurchaseOrderFF.xsd properties window, notice that the Input Instance Filename
property is the same file that was used to create the schema by using the Flat File Schema
Wizard.
2. Click OK.
3. In Solution Explorer, right-click PurchaseOrderFF.xsd, and then click Validate
Instance.
4. In the Output window, hold the CTRL key, and then click the Validate Instance
succeeded for schema PurchaseOrderFF.xsd, file: link.
The sample message appears in the center pane.
5. In the Output window, hold the CTRL key, and then click the Validation
generated XML output link.
The flat file message is displayed in an XML format. Notice the repeating Item nodes.
6. Close the Visual Studio solution and all other open windows.
MCT USE ONLY. STUDENT USE PROHIBITED
2–26 Module 2: Creating Schemas

Building a BizTalk Project

Overview A BizTalk project can contain artifacts of many different kinds including schemas, maps,
orchestrations, and pipelines. Before using these artifacts in the messaging and
orchestration engines, the project needs to be built into an assembly.

Building a BizTalk Project Building the project creates a dynamic-link library (DLL) with the same name as the
project. The DLL is created in the projectName\bin\Deployment folder. For example, if
the EAICBR solution contains a project named EAISchemas, the resulting assembly
would be named \EAISchemas\bin\Deployment\EAISchemas.dll.

If there are any build errors or warning messages, the Task List window will list these
errors and warnings, and double-clicking a task will show you the location of the error
or warning. Make sure that you test all schemas in the project with known document
instance(s) before compiling and deploying the project.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–27

Lab: Creating and Configuring BizTalk Schemas

Scenario Each type of message processed by a BizTalk server application requires an XML schema
that defines the structure of the message. In this lab, you will create a BizTalk Server
project that will contain your schemas. Adventure Works has defined an internal sales
order message format for which you will create a schema. Next you will use the Flat File
Schema Wizard to create a schema that represents the format of the sales orders
submitted by the Adventure Works stores. Finally, you will generate a schema from a
sample loan application message.

Start the Virtual Machine 1. On the Start menu, point to All Programs, and then click Microsoft Virtual PC.
2. Click the virtual machine 2933A-2, and then click Start.
3. Once the virtual machine starts, press <RIGHT>ALT+DELETE.
4. Log on using the user name Administrator and the password Pa$$w0rd.
MCT USE ONLY. STUDENT USE PROHIBITED
2–28 Module 2: Creating Schemas

Exercise 1: Creating a New BizTalk Project


Overview A BizTalk Server project contains BizTalk Server artifacts. In this exercise, you will create
a new Microsoft Visual Studio 2005 solution and a new project that uses the BizTalk
Server Project template. This project will contain the schemas that you will create in the
following exercises.

Create a Blank Solution 1. On the Start menu, point to All Programs, point to Microsoft Visual Studio
2005, and then click Microsoft Visual Studio 2005.
2. On the File menu, point to New, and then click Project.
3. In the New Project dialog box, in the Project types pane, click BizTalk Projects,
click the Empty BizTalk Server Project template, and then create a new project
using the information in the following table.
Property Value
Name Messaging
Location C:\AllFiles\LabFiles\Lab2
Create directory for solution <checked>
Solution Name AdvWorks

4. Click OK to create and open the new project.

Configure Project 1. In Solution Explorer, right-click the Messaging project, and then click Properties.
Properties 2. In the Messaging Property Pages window, change the Assembly Name and
Default Namespace to AdvWorks.Messaging, and then click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–29

Exercise 2: Creating an XML Schema


Overview You can define an XML schema by manually defining each node, or by importing or
including other schemas. In this exercise, you will define schema nodes for the
Adventure Works sales order message and import nodes from an existing schema that
contains customer information.

Create the SalesOrder 1. In Solution Explorer, right-click the Messaging project, point to Add, and then
Schema click New Folder.
2. Rename the folder Messages.
3. In Solution Explorer, right-click the Messages folder, point to Add, and then click
Existing Item.
4. In the Add Existing Item dialog box, navigate to C:\AllFiles\LabFiles\Lab2, in
the Files of type list, click All Files, and then double-click SalesOrder1.xml.
This is a sample message of the schema that you will build in this exercise.
5. In Solution Explorer, double-click SalesOrder1.xml to open the message.
Examine the structure of the message.
6. In Solution Explorer, right-click the Messaging project, point to Add, and then
click New Item.
7. In the Add New Item dialog box, in the Categories pane, click Schema Files, and
then, in the Templates section, click Schema.
8. In the Name box, type SalesOrder.xsd to name the schema.
9. Click Add to open the blank schema in BizTalk Editor.
The schema tree (left pane) and XSD view (right pane) appear in BizTalk Editor. Also,
the new schema (SalesOrder.xsd) is added to Solution Explorer.

Define the SalesOrder 1. In the Schema tree (left pane), right-click the Root node, click Rename, and then
Schema Structure rename the node to SalesOrder.
The Root node should always be renamed with a meaningful name that represents the
type of document described by the schema. When possible, use a root node name that is
unique throughout the enterprise.
2. Right-click the SalesOrder (root) node, point to Insert Schema Node, and then
click Child Record.
3. Rename the record to Detail.
4. Repeat steps 2 and 3 to create two more records and name them Record and
Items.
5. Right-click the Detail node, point to Insert Schema Node, and then click Child
Field Attribute.
6. Rename the attribute to StoreNumber.
7. Repeat steps 5 and 6 to create four more attributes under the Detail record and
name them as follows: Employee, OrderNumber, OrderType, and OrderDate.
8. Right-click the Items node, point to Insert Schema Node, and then click Child
Record.
9. Rename the record to Item.
MCT USE ONLY. STUDENT USE PROHIBITED
2–30 Module 2: Creating Schemas

10. Right-click the Item node, point to Insert Schema Node, and then click Child
Field Attribute.
11. Rename the attribute to Qty.
12. Repeat steps 10 and 11 to create three more attributes under the Item record and
name them as follows: SKU, Price, and ExtendedPrice.
13. Right-click the Items node, point to Insert Schema Node, and then click Child
Field Element.
14. Rename the element to Comment.
15. Repeat steps 13 and 14 to create two more elements under the Items record and
name them OrderTotal and TermOfLoan.
16. On the File menu, click Save All.

Import the Customer 1. In Solution Explorer, right-click the Messaging project, point to Add, and then
Information from click Existing Item.
another Schema 2. In the Add Existing Item dialog box, browse to and add C:\AllFiles\LabFiles\
Lab2\CustomerInfo.xsd.
You may have noticed that the sample message contains a CustomerInfo record with
several fields; the CustomerInfo schema contains all of these fields.
3. In BizTalk Editor, click the <Schema> node of the SalesOrder schema.
4. In the Properties window, click the Imports property, and then click the ellipsis
(…) button.
5. In the Imports dialog box, verify that XSD Import is selected from the list, and
then click Add.
6. In the BizTalk Type Picker dialog box, expand Messaging, expand Schemas,
click AdvWorks.Messaging.CustomerInfo, and then click OK twice.
7. In the SalesOrder schema, click the Record node.
8. In the Properties window, click the Data Structure Type property, and then in
the list, click ns0:CustomerInfo (Reference).
9. On the File menu, click Save All.

Validate the Schema ■ In Solution Explorer, right-click SalesOrder.xsd, and then click Validate Schema.
You can use the Validate Schema command to determine whether a schema contains any
internal inconsistencies or has other issues that might prevent it from being used
effectively for processing instance messages. All schemas created by using the BizTalk
Schema Editor will always be valid, but this is a good way to verify that the schemas you
receive from other sources are recognizable to BizTalk.

Generate a Sample 1. In Solution Explorer, right-click SalesOrder.xsd, and then click Properties.
Instance 2. In the SalesOrder.xsd Property Pages dialog box, in the Output Instance
Filename box, type C:\AllFiles\LabFiles\Lab2\SalesOrder-Gen.xml, and then
click OK.
3. Right-click SalesOrder.xsd, and then click Generate Instance.
A sample instance message is saved in C:\AllFiles\LabFiles\Lab2, and a link to the
XML instance is shown in the Output window. Hold the CTRL key, and click the link to
open the resulting XML file.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–31

Validate the Sample 1. Right-click SalesOrder.xsd, and then click Properties.


Instance Message 2. In the SalesOrder.xsd Property Pages dialog box, in the Input Instance
Filename box, type C:\AllFiles\LabFiles\Lab2\SalesOrder1.xml, and then
click OK.
3. Right-click SalesOrder.xsd, and then click Validate Instance.
The results of the instance validation are displayed in the output window. This step
validates the schema against an actual XML file.
MCT USE ONLY. STUDENT USE PROHIBITED
2–32 Module 2: Creating Schemas

Exercise 3: Creating a Flat File Schema


Overview BizTalk Server can also process messages in positional or delimited formats (flat files).
In this exercise, you will use the Flat File Schema Wizard to create a schema that defines
the structure of flat file messages sent from the Adventure Works stores.

Create the SalesOrder_FF 1. In Windows Explorer, navigate to and open C:\AllFiles\LabFiles\Lab2\


schema SalesOrder_FF_Sample.txt.
2. Examine the structure of the file, and then close Notepad.
3. In Solution Explorer, right-click the Messaging project, point to Add, and then
click New Item.
4. In the Add New Item dialog box, in the Templates section, click Flat File Schema
Wizard.
5. In the Name box, type SalesOrder_FF.xsd, and then click Add.
6. On the Welcome to the BizTalk Flat File Schema Wizard page, click Next.
7. On the Flat File Schema Information page, in the Instance file box, browse to or
type C:\AllFiles\LabFiles\Lab2\SalesOrder_FF_Sample.txt.
8. In the Record name box, type SalesOrder, and then click Next.
9. On the Select Document Data page, ensure that the entire contents of the
document are selected, and then click Next.
10. On the Select Record Format page, verify that By delimiter symbol is selected,
and then click Next.
11. On the Delimited Record page, ensure that the Child Delimiter is set to {CR}{LF},
and then click Next.
12. On the Child Elements page, change the Element Names and Element Types as
follows:
Element Name Element Type
OrderDetail Record
CustomerInfo Record
Products Record
Comment Field element

13. Click Next.

Define the OrderDetail 1. On the Schema View page, ensure that the OrderDetail record is selected, and
Record Structure then click Next.
2. On the Select Document Data page, ensure that the first line of content is
selected, and then click Next.
3. On the Select Record Format page, verify that By delimiter symbol is selected,
and then click Next.
4. On the Delimited Record page, set the Child Delimiter to , (comma), and then
click Next.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–33

5. On the Child Elements page, change the Element Names and Element Types as
follows:
Element Name Element Type
StoreNumber Field Attribute
OrderNumber Field Attribute
Cash_Cred Field Attribute
EmployeeName Field Attribute
TotalOrder Field Attribute

6. Click Next.

Define the CustomerInfo 1. On the Schema View page, ensure that the CustomerInfo record is selected, and
Record Structure then click Next.
2. On the Select Document Data page, ensure that the second line (name and
address) is selected, and then click Next.
3. On the Select Record Format page, verify that By relative positions is selected,
and then click Next.
4. On the Positional Record page, set start positions for the elements at 5, 30, 34, 59
69 and 71 and then click Next.
5. On the Child Elements page, change the Element Names and Element Types as
follows:
Element Name Element Type
ID Field Element
CustomerName Field Element
MonthsAtResidence Field Element
Address Field Element
Town Field Element
State Field Element
ZipCode Field Element

6. Click Next.

Define the Products 1. On the Schema View page, ensure that the Products record is selected, and then
Record click Next.
2. On the Select Document Data page, ensure that the third line (products) is
selected, and then click Next.
3. On the Select Record Format page, verify that By delimiter symbol is selected,
and then click Next.
4. On the Delimited Record page, set the Child Delimiter to , (comma).
5. Select the Record has a tag identifier check box, in the Tag box, type
PRODUCTS, and then click Next.
6. On the Child Elements page, change the Element Name to Product, change the
Element Type to Repeating record for the first element, set the Element Type for
the second element to Ignore and then click Next.
MCT USE ONLY. STUDENT USE PROHIBITED
2–34 Module 2: Creating Schemas

Define the Product 1. On the Schema View page, ensure that the Product record is selected, and then
Record click Next.
2. On the Select Document Data page, ensure that the data following the
PRODUCTS tag is selected, and then click Next.
3. On the Select Record Format page, click By delimiter symbol, and then click
Next.
4. On the Delimited Record page, set the Child Delimiter to | (pipe symbol).
5. Select the Record has a tag identifier check box, in the Tag box, type PRODUCT,
and then click Next.
6. On the Child Elements page, change the Element Names and Element Types as
follows:
Element Name Element Type
Quantity Field Attribute
ItemNumber Field Attribute
PriceEach Field Attribute

7. Click Next.
8. Click Finish.
9. On the File menu, click Save All.

Validate the Sample 1. In Solution Explorer, right-click SalesOrder_FF.xsd, and then click Properties.
Instance Message 2. In the SalesOrder_FF.xsd Property Pages dialog box, in the Input Instance
Filename box, notice that the file is the same as the sample instance used to
generate the schema with the Flat File Schema Wizard, and then click OK.
3. Right-click SalesOrder_FF.xsd, and then click Validate Instance.
The results of the instance validation are displayed in the output window. This step
validates the schema against a sample flat file.
4. In the Output window, hold CTRL and click the link to the right of Validation
generated XML output to view the XML representation of the flat file instance.
MCT USE ONLY. STUDENT USE PROHIBITED
Module 2: Creating Schemas 2–35

Exercise 4: Generating a Schema from an XML Message Instance


Overview BizTalk can generate a schema based on an existing XML message instance. In this
exercise, you will generate a schema based on a sample loan application message.

Install the Well-Formed ■ In Windows Explorer, navigate to C:\Program Files\Microsoft BizTalk Server
XML Schema Generator 2006\SDK\Utilities\Schema Generator, and then double-click InstallWFX.vbs.
A command window will appear briefly as the VB script is executed.

Create the LoanApp 1. In Windows Explorer, browse to and open C:\AllFiles\LabFiles\Lab2\


Schema LoanApp_Sample.xml.
This is a sample of the message that is evaluated against a set of business rules to
automatically approve or deny a loan application.
2. Close Internet Explorer.
3. In Solution Explorer, right-click the Messaging project, point to Add, and then
click Add Generated Items.
4. In the Add Generated Items dialog box, in the Categories pane, click Generate
Schemas, click the Generate Schemas template, and then click Add.
5. In the Generate Schemas dialog box, in the Document type list, click Well-
Formed XML, in the Input file box, browse to and add C:\AllFiles\LabFiles\
Lab2\LoanApp_Sample.xml, and then click OK.
6. In Solution Explorer, verify that a LoanApp_Sample schema, which represents
the sample message, has been created.
7. Rename LoanApp_Sample.xsd to LoanApp.xsd.
8. In Solution Explorer, click the LoanApp schema, and then in the Properties
window, type LoanApp in the Type Name box.
9. Save and Close the AdvWorks solution.

You might also like