Saturday 2 July 2016

Schema In BizTalk Server | BizTalk | XML Schema Definition (XSD) | Basic Concepts | Part 1


This is my first of series of article on BizTalk Basic Concepts, where I would cover the BizTalk artifacts like schema, map, and orchestration. Here, I would brief about schema and how to create a schema in BizTalk. 

Schema 

BizTalk allows you to create your own schema; there are 4 types of schemas. 
  • XML schema. An XML schema defines the structure of a class of XML instance messages and this type of schema use XML Schema definition (XSD) language to define the structure of an XML instance message. 
  • Flat file schema. A flat file schema defines the structure of a class of instance messages that use a flat file format, either delimited or positional or some combination thereof. BizTalk Server defines a rich set of specific annotation tags that can be used to store all of the required additional information.
  • Envelope schema. An envelope schema is a special type of XML schema. Envelope schemas are used to define the structure of XML envelopes, which are used to wrap one or more XML business documents into a single XML instance message. When you define an XML schema to be an envelope schema, a couple of additional property settings are required, depending on such factors as whether there are more than one root record defined in the envelope schema. 
  • Property schema. A property schema is used with one of the two mechanisms that exist within BizTalk Server for what is known as property promotion. Property promotion is the process of copying specific values from deep within an instance message to the message context. From the message context, these values are more easily accessed by various BizTalk Server components. A property schema is a simple version of a BizTalk schema that plays a role in the process of copying promoted properties back and forth between the instance message and the message context. 
Creating XML Schema using BizTalk Editor 

BizTalk Editor uses its own graphical system of hierarchical records and fields to represent the structure of instance messages.

To generate a schema from a BizTalk Editor
  • In Solution Explorer, select the BizTalk project to which you want to add a schema.
  • On the Project menu, click Add New Item.
  • In the Add New Item - <BizTalk ProjectName> dialog box, in the Templates section, click Schema.
  • In the Name box, type a name for the schema, and then click Add.
  • If necessary, press F4 to open the Visual Studio Properties window.
  • In the schema tree view, select the Schema node, and then in the Properties window, select the Target Namespace property and type a name for the target namespace, refer screen shot. It is important that you set this property in this initial phase of schema creation; avoid using the default Target Namespace property value.
  • Define the XML schema XSD by adding record, element, and attribute using   Insert Schema Node Option, refer screen shot.


To generate a schema from a non-XSD source,
  • In Solution Explorer, right-click a BizTalk project, point to Add, and then click Add Generated Items.
  • In the Add Generated Items - <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas and then click Add.
  • In the Generate Schemas dialog box, in the Document type drop-down list, select XDR Schema, DTD Schema, or Well-Formed XML. 
    • If you see either DTD (Not Loaded) or Well-Formed XML (Not Loaded) in the drop-down list, select the appropriate document type anyway, and you will be guided through the process of installing the missing DLL. Then repeat these steps. Refer screenshot. 
  • In the Generate Schemas dialog box, click Browse, locate the file you want to import, and then click Open. The file you locate must match the document type you selected in the previous step.
  • A new schema is generated from the specified file, using the same name as that file with the .xsd extension, and opened in BizTalk Editor and this would not have any target namespace. Refer screenshot.

Creating Flat File Schema using BizTalk Flat File Schema Wizard 
To generate a Flat File schema using Wizard, 
In Visual Studio, open the Solution Explorer. 
  • To add the new flat file schema, right-click the project, and select Add. Click New Item. 
  • In the Add New Item window, do the following: 
    • In the Categories section, select Schema Files. 
    • In the Templates section, select Flat File Schema Wizard. 
    • In the Name field, enter OrderRequest_FF.xsd for the new schema. 
    • Click Add. 
  • When the BizTalk Flat File Schema Wizard opens, the Welcome Page appears. Click Next to continue. 
  • On the Flat File Schema Information screen, select your instance and enter the information and click Next to continue 


  • 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. 

  • As each line of the Order Request ends with a carriage return-line feed (CRLF), select By delimiter symbol, and then click Next on Select Record Format screen. 
  • 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}. 
  • The wizard has identified 3 elements in the order request record; you must now define the element property. Define the elements as shown, 
  • The first level of the schema is generated as shown and you can see three unique elements are defined, and now continue to further define the child records for the elements in the order request record. Click Next 
  • As we defined Header element as the record type and ProductList and DocumentList as RepeatingRecord, the BizTalk Flat File Schema Wizard now continues to further define these elements. On the Schema View screen, select Header and then click Next to continue. Then define the child delimiter and Record Tag Identifier as shown then click Next to continue, where you can define the elements of Header Record
  •  Repeat the same procedure for ProductList and DocumentList,


  • Now, you have defined all the nodes for the Order Request schema. On the Schema View page, click Finish to view the final Order Request 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. 

Conclusion
In this article, I briefly explained about schema and different ways to create XML and Flat File schema using BizTalk Editor and Wizard. 

The video demonstration is available on the Youtube, here is the embedded video.



No comments:

Post a Comment

Note: only a member of this blog may post a comment.