Wednesday, December 29, 2010

Orchestration Debugger

Working with the Orchestration Debugger

The following screenshot shows a typical debugging session in the Orchestration Debugger.

Orchestration Debugger with break point hit.

The Orchestration Debugger consists of three panes that are always present and two optional panes that appear when attached to an orchestration instance:

  • The Service pane displays the instance service name and GUID that uniquely identifies the orchestration instance, debug mode, orchestration state, whether the Orchestration Debugger is attached, and service options.

  • The Tracked Events pane lists the status of every action performed in the orchestration, such as whether it started or completed. As you select each of the rows in this pane, the corresponding shape in the Orchestration pane appears highlighted in green when the shape starts and blue when the shape finishes.

  • The Orchestration pane is where a visual representation of the orchestration is rendered with all of its shapes.

  • The Variable List pane appears when attached to an orchestration instance and displays the name, value, and type of the variable. The value indicates if the variable is null or, if not, then what kind of object it contains. Type is the Assembly.Namespace.Name of the object.

  • The Variable Properties pane appears when attached to an orchestration instance and displays properties for the variable that vary according to the type of object. For example, for messages this includes Message Parts (including Name, Properties, Size, Type, and Value) and Message Properties (including Context, Name, PartCount, Scope, Type, and Value).

You will likely focus on the Orchestration, Variable List, and Variable Properties panes when debugging orchestration instances. Using the Orchestration pane, you can determine how a message is flowing through an orchestration, while the Variable List and Variable Properties panes show current variables and their properties, values, and types. This is useful for debugging decision shape errors, determining what content is reaching a port, seeing the "before" and "after" messages in a transform operation, and other tasks.

Resuming an Orchestration Instance

To resume the execution of an orchestration in the Orchestration Debugger, click Debug on the menu and choose Continue. The instance will continue execution until either another breakpoint (either class-level or instance-level) is hit or the orchestration completes.

Aa953746.note(en-us,BTS.20).gifNote
Tracked events will not be refreshed until you click Refresh on the File menu.
Debugging a Called Orchestration

If the orchestration calls another orchestration, you can debug the called orchestration by right-clicking the call orchestration action in the Tracked Events pane and then clicking View Called Orchestration. In the orchestration below, the Call Orchestration shape is named CallOrchestration_1.

Viewing a called Orchestration in debug mode.

Right-clicking the corresponding Call event in the Tracked Event pane and then clicking View Called Orchestration causees the Orchestration Debugger to load the called orchestration. In the above orchestration, notice that the title bar displays the instance's GUID as well as #0. This number represents the orchestration being called; the original orchestration is always #0. When the called orchestration is brought up, it will be #1 and so on.

You can return to the calling orchestration by clicking Debug and choosing View Calling Orchestration in the Orchestration Debugger. This works recursively so if your original orchestration (#0) calls another orchestration (#1) that in turn calls another orchestration (#2), you would need to choose Debug | View Calling Orchestration twice.

Debugging an Orchestration Instance That is Suspended (Resumable)

Orchestration instances that are in the Suspended (Resumable) state can be debugged by the Orchestration Debugger by resuming the instance in debug mode.

To debug a Suspended (Resumable) orchestration instance
  1. Click Start, point to Programs, point to Microsoft BizTalk Server 2006, and then click Health and Activity Tracking.

  2. On the HAT tool menu, click Queries, and then choose Most recent 100 service instances or one of the other query choices as appropriate to your situation.

  3. In the search results, right-click an orchestration service instance that is in the Suspended (Resumable) state and then click Orchestration Debugger.

  4. From the Orchestration Debugger, click Debug and choose Resume in Debug Mode.

    The Orchestration Debugger opens the orchestration instance in debug mode as if a breakpoint had been reached.

  5. Debug the orchestration.

Debugging Orchestrations on a Remote Computer

You can use the Health and Activity Tracking tool to debug a remote computer provided the following conditions are met:

  • The BizTalk Server Administration tools have been installed.

  • You are a member of the BizTalk Server Administrators group on the computer where the BizTalkMsgDb exists.

  • The SQL Server instance has been configured to allow inbound network connections.

Aa953746.Caution(en-us,BTS.20).gifWarning
Grant access only to individuals that require access. For more information about HAT and security, see Security Considerations for Health and Activity Tracking.
To connect HAT to a remote computer
  1. Click Start, point to Programs, point to Microsoft BizTalk Server 2006, and then click Health and Activity Tracking.

  2. On the HAT tool menu, click Tools and choose Preferences. This will bring up the Preferences screen.

  3. Click Live Data, and then specify the Management SQL Server name and database name. In the example below, the HAT tool is configured to connect to the remote Management SQL Server BTS_MGMNT_SVR01 using the default management database named BizTalkMgmtDb.

    HAT Preferences screen
  4. Click OK.

Limitations of the Debugger

The Orchestration Debugger does not support the following scenarios:

  • Debugging inside of a Message Construction shape. You can set a breakpoint on the Message Construction shape.

  • Debugging inside of an atomic scope. You cannot set a breakpoint on shapes inside of an atomic scope or an orchestration that is defined as Atomic.

  • Setting a breakpoint on a Group shape. You can set a breakpoint on individual orchestration shapes inside of the Group shape.

  • Setting a breakpoint on a compensation block. You can set breakpoints on the actions inside of the compensation block.

  • Setting a breakpoint on a catch block. You can set breakpoints on the actions inside of the catch block.

You should also be aware of the following considerations when using the Orchestration Debugger:

  • If you track an orchestration modified without changing the version number, you must restart all the host instances to which the orchestration is enlisted. This ensures that any shape change in the newly deployed version displays correctly as you step through the Orchestration Debugger

  • When you attach to an instance in the Orchestration Debugger, any atomic scopes in the orchestration instance will cause gaps to appear in the tracked events list. This happens because events for the shapes inside atomic transactions do not get persisted until the scope commits and because the debugger reloads events onto the end of the list, so any gaps remain unfilled during the live session.

    Aa953746.note(en-us,BTS.20).gifNote
    You can eliminate gaps in the tracked events list by refreshing the view.

If you need to capture detailed information about program flow, variable contents, versions and other diagnostics you may want to use Debug and Trace statements as explained below.

Tuesday, December 28, 2010

BizTalk 2009 admin console is not working all of a sudden while deploying the release

BizTalk 2009 admin console is not working all of a sudden while deploying the release
  1. Full stop the application first.
  2. If an assembly is previously deployed there is no need to add it as a resource to the deployed application.
  3. First remove the previous version of the assembly from GAC (After stopping the application). Place the new assembly in the GAC.
  4. Then in the resource node select the assembly and click refresh.
  5. Browse the new version of the assembly.
  6. Then restart the application and the host instances.
  7. The new version of the assembly will execute.

BizTalk 2009 + SharePoint/WSS 3.0 integration

http://kentweare.blogspot.com/2009/10/biztalk-2009-sharepointwss-30.html

BizTalk Flat File Schema Wizard

I have found the Flat File Schema Wizard in BizTalk Server 2006 and BizTalk Server 2006 R2 to be extremely useful and figured that I would blog about it for anyone looking for an introduction to this feature.

Inside of BizTalk, the preferred message type is XML. If messages are in an XML format, BizTalk can do intelligent things with the messages. These "intelligent things" include routing the message based upon a promoted property, tracking elements in BAM or making logic decisions inside of an orchestration based on a particular value of a node.

Generally the way Flat Files are processed at Run-time are:

  1. Flat file is received by adapter configured to watch the receive location's URI
  2. A custom pipeline is required to disassemble Flat File into its XML equivalent
  3. BizTalk Orchestration(if non-pure messaging scenario chosen) would then pick up this XML equivalent version of the flat file. The message would then move through the business process.
  4. If/when BizTalk needed to send out a version of this XML message as a Flat file, a custom Send Pipeline would be required that would take the XML message and assemble the Flat File.
  5. In the Send Port adapter, this custom Send Pipeline would need to be configured in order for the Flat File to be delivered to the end point.

I will now walk you through what is required at design time in order to enable the runtime to support the processing of Flat Files:

1. In your Schema and Maps project, "Add a New Item"



2. On the left hand side, select "Schema Files" and then select "Flat File Schema Wizard" from the right hand side. In the bottom centre of the wizard, provide a name for this Flat File Schema.

3. The Wizard based interface will now appear which will walk you through defining your Flat File structure. Click on the "Next" button to continue.



4. You will need an instance, or sample, of the flat file that you are about to create a schema for. Browse for this file, provide a "Record" name and update the "Target namespace" as required.




5. The wizard will then load up your instance file to further break it down. In this step, you need to define how records are differentiated. Depending upon the complexity of your flat file, your record definition may be different from mine.
For my sample, the structure of my record is as follows:

CustomerID,DiscountGroup,Address,City,EmailAddress,PhoneNumber{CR}{LF}. Since each record is contained within one line I want to select the entire first line.


6. I then need to indicate how the record is delimited. In my scenario it is based upon a Carriage Return/Line Feed. Something to note here is that my source file is based upon a Windows File structure. Unix indicates the end of a line differently than Windows.

7. In the next step, I am providing exactly how the child delimiter is defined. Since this is a Windows based file, I will select "{CR}{LF}" . Other options include {CR}, {LF}, {TAB}, {SPACE}, {0x1A}, {}, {.}, {;} or you can provide your own symbol.

8. So at this point, I have defined what a Record looks like but I have not broken down the various elements that make up a record. By default "Repeating record" is not selected, so you will want to pull down the "Element Type" drop down to select it. If you do not do this step, you will not have the ability to break down your records into individual elements/attributes.

Also, if you want, rename the parent node for each record, modify the "Element Name" field to your desired name.



9. Select "Next" to continue to the next screen where you will be able to further define how each record is broken up.



10. So here is the start of breaking down the record into individual elements. You want to ensure that the {CR}{LF} symbols are not selected and click "Next".



11. Here is where you tell BizTalk how to parse the record. The two options are by delimiter symbol or relative. Since I am using a CSV file, I selected "By delimiter symbol". If you have a fixed width file, then you would want to select "By relative positions".



12. By default, the comma symbol is populated in the Child delimiter drop down. If you use a different like a pipe '' or a period '.' you can change this here.



13. In this screen, you are able to define each of the Elements/Attributes for your data. Much like any XSD, you are able to define the data types as you see fit. Also note, in the far right hand column, BizTalk is loading the contents of you sample row into the wizard for you to verify whether BizTalk has parsed it correctly.



14 BizTalk will then show you a break down of what your XML tree will look like. Once you click Finish the Schema will be available to you in your BizTalk solution.




15 You now have a Flat File Schema for use within BizTalk!



Since the Disassembling and Assembling of Flat Files occur within pipelines, having this Flat File schema will not do us much good until we create the pipelines to provide the conversion between Flat Files and XML.

I will now walk you through the process of creating a pipeline that will use the Flat File Schema that we just created.

In the sample project that I am using, I have 1 "master" solution and 4 projects that belong to the solution. I have broken it down based upon a popular project structure:

  • MapsAndSchemas
  • Orchestrations
  • Pipelines
  • Helper (.Net Assembly used for any helper/utility methods)

So within my Pipelines project, I need to add a reference to my Schemas project. This will allow me to use this schema in my Disassembly/Assembly stages of my pipeline.

1. Add a "New Item" to your Pipeline project(or applicable project)



2. On the left portion of the dialog box, select "Pipeline Files", In the top centre of the dialog box, select "Receive Pipeline" and then provide a meaningful name in the bottom of the dialog box.



3. The Pipeline component designer will load. You will then want to drag a "Flat file disassembler" control from your toolbox and release it in the "Disassemble" stage.



4. With the "Flat file disassembler" control selected, select your Flat File schema that you previously created from the "Document schema" drop down.


5. You would follow the same steps when creating your Send pipeline. The difference being that you would be dropping a "Flat file assembler" control onto the "Assemble" stage in the pipeline. You would select the same Flat File schema from the "Document schema" drop down.


Once you have deployed your solution, you will want to ensure that you select your custom pipelines in the Receive Locations/Send Ports that you expect to receive/send these flat files.

Functionality of Scope Shape in orchestration

There are several benefits of using a scope:
1. You encapsulate some of your code, and can declare local variablesand messages inside it, that will be garbage collected once the scopehas finished.
2. You can add exception handlers to scopes, to deal with anyeceptions that might occur.
3. You can have fewer persistance points, if you wrap for example tosend shapes inside one atomic shape, you only get one instead of twopersistance points.
4. If you have several shapes inside an atomic shape, BizTalk guaranteesthat all the shapes are executed or none of them. So there is anautomatic rollback of everything that happened inside the shape incase of a failure later on in the shape.

Monday, December 27, 2010

Parameters Not Showing in Call Rules Shape within BizTalk

I created a Business Rule, tested it, published and deployed it. Within my orchestration when I then tried to call the Rule and configure my Call Rules shape I was able to select the business policy but under the "Parameter Name" I could not see any parameter appearing.
To solve this issue, when importing the XSD in the Business Rule Composer make sure that the Document Type property matches the Fully Qualified Name of the schema.
Read more

Sunday, December 26, 2010

Biztalk Sample Programming

http://www.koders.com/csharp/fid8CCC9FDF8ACDACAC52A10E4C7E3A5511311A6E44.aspx?s=file

Backup BRE

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Utilities;
using System.IO;
using Microsoft.Build.Framework;

namespace BizTalk.BuildGenerator.Tasks.BRE
{
///
/// Task to ackup the BRE
///

public class BackupBRE : BaseBRETask
{
private string _FolderPath;

///

/// Task execute method
///

///
public override bool Execute()
{
if (!Directory.Exists(this._FolderPath))
throw new ApplicationException("The folder does not exist");

string folder = Path.GetFullPath(this._FolderPath);
Console.WriteLine("Backup Folder: " + folder);
string filePath = folder + @"\" + Guid.NewGuid().ToString();
BREManager mgr = base.CreateManager();
mgr.ExportAll(filePath);
return true;
}
///
/// This is the folder where the backup will be created
///

[Required]
public string FolderPath
{
get { return _FolderPath; }
set { _FolderPath = value; }
}
}
}

Import/Export and Deployment of Business Policies

How to Script Import/Export and Deployment of Business Policies

This section describes how to programmatically import/export and deploy policies using RuleSetDeploymentDriver.

The following example shows how to export a policy to a file.

using System;
using Microsoft.RuleEngine;
using Microsoft.BizTalk.RuleEngineExtensions;
namespace SimpleExport
{
class ExportPolicy
{
[STAThread]
static void Main(string[] args)
{
if (args.Length != 3)
Console.WriteLine("Format: PolicyName MajorVersion MinorVersion");
else
{
string policyName = args[0];
int majorRev = Convert.ToInt16(args[1]);
int minorRev = Convert.ToInt16(args[2]);
RuleSetInfo rsi = new RuleSetInfo(policyName,majorRev,minorRev);
Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd;
dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
string fileName = (rsi.Name + "-" + rsi.MajorRevision + "." + rsi.MinorRevision + ".xml");
dd.ExportRuleSetToFileRuleStore(rsi,fileName);
}
}
}
}

The following example shows how you can import and deploy a policy from a file.

using System;
using Microsoft.RuleEngine;
using Microsoft.BizTalk.RuleEngineExtensions;
namespace SimpleImport
{
class ImportPolicy
{
[STAThread]
static void Main(string[] args)
{
String filename = args[0];
Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd;
dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
SqlRuleStore sqlRuleStore = (SqlRuleStore) dd.GetRuleStore();
FileRuleStore fileRuleStore = new FileRuleStore(filename);
RuleSetInfoCollection rsic = fileRuleStore.GetRuleSets(RuleStore.Filter.All);
foreach (RuleSetInfo rsi in rsic)
{
RuleSet ruleSet = fileRuleStore.GetRuleSet(rsi);
bool publishRuleSets = true;
sqlRuleStore.Add(ruleSet,publishRuleSets);
dd.Deploy(rsi);
}
}
}
}



Understanding Rules BRE Priorities

Now, if you have done some critical thinking about what we have done so far, you should notice one important hint: the order at which rules will execute will actually change the final outcome.

If both Rules 1 and 2 will be evaluated to true, then RiskGrade will be set to RG1 or RG2 depending on which rule gets executed first. To solve such cases, you should always give your rules priorities.

Without priorities or with equal priorities, rules will be executed in a random order. Priorities are set by selecting each rule and setting its priority property in the Properties window. Higher priorities get executed first. In our current example, assume that we want Rule2 to execute first and Rule1 to come second. As such, give Rule2 priority 2 and Rule1 priority 1 using the Properties window.

Tuesday, December 21, 2010

List of Policies; List of Vocabularies

BizTalk Business Rules Engine Handy functions in .NET

Working with the BizTalk 2006 R2 BRE api, I find myself going back to this code to start of as a base. These 2 functions get ALL of the versions of the policies or vocabularies. If you want to work with only the latest, or the published ones, change the RulesStore.Filter enum to whatever your needs.

List of Policies

1: public void GetPoliciesList()
2: {
3: Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver breDriver =
4: new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
5: Microsoft.RuleEngine.RuleStore breStore = breDriver.GetRuleStore();
6:
7: Microsoft.RuleEngine.RuleSetInfoCollection colPolInfo = null;
8: colPolInfo = breStore.GetRuleSets(RuleStore.Filter.All);
9: foreach (RuleSetInfo pInfo in colPolInfo)
10: {
11: Trace.WriteLine(string.Format("bts- Info = [{0}].v.{1}.{2}",
12: pInfo.Name, pInfo.MajorRevision, pInfo.MinorRevision));
13:
14: //get the policies to extract rules
15: Microsoft.RuleEngine.RuleSet pol = breStore.GetRuleSet(pInfo);
16: Trace.WriteLine(string.Format("bts- Count = [{0}]", pol.Rules.Count)); 17: }
18: }

This is how to get a list of all policies published on the BRE database. Once you get all of the RuleSets, you can loop through each of them to retrieve the actual rules behind them. Before getting to the rules, you need to get a RuleSet out of the RuleSetInfo.

List of Vocabularies
1: public void GetVocabulariesList()
2: {
3: Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver breDriver = 4: new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver();
5: Microsoft.RuleEngine.SqlRuleStore sqlRuleStore = (SqlRuleStore)breDriver.GetRuleStore();
6:
7: Microsoft.RuleEngine.VocabularyInfoCollection colVocInfo = null;
8: colVocInfo = sqlRuleStore.GetVocabularies(RuleStore.Filter.All);
9: foreach (VocabularyInfo vInfo in colVocInfo)
10: {
11: Trace.WriteLine(string.Format("bts- vInfo = [{0}].v.{1}.{2}",
12: vInfo.Name, vInfo.MajorRevision, vInfo.MinorRevision));
13:
14: //get the vocabulary to extract collection of definitions
15: Microsoft.RuleEngine.Vocabulary voc = sqlRuleStore.GetVocabulary(vInfo);
16: Trace.WriteLine(string.Format("bts- Count = [{0}]", voc.Definitions.Count));
17: }
18: }


This is how to get a list of all vocabularies published on the BRE database. If you need to see how to get to all of the definitions on a particular vocabulary, see my previous post: How to access BRE Vocabularies from .NET.

Noticed that there are some subtle differences in how you retrieve each piece of information. For Policies you get a RuleStore while to get the Vocabularies you need to get a SQLRuleStore.

As usual, feedback is always welcome if you use this code.

Friday, December 17, 2010

How to Use BizTalk Flat File Schema Wizard.

http://msdn.microsoft.com/en-us/library/aa577898(BTS.10).aspx

Walkthrough: Creating a Flat File Schema From a Document Instance





This walkthrough shows you how to create a flat file schema from a document instance using the BizTalk Flat File Schema Wizard based on the following sample purchase order. For an introduction to the BizTalk Flat File Schema Wizard, see How to Use BizTalk Flat File Schema Wizard.


Sample Purchase Order

Each line of the purchase order ends with a carriage return line feed (CRLF), marked in green. The purchase order starts with a PO tag shown in red and followed by a date. Two repeating fixed positional fields contain customer information and are shown in purple. After the comment field, there is a repeating field starting with an ITEMS tag that contains multiple records delimited by commas (,) and data values separated by pipes (|), which are shown in blue.


Prerequisites


Before exercising this walkthrough, make sure the following software is installed and configured on your server:




  • Microsoft Visual Studio



  • Microsoft BizTalk Server with the following components installed:


    • Developer tools



To prepare the document instance for the walkthrough, copy the following to Notepad and save it as a text file.




PO1999-10-20
US Alice Smith 123 Maple Street Mill Valley CA 90952
US Robert Smith 8 Oak Avenue Old Town PA 95819
ITEMS,ITEM872-AA|Lawnmower|1|148.95|Confirm this is electric,ITEM926-AA|Baby Monitor|1|39.98|Confirm this is electric



To start the wizard




  1. In Microsoft Visual Studio, open the Solution Explorer.




  2. To add the new flat file schema, right-click the project, and select Add. Click New Item.




  3. In the Add New Item window, do the following:




    1. In the Categories section, select Schema Files.



    2. In the Templates section, select Flat File Schema Wizard.



    3. In the Name field, enter PurchaseOrder.xsd for the new schema.



    4. Click Add.





  4. When the BizTalk Flat File Schema Wizard opens, the Welcome Page appears. To skip this screen when running the wizard in the future, select the Do not show this introduction page again box. Click Next to continue.


    Welcome screen



Selecting Document Instance


To select purchase order instance





  • On the Flat File Schema Information screen, select your instance and enter the following information. When you are done, click Next to continue.




    • Instance file: Click the Browse button to locate the flat file from which the schema will be generated. Browse to the folder contains the text file you prepare in the Prerequisites section of Walkthrough: Creating a Flat File Schema From a Document Instance.



    • Record name: Type PO as it will be the schema root name.



    • Target namespace: Type http://Flat_File_Project.PurchaseOrder for schema target namespace.



    • Code page: Select UTF-8 (65001) from the drop down selection list.



    • Count positions in bytes: Check this box if you wish to count the positional data fields by bytes. By default, the positional data fields are counted in characters. In this walkthrough, leave the Count positions in bytes check box unchecked.



    Flat File Schema Information screen




Selecting Document Instance Data


To select purchase order data





  • On the Select Document Data screen, the contents of the flat file are displayed. Select the data needed for creating the schema, and then click Next.


    Flat File Schema Information screen









    noteNote

    If you would like to use the entire document instance, you can press Ctrl-A to select all.















    noteNote

    Check Wrap long lines box if you want to view the entire document instance content wrapped into the edit box through out the wizard.















    noteNote

    If you are creating the schema from an interchange instance, select only the part that represents the individual document structure.










Delimiting Record Data


To delimit purchase order record





  • As each line of the purchase order ends with a carriage return line feed (CRLF), select By delimiter symbol and then click Next on Select Record Format screen.


    Select Record Format screen




Specifying Record Data Property


To specify purchase order record property





  • On the Delimited Record screen, enter the following to define the first level of the schema and when you are done, click Next.




    • Child delimiter: Select {CR}{LF}.

      noteNote
      Child delimiter property is an editable box with drop down selection list contains a set of default values. The Child delimiter can be specified as a character or as a hexadecimal value. For example, \{ or {0x0D0A}.



    • Escape character: An escape character is a single character that suppresses any special meaning of the character that follows it. See Escape Characters for more information. Leave it blank for the walkthrough.

      noteNote

      When using \, {, and } for Child delimiter or Escape character, a back slash must be used. For example, \\, and \{.



    • Check Record has a tag identifier box and type PO in Tag. In a multiple records file, PO will be used to identify each individual record. Click Next to continue.



    Delimited Record screen




Defining Element Property in Record Data


To define the element in the purchase order record





  1. The wizard has identified four elements in the purchase order record; you must now define the element property. In the first row, do the following:




    1. Type date for the Element Name.



    2. Select Field element for Element Type.



    3. Select date from the drop-down selection list for Data Type.





  2. Repeat Steps a to c for the following elements. When you are done, click Next.


     
























    Element Name

    Element Type

    Data Type


    customer




    Repeating record












    Ignore








    items




    Record







    Child Elements screen









    noteNote

    You can select multiple rows and then change their Element Type to a single type by using the mouse and the Shift or Ctrl button.















    noteNote

    After you click Next on the Child Elements screen, you will not be able to click Back to redefine or make any changes to the child elements. You may need to close the wizard and launch the wizard again to define the flat file schema.








  3. After you complete the steps in this procedure, the first level of the schema is generated as shown in the following screenshot. Three unique elements are defined, and you will continue to further define the child records for the elements in the purchase order record. Click Next.


    Sample Schema screen




Defining the Element Type of Record


To define customer record





  1. Because we defined the customer element as the Repeating record type and the items element as the Record type, the BizTalk Flat File Schema Wizard now continues to further define these two elements. On the Schema View screen, select customer and click Next to continue.


    Schema View screen


  2. To work with the customer record, you need to select the data that represents that element. Because it is a repeating record, either of the lines can be used to define the record. Select the first line of customer data and click Next to continue.


    Select Document Data screen


  3. On the Select Record Format page, select By relative positions, and then click Next.


    Select Record Format screen


  4. The wizard provides a visual tool for showing and calculating the distance between the fields. On the Positional Record page, use the left mouse button to click the position marker 10 to represent where the name field begins. Click the following position markers to represent the rest of the data fields:


     
























    Field Name

    Position Marker

    street



    30



    city



    50



    state



    65



    postalcode



    68



    Click Next to continue.


    Positional Record screen


  5. On the Child Elements page, you specify the properties of the child elements. Select the first row and type country as the Element Name. Leave the default values in the other columns. Type the following values for the other properties for the Element Name:


     




























    Element Name

    Value


    customer_Child2




    fullName




    customer_Child3




    street




    customer_Child4




    city




    customer_Child5




    state




    customer_Child6




    postalcode



    Click Next to continue.


    Child Elements screen


  6. The child elements of the customer record are created as shown in the following screenshot. Click Next to define the child elements for the items record.


    Sample Schema screen



To define the items record





  1. On the Schema View page, select items and click Next.


    Schema View screen


  2. On the Select Document Data page, select the entire line begins with ITEMS and click Next to define its child elements.


    Select Document Data screen


  3. On the Select Record Format page, select By delimiter symbol and click Next.


    Select Record Format screen


  4. In the Items record, commas are used to delimit the individual items. Therefore, on the Delimited Record page, enter the following to define the items record. When you are done, click Next.




    • Select , from Child delimiter drop down selection list.



    • Leave the Escape character text box blank.



    • Select Record has a tag identifier and type ITEMS in Tag.



      In a multiple items record, ITEMS is used to identify each individual record.



    Delimited Record screen


  5. Using the values from the Delimited Record page, the wizard identifies two child elements. Because one of them is a repeating record, select the first element and enter item for Element Name, and then select Repeating Record from the drop down selection list for Element Type. Leave the rest of the default values in the columns. Select the second row and select the Ignore from Element Type list. When you click Next, the next level for the items record is created in the schema. You continue to define the final part of the purchase order schema.


    Child Elements screen


  6. Select item and then click Next to continue on the Schema View page.


    Schema View screen


  7. On the Select Document Data page, select ITEM872-AA|Lawnmower|1|148.95|Confirm this is electric. Click Next to continue.


    Select Document Data screen


  8. On the Select Record Format page, select the By delimiter symbol option because the individual item is delimited by a pipe (|).


    Select Record Format screen


  9. On the Delimited Record page, enter the following to define the item record. When you are done, click Next.




    • Select | from the Child delimiter drop down selection list.



    • Leave the Escape character text box blank.



    Select Record Format screen


  10. On the Child Elements page, the wizard has identified five child elements. Select the first row and enter productCode for Element name. Leave the default values in the rest of the columns. For the rest of the Element Name properties, type the following:


     
























    Element Name

    Value


    item_Child2




    description




    item_Child3




    quantity




    item_Child4




    unitPrice




    item_Child5




    notes



    Click Next to continue.


    Child Elements screen


  11. You have defined all the nodes for the purchase order schema. On the Schema View page, click Finish.


    Schema View screen


  12. You can now view the final purchase order schema. You can also refine the schema by using the BizTalk Schema Editor. See Flat file property name table and the Property tables in Schema Node Properties.


    Sample Schema screen




Summary


In this walkthrough you have learned how to use the BizTalk Flat File Schema Wizard to create a flat file schema from a document instance.



Next Steps


Validating PO Instance



To ensure that the PurchaseOrder.xsd schema can correctly parse the PO instance, do the following:




  1. In Solution Explorer, right-click the PurchaseOrder.xsd and then select Properties.



  2. In the Property Pages, make sure that the Input Instance Filename field is pointing to the location of the PO instance you created in the Prerequisites section of Walkthrough: Creating a Flat File Schema From a Document Instance. Click OK to close the dialog.



  3. In Solution Explorer, right-click PurchaseOrder.xsd and then select Validate Instance. The validation component opens.



  4. After validation is completed, a link is provided to you for viewing the XML output based on parsing result on PO instance using the PurchaseOrder.xsd schema. To view the XML output, press Ctrl and click the link.




Creating Pipelines for the Schema



Now you can create a receive or send pipeline based on the PurchaseOrder.xsd schema to use with your BizTalk application.


To create a new pipeline, see How to Create a New Pipeline. To configure the Flat File Pipeline components, see How to Configure the Flat File Assembler Pipeline Component and How to Configure the Flat File Disassembler Pipeline Component.






 



© 2009 Microsoft Corporation. All rights reserved.