Example of Inbound XML Message [AX 2012]

Updated: February 1, 2013

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

To create ledger journal entries in Application Integration Framework (AIF), the data is sent in the form of an XML message. This message is received by the inbound port in Microsoft Dynamics AX and is deserialized into a class. For example, an inbound message specifying the create service operation on the LedgerJournalService is used to create an instance of the AxdLedgerJournal class. The inbound message contains the data to be created: the parent ledger journal record and one or more child ledger journal transaction records. The format of the data varies depending on the business requirements for journal transactions.

The inbound XML is validated against the XSD for the document class by the framework. For more information about document class schemas, see Document Schema Rules and How to: Generate a Document Schema.

The XML must also validate against the schema for the inbound port for the action that is called. Invalid messages are indicated in the exception logs. In this case the action is create and this is implemented in the document class method createLedgerJournal. This schema varies depending on the fields that are enabled on the port for the document. To view this schema, follow these steps.

To view the schema

  1. Open the Inbound ports form. Click System administration > Setup > Services and Application Integration Framework > Inbound ports.

  2. Select the inbound port and then click Deactivate to enable access to the configuration options.

  3. On the Service contract customizations FastTab, click Data policies to open the Data policies form. For more information, see Customize service contracts.

  4. Select the LedgerJournal document, and then click View schema. Save the schema for the LedgerJournal document.

    Click View imported schemas and then save the shared-types schema to the same folder.

  5. To view sample XML for the schema, open the LedgerJournal schema with Visual Studio. In the Schema Explorer, right-click on the root node and then click Generate Sample XML.

The inbound XML message in the AxdLedgerJournal scenario should resemble the following XML code. Notice how the whole message is wrapped in an envelope and contains header information about the message unique identifier and the action that the document service performs. The body of the message contains the ledger journal record and a ledger journal transaction record that you generated. For more information about messages, see AIF Messages.

You can create the inbound message by using Notepad to add the tags for the message header and body. Add the message header information between the <Header> and </Header> tags. The only required tag is the <Action> tag. It is a best practice to include a Message ID. For more information about the values of the tags in the message header, see Message Header.

The message body contains the XML generated from the document schema. The following example shows the inbound message XML with a message header and body.

<?xml version="1.0" encoding="utf-8" ?> 
<Envelope xmlns = "http://schemas.microsoft.com/dynamics/2008/01/
        <MessageParts xmlns = "http://schemas.microsoft.com/dynamics/2008/01/
        <LedgerJournal xmlns = "http://schemas.microsoft.com/dynamics/2008/01/
        <LedgerJournalTable class="entity">
            <Name>Daily Journal 1</Name>
        <LedgerJournalTrans class="entity">        
            <Txt>AxLedgerJournal inbound test trans 1</Txt>

For another example of an inbound XML message, see Walkthrough: Exchanging documents by using the file system adapter.

Community Additions