Microsoft Certified Trainer

Today I’ve received a mail from Microsoft that I’m now a certified trainer! As a member I’ve also received a free subscription of TechNet Plus to evaluate Microsoft technologies. I’m very curious!!

MCT(rgb)_3926_3964

In this example I’m going to use the File system adapter to exchange data between BizTalk and Microsoft Dynamics AX. The best practice is to use the AIF BizTalk Adapter but for testing purposes it’s easier (and faster) to use the File system or the Message Queuing adapter. You have to do some extra steps however because the Application Integration Framework (AIF) expects an envelope around every document. The AIF BizTalk Adapter does this automatically but when you use the File system or the Message Queuing adapter, you have to use an custom Pipeline.

First you have to import in Visual Studio the .XSD schemas of the AIF documents that you are going to work with.(In this example: SalesOrder schema and the envelope schema)

21SalesOrder
SalesOrder schema
Notice that in an orchestration you work with the AIF document that alters the Dynamics table. You don’t have to worry about the AIF envelope. In the Port Binding property you must select “specify later”. Now it’s possible to change the adapter at run time and select between the AIF BizTalk Adapter and the File system or the Message Queuing adapter.
22_PortProperties
Port properties
Create a send pipeline and drag a “XML assembler component on the “Assemble” shape. Next configure the “Envelope schemas” Property. Select here the AIF envelope schema. Select at the “Document schemas” Property the schema of the AIF document (in this case the SalesOrder schema)
23_PipelineProperties
Pipeline properties
Finally you have to configure the Send Port in the BizTalk Administration Console. Select “Properties” when you right click the Send Port. Subsequently configure the Send Pipeline property and select here the custom pipeline you just have created.
24_SendPortProperties
SendPort properties


In this example I’m going to assign a value in the Header section of an AIF message with BizTalk. An AIF message is defined by two XSD schemas. You have an envelope and a document that defines which tables are mutated in Dynamics. The elements in the Header are part of the Envelope.
1_XmlExample
XML example of an AIF message.
 

The example above is a Dynamics AX 4 message. There are some small differences with Dynamics AX 2009 but the principle is the same. The XML documents have for example other namespaces and in action element are other values allowed.

There are more elements in the Header section but in this example I’m only going to set the value in the action element. This element contains information that uniquely identifies the service operation to the system and is a required element. To set the Action value I’m going to use Promoted Properties.

First you have to create a property schema with the elements you want to set.

2_PropertySchema

Property schema
 
After that you import in your BizTalk project the Envelope schema and the schema that defines the Dynamics table that you want to mutate.
3_EnvelopeSchema
Envelope schema
 
Then you have to promote the elements in the envelope schema.
4_PromoteProperty
Promote Action property
 
In an Orchestration you can set the value of the promoted field with the “Message Assignment” component.
5_MessageAssignmentComponent
Assign the value
 

In the example code beneath you see how the Action property of the “msgSalesOrder” message is set

//Assign Header values
msgSalesOrder(AIFExample.Action)= “createSalesOrder”;

Notice that in the orchestration you work with the document that defines the table that you want to mutate. You don’t have to worry about the envelope. The Dynamics AX adapter in BizTalk puts the document in the envelope and sends the envelope to Dynamics.

 

For more information about AIF Messages go to MSDN

Microsoft Dynamics AX
AIF Messages
http://msdn.microsoft.com/en-us/library/aa627117(AX.10)..aspx