HomeBrainDump Microsoft BizTalk Server 2004: Creating Sc...
Microsoft BizTalk Server 2004: Creating Schemas
In this tutorial from Microsoft Virtual Labs, you will learn how to use the BizTalk Schema Editor. You will start by creating a new BizTalk project. When you have finished, you will have created a custom schema for a sample company to meet requirements for submitting orders to a supplier.
Create an XML schema by using BizTalk Schema Editor.
Promote a schema property.
Create a file schema by using BizTalk Schema Editor.
Validate a schema and generate a sample instance message.
Build a schema project.
Scenario
Northwind Traders has chosen to create a custom schema to meet their business requirements for submitting orders to a supplier. In this lab you will create a BizTalk project for the schema, and then define a customer order schema to define the structure of messages (documents) to be exchanged within the solution.
You will also promote several of the schema properties so that the property values can be referenced for content based routing purposes in the BizTalk orchestration that you will create in later labs.
After you have created the schemas and promoted the schema properties, you will use BizTalk Editor to generate a sample instance message and validate the schemas to check for any inconsistencies.
Estimated time to complete this lab: 45 minutes
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will build a new solution for this project by using the Visual Studio .NET 2003 environment. First you will create a new blank solution, and then you will add a new project to the solution. This project will contain the schemas that you will create in the following exercises.
TasksDetailed steps
Set up lab.
Click inside the virtual machine window.
Press Right-ALT + DEL.
Type a password of pass@word1 and press Enter.
Use Windows Explorer to navigate to and run C:\Labs\Setup Scripts\SetupLab2.A.bat.
This script will erase the existing projects and artifacts in the C:\Labs\Work folder and copy all required artifacts and files for this lab into the C:\Labs\Work folder.
Close Windows Explorer.
Create a blank solution.
A solution may include only one BizTalk project, if the solution is relatively simple.
A solution may include many BizTalk projects, if the solution consists of numerous projects that are developed independently and then must be integrated later.
Click Start, point to All Programs, point to Microsoft Visual Studio .NET 2003, and then click Microsoft Visual Studio .NET 2003.
The Visual Studio .NET 2003 splash screen appears, and then Visual Studio .NET starts.
Click File | New | Blank Solution.
In the New Project dialog box, select the Blank Solution template.
In the Name field, type NWBusinessSolution as the solution name.
In the Location field, type C:\Labs\Work
Click OK to open the new solution.
Add a newBizTalk project to the solution.
Selecting the BizTalk project template exposes the BizTalk tools, such as BizTalk Mapper, within the Visual Studio .NET development environment, and invokes a BizTalk-specific compiler.
In Solution Explorer, right-click Solution 'NWBusinessSolution', point to Add, and then select New Project.
In the Add New Project dialog box, select the BizTalk Projects folder.
In the Templates pane, select Empty BizTalk Server Project.
In the Name field, type NWMessaging as the project name.
Click OK to open the new project.
A new project is added to Solution Explorer, and the project folder is created in C:\Labs\Work\NWBusinesSolution.
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will create a schema to define the structure of the shipping address record. You will also open an existing schema and use the import function to insert schema nodes within the existing schema.
TasksDetailed steps
Create the shipping address schema.
Selecting the Schema template causes BizTalk Editor to start.
In Solution Explorer, right-click the NWMessaging project, point to Add, and then select Add New Item.
In the Add New Item dialog box, in the Templates pane, select Schema.
In the Name box, type ShippingAddress.xsd to name the schema.
Click Open to open the blank schema in BizTalk Editor.
View the Properties pane.
The schema tree (left pane) and XSD view (right pane) appear in BizTalk Editor. Also, the new schema (ShippingAddress.xsd) is added to Solution Explorer.
Create the schema record.
The Root node should always be renamed using a meaningful name that represents the type of document described by the schema. When possible, use a root node name unique throughout the enterprise.
You can right-click an empty area of the Toolbar and select BizTalk Editor to display a floating toolbar of BizTalk Editor options.
In the Schema Tree, right-click the Root node, and then select Rename.
Type ShippingAddress as the new name, and then press Enter.
Right-click the ShippingAddress (root) node, point to Insert SchemaNode, and then select Child Field Element to add the following fields (repeat this step for each field element):
City
Country
Street
Email
Fax
State
Zip
Phone
The completed schema should look like this:
Click File | Save All.
Open an existing schema and import a new child record.
This allows you open an existing schema and use the import function to insert schema nodes within an existing schema.
You can show properties in alphabetic order by clicking the Alphabetic button at the top of the Properties window.
In Solution Explorer, right-click the NWMessaging project, point to Add, and then select Add Existing Item.
Navigate to C:\Labs\Work, and then double-click the CustomerOrder.xsd schema to add it to the project.
The schema is added to Solution Explorer.
In Solution Explorer, double-click CustomerOrder.xsd to open it in BizTalk Editor.
If the Properties window is not visible, then in BizTalk Editor right-click the <Schema> node of CustomerOrder.xsd, and then select Properties.
In the Properties window, click the Imports property, and then click the ellipsis (…) button.
In the Imports dialog box, verify that XSD Import is selected from the drop down box, and then click Add.
In the BizTalk Type Picker, expand Schemas, select NWMessaging.ShippingAddress, and then click OK.
In the Imports window, click OK.
Right-click the CustomerOrder root node, select Insert Schema Node, and then click Child Record.
Right-click the child record Record and click Properties.
In the Properties window, select the Data Structure Type property and, from the drop-down box, select ns1:ShippingAddress (Reference). The ShippingAddress record is added to the schema.
Click File | Save All.
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will promote schema properties so that the property values can be referenced by BizTalk messaging and orchestration. Promotion is a mechanism that you must use when you want to reference a specific value within a message instance and then use the value to make message routing decisions. Additionally, the promoted property will be visible by IntelliSense in Expression Editor when code is required in an orchestration.
TasksDetailed steps
Promote property fields.
The property fields are promoted so that their values can be referenced for content based routing purposes and orchestration.
The Property1 node in the PropertySchema.xsd is not used and can be deleted.
In the BizTalk Editor, in the Schema Tree, right-click the <Schema> node, and then select Expand Schema Node to show the entire schema.
Right-click the CustomerPONumber node, point to Promote, and then click Quick Promotion.
Click OK to add the property schema to the project.
The icon for the PO field has changed to indicate that the field has been promoted. Also, a new schema (PropertySchema.xsd) is added to the Solution Explorer.
Right-click the TotalOrderAmount node, point to Promote, and then click Quick Promotion.
Promote distinguished fields.
The distinguished fields are promoted so that their values can be referenced in an orchestration that you will create in later labs.
Right-click the <Schema> node, point to Promote, and then select Show Promotions.
Select the following fields from the Schema (left) pane, and then add them as distinguished fields:
Status
Comments
Click OK.
The completed schema should look as shown here
On the File menu, click Save All to save your work.
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will create a flat file schema to define the structure of a customer contact record.
TasksDetailed steps
Create the customer contact schema.
This creates the XSD schema that describes the XML structure that flat files will be converted to.
In Solution Explorer, right-click the NWMessaging project, point to Add, and then select Add New Item.
In the Add New Item dialog box, in the Templates pane, select Schema; and then, in the Name box, type CustomerOrderFlatFile.xsd and click Open.
In BizTalk Editor, right-click the <Root > node, and then rename the schema to Customers.
Right-click the Customers node, select Insert Schema Node, and then select Child Record.
Rename the child record to Customer.
Add the following Child Field Elements:
FirstName
MiddleName
LastName
ContactNo
Configure the schema as a flat file schema.
This creates properties for the schema node that map to XSD schema annotations.
You will use a child delimiter that specifies a carriage return (0D) and a line feed (0A).
Right-click the <Schema> node, and then select Properties.
In the Properties window, click the Schema Editor Extensions property, and then click the ellipsis (…) button.
In the Schema Editor Extensions window, select the Flat File Extension checkbox, and then click OK.
Right-click Customers and click Properties
In the Properties window, set the following properties:
Property
Value
Child Delimiter
0x0D 0x0A
Child Delimiter Type
Hexadecimal
Child Order
Postfix
Right-click Customer and click Properties.
In the Properties window, set the following properties:
Property
Value
Child Delimiter
,
Child Delimiter Type
Character
Child Order
Infix
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will use the Validate Schema command to determine whether the schemas contain any internal inconsistencies, or have other issues that might prevent them from being used effectively for processing instance messages. You will also generate a sample instance message for each of the schemas.
TasksDetailed steps
Validate the schema file.
Validating the schema insures that an XML document could be created that would be well-formed and valid against this particular schema.
In Solution Explorer, right-click CustomerOrder.xsd, and then select Validate Schema.
The results of the schema validation are displayed in the output window.
Generate a sample instance message for the schemas.
Generating a sample instance provides a visual test, as well as a document to pass through the process for testing.
Right-click the CustomerOrder.xsd, and then select Properties.
In the CustomerOrder.xsd Property Pages dialog box, in the Output Instance Filename box, type C:\Labs\Work\GeneratedCustomer Order.xml and then click OK.
Right-click the CustomerOrder.xsd schema, and then select Generate Instance.
A sample instance message is saved in C:\Labs\Work, and a link to the XML instance is shown in the Output window. Click the link while pressing Ctrl to open the resulting XML file.
Validate the sample instance message.
The CustomerOrder.xml XML file is provided so that you can check for errors in the schema you just created.
Right-click the CustomerOrder.xsd schema, and then select Properties.
In the CustomerOrder.xsd Property Pages dialog box, in the Input Instance Filename box, type C:\Labs\Work\CustomerOrder.xml and then click OK.
Right-click the CustomerOrder.xsd schema file, and then select Validate Instance.
The results of the instance validation are displayed in the output window. This step validates the schema against an actual XML file.
Validate the flat file sample instance.
The CustomerOrder.txt flat file is provided so that you can check for errors in the schema you just created.
a. Right-click CustomerOrderFlatFile.xsd, and then select Properties.
In the CustomerOrderFlatFile.xsd Property Pages dialog box, set the following properties:
Property
Value
Input Instance Filename
C:\Labs\Work\CustomerOrder.txt
Validate Instance Input Type
Native
Click OK.
Right-click the CustomerOrderFlatFile.xsd schema file, and then select Validate Instance.
The results of the instance validation are displayed in the output window. This step validates the schema against an actual flat file.
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.
In this exercise, you will create and assign a strong name for the BizTalk assemblies you are about to build. A strong-named assembly provides several security benefits. A strong name guarantees the uniqueness of the assembly by assigning a digital signature and a unique key pair. This also protects the lineage of the assembly by ensuring that no one else can generate a subsequent version of that assembly. And finally, a strong name provides a strong integrity check to guarantee that the contents of the assembly have not been changed since it was built.
TasksDetailed steps
Create a strong name assembly key file.
This creates a strong name public/private key pair, which is saved to an assembly key file.
Click Start | Programs | Microsoft Visual Studio .NET 2003 | Visual Studio .NET Tools | Visual Studio .NET 2003 Command Prompt.
The Visual Studio .NET command prompt appears.
At the command prompt, type cd C:\Labs\Work and then press ENTER.
Type sn -k Key.snk and then press ENTER.
A message appears, indicating that the key pair has been written to the key file (Key.snk).
Type Exit to close the Command Prompt.
Assign a strong name to the assembly.
This assigns the key file to the assembly. You must do this for each of the projects in this solution.
In Solution Explorer, right-click the NWMessaging project, and then select Properties.
In the left pane of the NWMessaging Property Pages page, click Assembly.
In the right pane, scroll down to the Strong name section, click the field to the right of Assembly Key File, and then click the ellipsis (…) button.
In the Assembly Key File dialog box, navigate to C:\Labs\Work\Key.snk, and then click Open.
Click OK to save changes.
Exercise 7 Building the Schema Project
Scenario
In this exercise, you will build the project to generate an assembly that contains the resources (the schemas) that you have just created. This also ensures that that there are no compile-time errors in the work you have completed so far.
TasksDetailed steps
Build the project.
The assembly is compiled into a DLL file and saved in the …\bin\Development folder within the project folder.
On the File menu, click Save All.
In Solution Explorer, right-click NWMessaging, and then select Build.
The results of the compiled schema project are displayed in the output window. Do not deploy this assembly, because deployment could affect later labs.
Close Visual Studio.
Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.