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.



Friday, 1 July 2016

Introduction to BizTalk Server Architecture | BizTalk Server


In this article I would brief about BizTalk Server Architecture.

BizTalk Server is Microsoft's central platform for Enterprise Application Integration (EAI) and Business Process Management (BPM) and embodies the integration and automation capabilities of XML and Web Services technologies.

Architecture
The BizTalk Server run-time is built on a publish/subscribe architecture, sometimes called "content-based publish/subscribe". Messages are published into BizTalk, transformed to the desired format, and then routed to one or more subscribers. BizTalk makes processing safe by serialization (called dehydration in BizTalk’s terminology) placing messages into a database while waiting for external events, thus preventing data loss. This architecture binds BizTalk with Microsoft SQL Server. Processing flow can be tracked by administrators using an Administration Console. BizTalk supports the transaction flow through the whole line from one customer to another. BizTalk orchestrations also implement long-running transactions. 

Publish-Subscribe model is an asynchronous programming technique that makes it easier to share information between entities that send information (publishers) and entities that receive information (subscribers). The main advantages of publish-subscribe model includes scalability (the ability to take advantage of available, changing, resources) and flexibility (works as the basis for many other programming approaches). BizTalk publishes messages to a common area and processes that are interested in consuming the published messages subscribe to them (orchestrations, receive or send ports, or directly bound ports). 

Publish-Subscribe model wouldn't work if all subscribers receive all messages. When a subscriber registers its interest, the registration includes filters to select messages of interest. 


In general, there are two types of filters -topic based filters that BizTalk represents as Receive Ports or Send Ports, and content based filters which filter messages based on their content -

BizTalk provides several means of filtering based on content The subscription includes both types of filters, 
  • The topic filter is based on the ReceivePortID 
  • The content filter is based on an attribute called MessageType 
A Receive Port is logical representation of a means to receive a message using a specific protocol or location. For example, BizTalk can receive messages in files, from Message Queues, or via HTTP (among the methods - there are others). The specific protocols and locations are referred to as Receive Locations. There can be several Receive Locations per Receive Port making it possible to accept messages from a variety of locations and treat them the same way in BizTalk. 

The MessageType is a representation of a message's type and this should be unique. BizTalk represents all messages in XML. One important aspect of all XML documents is its namespace and another important aspect of all XML documents is the name of the document's root node. The combination of the message's namespace and name of the root node are represented as: 

The hash symbol (#) separates the namespace from the name of the root node. 
Publishers
Mainly two, they are receive locations and orchestrations. 

Subscribers
Mainly three, they are send ports, send port groups, and orchestrations. 


Conclusion
BizTalk Server is a message-based system and its uses publish-subscribe model. All the messages that enter the BizTalk are converted to XML format which is uniquely identified by its MessageType.

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