Microsoft DynamicsFree generatorPDF, Excel, Word exportMicrosoft Dynamics AX 2012All Microsoft Dynamics AX 2012 tools

AIF Integration in AX 2012: Inbound Sales Order Message Generator for the File System Adapter

This generator builds an AIF inbound XML message for the SalesOrderService create operation in Dynamics AX 2012, ready to drop into the folder of an enhanced inbound port that uses the file system adapter. A second block lists the port, data policy and batch settings and where to look when the order does not appear.

Fill in

Generated code
Download:

SalesOrderService create message (save as SO_0001.xml in the inbound folder)

<?xml version='1.0' encoding='utf-8'?>
<Envelope xmlns='http://schemas.microsoft.com/dynamics/2011/01/documents/Message'>
  <Header>
    <MessageId>{7B1E3C52-9A4D-4F0B-8E21-5C6D9A0F3B17}</MessageId>
    <Company>usmf</Company>
    <Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create</Action>
  </Header>
  <Body>
    <MessageParts>
      <SalesOrder xmlns='http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder'>
        <SalesTable class='entity'>
          <CustAccount>US-001</CustAccount>
          <DeliveryDate>2026-11-15</DeliveryDate>
          <PurchOrderFormNum>PO-7781</PurchOrderFormNum>
          <ReceiptDateRequested>2026-11-15</ReceiptDateRequested>
          <SalesLine class='entity'>
            <ItemId>1000</ItemId>
            <SalesQty>25</SalesQty>
            <SalesUnit>ea</SalesUnit>
            <InventDim class='entity'>
              <InventLocationId>11</InventLocationId>
              <InventSiteId>1</InventSiteId>
            </InventDim>
          </SalesLine>
        </SalesTable>
      </SalesOrder>
    </MessageParts>
  </Body>
</Envelope>

Processing checklist

1. Inbound port: System administration > Setup > Services and Application Integration Framework > Inbound ports. Adapter = File system adapter, URI = the inbound folder, Response address = an outbound folder. Service operation SalesSalesOrderService.create selected. Port activated.
2. Data policies: Customize documents > Data policies. Enable CustAccount, ItemId and every element you send (DeliveryDate, PurchOrderFormNum, ReceiptDateRequested, SalesQty, SalesUnit, InventDim/InventSiteId, InventDim/InventLocationId).
3. Batch job: System administration > Inquiries > Batch jobs > Batch jobs. One recurring job with four tasks: AifGatewayReceiveService, AifInboundProcessingService, AifOutboundProcessingService, AifGatewaySendService. Status Waiting; a 1 minute recurrence is convenient for testing.
4. Drop the file. Files are processed in file name order, so name them SO_0001.xml, SO_0002.xml.
5. Check the response file in the outbound folder: a SalesId in EntityKeyList means the order was created; RequestMessageId equals {7B1E3C52-9A4D-4F0B-8E21-5C6D9A0F3B17}.
6. If nothing appears: System administration > Periodic > Services and Application Integration Framework > Queue manager (message status) and Exceptions (error text, for example a disabled data policy element or an unknown item).

Verify on your system: the namespaces are http:// URIs and must match exactly. Header Company must be a company the port allows (or remove it to use the port or submitting user default). Elements inside each entity follow the schema sequence, which for the sales order document is field names in alphabetical order followed by child entities, so keep InventDim after the SalesLine fields and InventLocationId before InventSiteId. Download the schema from the port (Document data policies or the service WSDL) to confirm. Use a new GUID in MessageId for every file; AIF rejects duplicates.

AIF messages failing in Exceptions?

Send us an anonymised message and the exception text, and we will tell you which element, policy or setup is blocking it.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

How to use it

Generate a fresh GUID for MessageId (PowerShell: [guid]::NewGuid()), fill in a real customer account, item, unit, site and warehouse for the target company, and copy the XML into a UTF-8 file. Save it to the inbound folder configured on the port. Within one or two batch cycles AX picks up the file, creates the sales order and writes a response with the new SalesId to the response folder. To send more orders, change MessageId and the values, and name files in sequence because the adapter processes them in file name order.

Where this lives in AX 2012

Enhanced integration ports live under System administration > Setup > Services and Application Integration Framework > Inbound ports. The file system adapter is asynchronous, so messages wait in the AIF queue until the AIF batch tasks run: AifGatewayReceiveService reads the folder, AifInboundProcessingService calls the service, AifOutboundProcessingService builds the response and AifGatewaySendService writes it out. Message status is in the Queue manager and errors in Exceptions, both under System administration > Periodic > Services and Application Integration Framework.

  • Service operation: SalesSalesOrderService.create
  • Document: SalesOrder with SalesTable and SalesLine entities
  • Each element sent must be enabled in Data policies
  • Response correlates through RequestMessageId

Worked example

Customer US-001 sends PO-7781 for 25 ea of item 1000, wanted on 2026-11-15 from site 1 warehouse 11. The generated file sets CustAccount US-001, PurchOrderFormNum PO-7781 (the customer requisition shown on the order), ReceiptDateRequested and DeliveryDate 2026-11-15, and one SalesLine with InventDim site and warehouse. After processing, the response contains KeyField SalesId with the new order number. Opening Accounts receivable > Common > Sales orders shows the order with the customer reference filled in.

Version differences and gotchas

The envelope namespace is 2011/01 while the service action and document namespaces are 2008/01; mixing them up is the most common cause of a silent failure. Required fields and defaults depend on the port's document data policy and the customer and item setup; if the item uses product dimensions such as configuration or size, add those InventDim elements and enable them. In AX 2012 R2 and R3 partitions apply; a port restricted to one company or partition rejects messages for others. Duplicate MessageId values are rejected, so never reuse a file.

Frequently Asked Questions

How does AIF integration work in AX 2012?

An integration port exposes service operations such as SalesSalesOrderService.create through an adapter: file system, MSMQ, BizTalk or web services. Asynchronous adapters such as the file system adapter put messages in the AIF queue, and four AIF batch tasks receive, process, build responses and send them. Data policies control which XML elements are accepted.

What XML format does AX 2012 AIF expect for a sales order?

An Envelope in the 2011/01 Message namespace with a Header (MessageId and Action) and a Body containing MessageParts. Inside is a SalesOrder document in the 2008/01 SalesOrder namespace with SalesTable and nested SalesLine entities, each marked class='entity'. This tool generates that structure.

Why is my AIF file not picked up from the folder?

Usually the batch job is not running or lacks the AifGatewayReceiveService task, the port is not activated, or the AOS service account cannot read the folder. Check the batch job status, the port, and folder permissions for the AOS account. Then check Queue manager and Exceptions for messages that were read but failed.

Can I reuse the same MessageId?

No. AIF uses MessageId to detect duplicates and will reject a message whose ID was already processed. Generate a new GUID for every file. The response carries your MessageId in RequestMessageId so the sending system can match responses to requests.

If you want a private AI assistant that drafts and validates AIF messages or answers questions about your AX 2012 orders on your own servers, we can set that up.

ArchRay builder
Design the on-prem AI stack for Microsoft Dynamics AX 2012: model, GPUs, RAG pipeline, guardrails
See memory, speed and cost as you swap parts, then export the diagram. Free, in your browser.
Open the builder

Keep exploring

Free tools

ERP fixes and how-tos

AI on your ERP

Integrations

Software