Friday, January 27, 2012

Test AIF Service with X++

The following code will allow you to make sure the AIF service is running in our server. In addition, you can use this code to run the AIF service at any moment instead of using a batch process.

static void TEST_AIF(Args _args)
    AifGatewayReceiveService agrs = new AifGatewayReceiveService();
    AifInboundProcessingService aip = new AifInboundProcessingService();

    AifGatewaySendService agss = new AifGatewaySendService();
    AifOutboundProcessingService aop = new AifOutboundProcessingService();

That's all folks!

Tuesday, January 24, 2012

Microsoft Dynamics AX 2012 Services and (Application Integration Framework) AIF architecture

Hi there!

In this post I would like to discuss, in detail, the Application Integration Framework (AIF) and its capability to integrate Microsoft Dynamics AX 2012 with other systems inside and outside an organization.

So what is the AIF and why is important?

The AIF provides capability to integrate Microsoft Dynamics AX 2012 with other systems inside and outside an organization by enabling the exchange of data through XML.

This formatted XML is referred to as a document, and each document contains data and business logic. Documents are based on a document class and defined by using Microsoft Dynamics AX.

Further, AX 2012 ships together with standard document services that support common business processes. As in AX 2009, in AX 2012 we can also customize existing services or create our services.

How documents are exchanged?

The AIF provides an extensible framework for the exchange of XML documents with external systems. The framework supports both synchronous and asynchronous transports.

In synchronous mode, requests are tightly coupled to responses, which means that the submitter of the request must wait for a response from AIF before proceeding.  In this case, AIF does process the request immediately and then sends a response.

In asynchronous mode, however, requests are placed into a queue, called the gateway queue. Queued messages are processed at a later time and AIF sends a response when processing is completed. In this case, responses are delayed, but note that large volumes of messages can be processed more efficiently, and message processing can be controlled by changing various configuration settings. Further, the AIF can be used to send and retrieve data into/from AX.

Inbound / Outbound Exchanges

Inbound exchange, an external system may send a sales order so that the sales order can be saved to the Microsoft Dynamics AX database.
Outbound exchange, an external system may send a request for a purchase order and receive the purchase order.

The inbound and outbound exchanges can be categorized in the following ways:

  • Send data – AX sends documents to an external system.
  • Send data in response to requests – AX receives requests for documents from another authorized system, and retrieves the requested information, such as a document or a list of documents, from the AX database. Then AX returns the information to the requesting system.
  • Receive and create data – AX receives documents from another authorized system and creates new records in the Microsoft Dynamics AX database.

AIF Architecture

AX 2012 exposes its functionality through services that are based on Windows Communication Foundation (WCF) and hosted on Application Object Server (AOS).

External applications and client applications on the local area network consume AX services by accessing them directly from AOS. These clients and applications include AX components such as the AX client, Office Add-, and Enterprise Portal.

The following diagram illustrates the services and AIF architecture.

Application Integration Framework Process
  • Internet-based external applications and clients access the AX services through Internet Information Services (IIS).
  • IIS routes the incoming requests for AX services to AOS. All services requests, regardless of their origin, are handled by the WCF runtime that is hosted on AOS.
  • The AIF request pre-processor, if it is configured, can intercept the inbound request messages for custom preprocessing, such as message transforms or value substitutions.
  • The AX service invokes the necessary business logic to process the inbound request message.
  • Similarly, the AIF response post-processor, if it is configured, can intercept the outbound response messages for custom post-processing, such as message transforms or value substitutions.
  • The AIF response post-processor then returns the response to the client.

NOTE:  Microsoft Dynamics AX 2012 no longer includes a BizTalk adapter. For more information about how to use Microsoft BizTalk Server together with Microsoft Dynamics AX 2012, see Exchanging documents between BizTalk Server and AIF.

Services in AX 2012

Application Object Server (AOS) is the Windows Communication Foundation (WCF) service host for Microsoft Dynamics AX 2012 services that are exposed to users and applications on an intranet.
  • To consume services over the Internet, you must host services on Internet Information Services (IIS).
  • Services that are hosted on IIS use the WCF message routing service. IIS routes all service requests to AOS.
  • All service requests are processed on AOS, regardless of whether they originate on the Internet or an intranet. AOS then returns a response to the service consumer via IIS.
  • Exchanges that are configured to use Web services are processed synchronously and therefore are not queued.
  • AX deploys the service that is based on Web Services Description Language (WSDL) to a subfolder of the virtual directory that is associated with the Web site that you provide.

NOTE: In general when dealing with the AIF, keep in mind that the AIF user names and passwords are encrypted in the Application.Host configuration file located in C:\Windows\System32\Inetsrv\Config. Therefore, DO NOT copy files from other environments into this location when the AIF and/or Workflow are running in the same machine.

AX 2012 supports the following three kinds of services:
  • Document services are query-based services that can be used to exchange data with external systems by sending and receiving XML documents. These documents represent business entities, such as customers, vendors, or sales orders.
  • Custom services can be used by developers to expose any X++ logic, such as X++ classes and their members, through a service interface.
  • System services are provided by Microsoft Dynamics AX. System services include the Query service, the Metadata service, and the User Session service.
Further, system services are not customizable, and they are not mapped to any query or X++ code. For more information about system services, see AIF System Services.

Integration ports in AX 2012

In Microsoft Dynamics AX 2012, integration ports provide simplified administration of services and Application Integration Framework (AIF). Integration ports replace the AIF endpoints and related concepts that were used in previous releases of Microsoft Dynamics AX.

  • Each integration port can expose one or more services, and each integration port has a unique Uniform Resource Identifier (URI) that identifies the address of the port.
  • Each integration port also has a direction. An integration port can be either an inbound integration port or an outbound integration port.
  • An inbound integration port is a destination for messages that originate from outside Microsoft Dynamics AX.
  • An outbound integration port is a destination for messages that originate from your Microsoft Dynamics AX system. Inbound integration ports can be one of two types: basic or enhanced. Outbound integration ports are always enhanced ports.

Basic integration ports

Basic integration ports are exposed at a specific Windows Communication Foundation (WCF) endpoint on the Application Object Server (AOS) host. Only a developer can create a new basic integration port.

Enhanced integration ports

If you want advanced integration capabilities that you can use to customize the behavior of an integration port, you must create an enhanced integration port.

Enhanced integration ports provide the following capabilities that basic integration ports do not provide:
  • A variety of protocols are supported through WCF adapters. These protocols include HTTP, NetTCP, and Message Queuing, which is also known as MSMQ.
  • Enhanced integration ports also support a file system adapter that lets you use file paths as addresses.
  • You can perform pre-processing and post-processing of service requests and service responses.
  • You can create customizations for data contracts by specifying service operations and policies for document data.
  • You can specify advanced security and troubleshooting settings.


In AX 2012 services and AIF, integration ports use adapters. These adapters enable AX to communicate by using various transport protocols.

AX 2012 provides the following four adapters that represent predefined bindings:

HTTP adapter – This adapter provides for synchronous message exchanges by using an HTTP or HTTPs transport.

NetTCP adapter – This adapter provides for synchronous exchanges by using WS-* standards support over the Transmission Control Protocol (TCP) transport.

This adapter corresponds to the WCF-NetTcp binding in Windows Communication Foundation (WCF).

MSMQ adapter – This adapter provides support for queuing by using Message Queuing as a transport. Message Queuing is also known as MSMQ.

Message Queuing is a type of asynchronous communication. This adapter corresponds to the WCF-NetMsmq binding in WCF.

File system adapter – This adapter provides support for the asynchronous exchange of documents through file system directories.

Messages and transforms in AIF

In AX 2012 services and AIF, a message corresponds to a Windows Communication Foundation (WCF) message. A message is a self-contained unit of data that can consist of several parts. These parts include a body and headers. When AIF receives and processes an inbound message, it generates an outbound message in response.

Although AIF supports the transfer of data in any arbitrary format, most information exchanges with AIF services use XML documents.

In order to create an XML document that adheres to a standard for a particular exchange of information, AIF requires XML documents to follow an XML style definition (XSD). XSD files (which have a .xsd file name extension) are meta-documents that describe the format, or schema, of XML documents that declare the namespace of the XSD.

Each schema includes rules about the hierarchical arrangement of XML elements, which elements must be present in the document, and other such requirements.


1-Document service schemas: Each document service has a unique schema that describes the fields that can be added, read, updated, and so forth, by using the particular document service.

2-Message schema: Asynchronous exchanges require XML messages to be contained by the AIF message envelope. The namespace for the message schema is:

3-Message-set schema: AIF uses the message-set, or batch, schema to contain batched AIF messages in asynchronous exchanges. The namespace for the message-set schema is:

4-Entity key schemas: AIF uses entity key schemas to contain name-value pairs, such as those used to query for a particular item during a read operation or when sending a response to a create operation. The namespaces for entity keys and entity key lists are:

5-Shared types schema: AIF aggregates common property types in the shared-types schema. The namespace for the shared-types schema is:

6-Fault schema: AIF uses the fault schema to contain response messages about error conditions. The namespace for the fault schema is:

Schema locations

You can save XSDs for particular document services, including their imported schemas (such as the shared-types schema) and any port-specific customizations, when you configure data policies for an integration port.

You can retrieve XSDs for common schemas from the following directory where you installed Microsoft Dynamics AX:
Program files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\Application\Share\Include

Processing messages

When you use an enhanced integration port for services and AIF, you can perform custom processing of data, such as XML documents, as each message passes through the integration port. Enhanced integration ports use the following two concepts to process messages during inbound or outbound exchanges:
  • Extensible Stylesheet Language Transformations (XSLT)
  • .NET-based transforms to messages.

In addition, transforms are run for inbound exchanges before they are run for outbound exchanges. Transforms process the whole message. Headers are included in the processing.

NOTE: Transforms apply only to asynchronous exchanges.

.Net-based transforms can convert messages to or from any proprietary format. AX services and AIF can process XML documents only if the documents comply with the service XSD.

If an incoming document is based on XML but uses a different schema, you can use Extensible Stylesheet Language (XSL) to transform the document to the AIF schema.

If an incoming document is not based on XML, such as a comma-delimited file, you can use a .NET Framework assembly to convert the file to the AIF schema.
Pipelines use components to enable the processing of requests for service operations. These components include custom components that are written in X++ code.

For example, if an inbound message contains customer records, your AIF pipeline can contain an XSLT component that updates an element in the XML, based on the value of the customer status element.

Further, your AIF pipeline can contain one or more of any available transformation component. Alternatively, your AIF pipeline can contain no transformation components.

Processing that occurs in pipelines, including XML transformation, applies to both synchronous and asynchronous exchanges.

For inbound exchanges, pipelines are run after transforms. For outbound exchanges, pipelines are run before transforms.

The following diagram shows how data moves through an enhanced inbound integration port.

That's all for now.

Friday, January 13, 2012

Monitoring Pack for Microsoft Dynamics AX 2012

Hi there!

There is a new tool for AX 2012 called Management Pack(similar to the one for AX 2009) that will automatically discover the entire AX environment; This is, AOS's, application frameworks, databases, reporting servers, enterprise portal server and analysis servers. In addition, it monitors each component for configuration, availability and performance.

The Management Pack provides warnings, at an early stage, that an operator can use to quickly identify issues that could affect the performance and availability of the Dynamics AX system.

Feature Summary
  • Visual representation of the entire Dynamics AX 2012 environment with health rollup
  • Monitors for Database, AOS, Enterprise portal servers, Reporting servers and framework components
  • AOS clusters and AOS Servers monitored
  • Events view for AOS and Enterprise Portal Events
  • SCOM Tasks for most common AX administrative actions
You can download the tool from here.

Take care!

Thursday, January 5, 2012

AX 2012 - Run Reports without hitting the Production DB

Hi there!

My fellow Sunriser, Brandon George,  has written an amazing article about running reports without hitting the Production Database.

Form the article:

"Since the default .Net Business Connector configuration for SSRS is pointing back to the same AX instance, when the SSRS instance is executing the reporting and firing the Data Extensions to get to the correct Query object and therefore data, then in this standard approach, we are hitting the production database for your instance of AX..."

"The critical keys that enable this concept are, (1) having the production instance of your AOS and Reporting Server setup, pointing to your SSRS server role within AX. (2) Changing what AOS the SSRS server hits for processing data, by deploying a custom configuration file. (3) Log Shipping is enabled at on the AX Production database, so that the AX Reporting Database is kept up to date with live data."

"...That is code promotion, or change management. Why does this matter? Well simply put, it's because the model store that represents the application now lives as a part of the production database. This then gets replicated when any changes take place."

Brandon George is a Senior Technical Architect at Sunrise Technologies and I personally believe he is one of the few people in the world that has truly master AX. I strongly suggest to follow his blog as it contains valuable, innovative, and critical information about AX.

You can access his blog (and the article) from here.

Take care!

Ax 2012 AIF Calling the CustCustomerService.Create method from WCF

A fellow AX developer wrote a very interesting article about creating a customer using the CustCustomerService.Create method from WFC.

You can access the post here.

Take care!

Calling the InventTransferJournalService in AX 2012

The following is the code (written by Becky Newel from Microsoft) to call the InventTransferJournalJournalService in AX 2012.

TransferJournalServiceClient client = new TransferJournalServiceClient();
CallContext context = new CallContext();
AxdTransferJournal journal = new AxdTransferJournal();
AxdEntity_InventJournalTable journalHeader = new AxdEntity_InventJournalTable();
AxdEntity_InventJournalTrans inventJournalTrans = new AxdEntity_InventJournalTrans();

journalHeader.JournalNameId = "ITrf";
inventJournalTrans.ItemId = "1000";
context.Company = "ceu";

AxdEntity_InventDimIssue inventDimIssue = new AxdEntity_InventDimIssue();
inventDimIssue.InventSiteId = "2";
inventDimIssue.InventLocationId = "21";
inventJournalTrans.InventDimIssue = new AxdEntity_InventDimIssue[1] { inventDimIssue };

AxdEntity_InventDimReceipt inventDimReceipt = new AxdEntity_InventDimReceipt();
inventDimReceipt.InventSiteId = "1";
inventDimReceipt.InventLocationId = "11";
inventJournalTrans.InventDimReceipt = new AxdEntity_InventDimReceipt[1] { inventDimReceipt };

journalHeader.InventJournalTrans = new AxdEntity_InventJournalTrans[1] {inventJournalTrans };
journal.InventJournalTable = new AxdEntity_InventJournalTable[1] { journalHeader };

           client.create(context, journal);
catch (Exception e)
string error = e.Message;

Take Care!

Enterprise Portal authentication in Microsoft Dynamics AX 2012 – Finally something that makes sense!

In AX 2012 there is a new authentication terminology - Pluggable authentication. This type of authentication allows users who are not part of Active Directory access to the AX 2012 Enterprise Portal.

In a nutshell, AX 2012 integrates with SharePoint Pluggable Authentication, which provides authentication to external Enterprise Portal users that are not part of an organization's Active Directory.

Further, Pluggable Authentication provides an administrator three additional forms of authentication in addition to Active Directory:

1.       Active Directory Federated Service: Allows users who are associated with an external Active Directory to access Enterprise Portal.

a.       When an ADFS user is removed from the external Active Directory that user does not have access to Enterprise Portal.

2.       Forms Based Authentication: Allows users to authenticate against a custom database of users.

3.       Live Id: Users can authenticate to Enterprise Portal by using Windows Live Id.
See the following diagram:

For more information on the new Enterprise Portal changes in AX 2012 visit

In addition, Brandon George has a really good post about the new Security Architecture in his blog, Check it out

Take care!

Wednesday, January 4, 2012

Helpful AX 2012 links

New Stuff for Developers

What's New in Microsoft Dynamics AX 2012 for Developers [AX 2012]


AOS architecture [AX 2012]

Model store architecture [AX 2012]

Help server [AX 2012]

.NET Business Connector architecture [AX 2012]

Enterprise Portal architecture [AX 2012]

.NET Business Connector

.NET Business Connector Overview [AX 2012]


Microsoft Dynamics AX IDE [AX 2012]

Visual Studio Development for Microsoft Dynamics AX [AX 2012]

Visual Studio Integration [AX 2012]

Business Intelligence

Business intelligence components [AX 2012]

Installation & Configuration

Firewall settings for Microsoft Dynamics AX components [AX 2012]

Verify that you have the required permissions for installation [AX 2012]
Developing Extensible Data Security Policies [AX 2012]
Create service accounts [AX 2012]
Planning hardware infrastructure [AX 2012]

Microsoft Dynamics AX 2012 Implementation Planning Guide [AX 2012]

Moving between Microsoft Dynamics AX 2012 Environments [AX 2012]



AxUpdatePortal Utility [AX 2012]

About the Microsoft Dynamics AX client

[NOTE] The information below has been taken from a Microsoft source.

The client application is a 32-bit Windows application that provides a rich user interface for the Microsoft Dynamics AX application. The client is typically used by employees within an organization.

The client provides the following functionality:

Rich user interface: The client is a Windows application with a rich user interface consisting of forms, menus, and controls. The client includes over 3,000 forms built using a combination of metadata and X++ code. The Microsoft Dynamics AX forms use X++ to process events and business logic. Forms can host managed WinForms or Windows Presentation Foundation (WPF) controls, and X++ can interoperate with managed (.NET) classes and assemblies.

The MorphX development environment: The development environment is integrated into the client application. Authorized developers can use the MorphX development environment to enhance or customize the Microsoft Dynamics AX application.

Integration with Microsoft Office: The Microsoft Dynamics AX application integrates with Microsoft Office. Data in grids can be exported to Microsoft Excel, where that data can be formatted, manipulated, refreshed, modified, and saved back into Microsoft Dynamics AX. You can integrate Microsoft Outlook® with the CRM module to synchronize schedules and tasks bi-directionally.

Unified communications: The client provides integrated unified communications using Microsoft Office Communicator. Key forms and controls are presence-aware for contacts and employees. These forms and controls also provide a visual indicator of the availability of contacts. Users can also use real-time messaging such as instant messaging and outbound voice communication.

Reports: The Microsoft Dynamics AX application provides reports based on SSRS.

Tuesday, January 3, 2012

Microsoft Dynamics AX 2012 - Basic Security Concepts

Hi there!

In AX 2012, role based security provides an extensible framework for defining access to the Microsoft Dynamics AX application and data. It changes a little bit from what we know in ax 2009.

In AX 2009, administrators had to, literally, create their own user groups and manually assign users to those groups.  Also, in order give permission to a user group to execute a particular operation, the administrator had to identify objects, such as tables, fields, and menu items that were required for the operation, which was a pain in AX 2009 as identifying these elements was time consuming.

However, in AX 2012, security is role-based, and many security roles are predefined by the application to make the setup portion of it easy for us. Now, it is important to really comprehend this positive change as in role-based security, users are assigned to roles based on their responsibilities in the organization and their participation in business processes.  In fact, AX 2012 introduces duties, which are a group of privileges (See a short definition below). In addition, an administrator no longer has to identify application objects and grant access to those objects. Instead, the administrator grants access to the duties that users in a role perform and that's it.

In addition, in AX 2012 all permissions for all application objects have been grouped into task-based privileges and duties.  This means that an administrator only has grant access to the Maintain sales order duty, which includes all of the permissions that are required to view, create, modify, and delete sales orders.

Another interesting change has been the concept of reusable permissions.  I don’t know if you had the chance to work with multiple companies in AX 2009, but you couldn’t allow user groups could not span multiple companies. As a matter of fact, if the same functional role was required in two companies, an administrator had to create two user groups and so on and so forth. You know where I’m going with this, right?

In terms of record-level-security, this function is still available in AX 2012, but it will be removed in future versions. In ax 2012, the data security framework I used to help secure the data and take security privileges into account. For example, an administrator can grant View access to one subset of Purchase Orders and Edit access to another subset of Purchase Orders.

There are a few definitions about the AX 2012 security terminology I would like to share with you:

A security role represents a behavior pattern that a person in the organization can play. A security role includes one or more duties.

A duty is a responsibility to perform one or more tasks.  A duty includes one or more privileges.

Privileges specify the access that is required to perform a duty.  A privilege includes one or more permissions.

Permissions include the access level to one or more securable objects that are required to perform the function associated with an entry point.

For more information on AX 2012 security you can go to

Take Care!