Greg On Dynamics Ax

Random thoughts about development using Dynamics AX and .Net

Archive for the ‘AIF’ Category

AIF Pipeline Example

with 4 comments

In my last post (Top 5 AIF Development Tips and Tricks) I mentioned how you can use the AIF to transform external messages into the format that AX expects. This post elaborates upon that tip with a more detailed example.

Suppose you want to import currency exchange rates.

AX has an action for this out of the box – createListExchangeRates, and will happily accept a message similar to this:

<ExchangeRates xmlns="">

Thats all well and good if you have control over the schemas of any inbound messages.
Most likely this is not the case, say for example you want to import the exchange rates for the euro from the european central banks daily published list (

If you try and receive this it will fail on two counts:
1) It is not wrapped in an envelope (which is used by the AIF to identify the message sender and destiation) and
2) the format of the exchange rate does not match AX schema.

To solve problem 1) you can make use of the¬†‘Wrap XML in AIF envlope’¬†program available from axaptapedia

To solve 2) you can use the pipeline to specify an XSLT to transform the message, the XSLT to perform the transformation for this example is:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="" 
  exclude-result-prefixes="ext xs xsi xsl gesmes" 
  <xsl:namespace-alias stylesheet-prefix="ax" result-prefix="#default" />
    <xsl:output method="xml" encoding="UTF-8" indent="yes" />
    <xsl:template match="gesmes:Envelope">
          <xsl:variable name="root" select="." />          
          <xsl:for-each select="$root/ext:Cube/ext:Cube">
            <xsl:variable name="xrateDate" select="$root/ext:Cube/ext:Cube/@time" />
              <xsl:for-each select="$root/ext:Cube/ext:Cube/ext:Cube">
                <xsl:attribute name="class">
                  <xsl:value-of select="'entity'" />
                  <xsl:value-of select="@currency" />
                  <xsl:value-of select="@rate" />
                  <xsl:value-of select="$xrateDate" />
                  <xsl:value-of select="$xrateDate" />

After running the AIF inbound service upon last weeks exchange rates it results in the following data being created (US Dollar highlighted):

Exchange rates AX form

Exchange rates AX form


Written by gregondax

October 26, 2009 at 8:00 am