AIF XSLT transformation

This post describes the XSLT transformations and their use in AX AIF document transfers.

Overview

While interacting with other systems, many of us may have come across the scenario when the other system sends XML only in specific format and do not have the ability to covert it to/from the format that AX AIF understands. XSLT transformation is one of the ways out in such scenario. You can use pipelines, value-mappings or external transform methods as other measures.

AIF in AX allows to convert the incoming or outgoing XML via the use of XSLT. For naïve users, XSLT is a file looking similar to XML which convert the received XML to the desired target XML file.

XSLT transformation

Here is an example of sales order which I am receiving from other system.

[Note: The process of transformation remains same for outbound message as well. I am using inbound in below example]



Obviously, AX format is different from what is provided here. So a mapping is needed between the incoming fields and AX fields. The message header, body, envelope tags need to be put in which are pretty much static for each message. The sales order need to be looped through in the received XML and corresponding sales order and line tags need to be created. Look at the XSLT which I created.


If you look at this XSLT closely, you will find that the Envelope, Header, Body etc. elsements are static. Customer account, delivery date etc. header fields are being taken from corresponding fields in received XML. (In my case I am getting maximum one order per XML but you can put this in loop if needed). Lines are getting created by looping (see xsl:for-each node) through order node in received XML. After that, it is getting values from the received XML fields.

You can check the result of your transformation with any online XSLT transformation utility. Once satisfied with the results, copy the XSL or XSLT file at any specific location in your machine.

AX port setup

Open the relevant port in AX (System administration > Setup > Services and application integration framework > Inbound ports) While the port is 'Inactive', check the check-box 'Transform all requests' and click on 'Inbound transforms' button. Click 'Manage transforms' button.


In Manage transforms form, create a new record, give it a name and then click Load button and choose the file which you have previously saved. Close the form.


In Inbound transforms form create a new record and choose the newly created transform from drop-down. Close this form. Re-activate your port. Once done, you are good to test your port with newly created XSLT transform.

Inquiries & Troubleshooting

Now all above said and done, you may want to see what XML exactly came in your system in first place and what transform did to it exactly before AIF consumed it. To do that go to History form (System administration > Periodic > Services and application integration framework > History). Select your incoming record and click 'Document logs' button. The version 0 record will be the original XML received and version 1 will be the transformed XML. You can select the relevant record and click 'View XML' button to see the XML.


Any errors will come up in Exceptions form. If there is any error related to transformation, you can take the original file (from history) and XSLT file. Use online transformation or any other tool to find the issue.

Here is a link to the files used in this example.
https://drive.google.com/file/d/0ByzwyaPDBPLqUk1UUTh0ZG9WWHc/view?usp=sharing

Comments

  1. Can you tell us which AX 2012 version this relates to? As we do not see a version 0 and 1 ..

    ReplyDelete

Post a Comment

Popular Posts