Microsoft Dynamics AX 2012 Application Integration Framework(AIF) allows you to integrate your Microsoft Dynamics AX 2012 application with the external applications using services by exchange of data using formatted XML. Microsoft Dynamics AX 2012 allows you to format these XML messages in a way you like using Transforms.
All the messages are stored in the gateway queue within AX before they can be processed by any service operation. The gateway queue has this limitation that it can only accept XML messages. So, it is quite possible that the third party application with which Microsoft Dynamics AX 2012 is communicating with does not understand XML. Rather it sends the data in the csv format. In that case, you would have to convert that csv into the valid XML for Microsoft Dynamics AX 2012. In all of these scenarios you could make use of a transform.
Transforms are of two types:
- .Net Assembly
In this post, we ‘ll be focusing on XSLT and we will see how we can create a simple transform using XSL.
What is XSL?
XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents. XSLT stands for XSL Transformations. So if you are an XML guy, you can make use of XSLT within Microsoft Dynamics AX very easily.
Let’s consider the example of outbound Sales Invoices.
At present, the format of the output XML message is:
//more XML tags….
But, what we want is that the header tag should tell us the name of document. So our expected output XML is:
//more XML tags….
So, as you can see that we want to replace the <Envelope> tag with a more meaningful document specific <SalesInvoice> tag. This would enable the third party application understand that this is a Sales invoice message by merely processing the header tag. Now we ‘ll create a transform using XSL that would render us the output xml in the required format.
So this is the XSL code that would enable us to achieve the required format:
<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:a=”http://schemas.microsoft.com/dynamics/2011/01/documents/Message”>
<xsl:output method=”xml” omit-xml-declaration=”no”/>
Steps to add the XSL transform to our Sales Invoice service
2. Click on Service operations and select the Read operation for the Sales invoice service.
3. In your outbound port form, select the “Transform all responses” check box and click “Outbound Transforms” button.
4. A form would open up, then click new and click on this button in the action pane called “Manage transforms”.
5. Another form would open up, click new and provide any name. Next select “XSL” in the type. And click “Load” button. Then locate and select your “XSLT” file and click Open.
6. As you can see that the “XSLT” is loaded into this text box.
7. Now close this form. Select this newly created transform now in the enhanced outbound transform form.
8. We are all done now. Now to test, open up your Sales invoice journal form. Click “Send” and select “Original”. This would trigger the Sales invoice service read operation.
9. Now navigate to the directory you provided in the Outbound port. Your transformed xml message should like this:
To run the outbound services demo using file adapter, please make sure that the Batch server is configured and that the batch jobs necessary for gateway execution are running. For more details about those jobs, please visit this link : http://technet.microsoft.com/en-us/library/hh352328.aspx