Microsoft Dynamics AX 2012 Connector | MuleSoft Documentation
# Microsoft Dynamics AX 2012 Connector
Microsoft Dynamics AX 2012 Connector v2.0
Anypoint Connector for Microsoft Dynamics AX 2012 (Dynamics AX 2012 Connector) enables Mule apps to interact with the Microsoft Dynamics AX Query Service.
This connector supports the following operations:
  * Run a query against an AOT table.
  * Run an AOT static query.
  * Call an AIF Document Service.


The connector supports Microsoft Dynamics AX 2012.
## Before You Begin
To use this connector, you must be familiar with:
  * Microsoft Dynamics AX
  * Mule, Mule concepts, elements in a Mule flow, and Global Elements
  * Anypoint Connectors
  * Anypoint Studio


Before creating an app, you must have:
  * Microsoft login credentials to test your connection to your target resource
  * Anypoint Windows Gateway Services installed


For software requirements and compatibility information, see the Connector Release Notes.
## POM File Information
```
<dependency>
 <groupId>com.mulesoft.connectors</groupId>
 <artifactId>mule-microsoft-dynamics-ax-connector</artifactId>
 <version>x.x.x</version>
 <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using.
To obtain the most up-to-date `pom.xml` file information, access the connector in Anypoint Exchange and click **Dependency Snippets**.
### Windows Gateway Services for Anypoint Platform
The Windows Gateway Services agent performs protocol translation when calling the Dynamics AX System Services. The Dynamics AX System Services (Metadata Service, Query Service) use the net.tcp protocol which is not implemented in Java. To execute requests, the connector routes the requests through the Windows Gateway Services as shown in the following image:
  1. The connector sends an HTTP request to the Windows Gateway Services.
  2. The Windows Gateway Services receives the HTTP request.
  3. The Windows Gateway Services executes the request against the Dynamics AX System Services using the netTcp protocol.
  4. The Windows Gateway Services receives the response from the Dynamics AX System Services.
  5. The Windows Gateway Services sends the response to the connector over HTTP.
  6. The connector receives the response.


All communication between the Anypoint Platform and Windows Gateway Services is authenticated and secured by SSL.
## Connect in Anypoint Studio 7
You can use this connector in Anypoint Studio by first downloading it from Exchange and configuring it as needed.
## Add the Connector to a Studio Project
Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.
### Add the Connector Using Exchange
  1. In Studio, create a Mule project.
  2. Click the Exchange icon **(X)** in the upper-left of the Studio task bar.
  3. In Exchange, click **Login** and supply your Anypoint Platform username and password.
  4. In Exchange, search for "ax".
  5. Select the connector and click **Add to project**.
  6. Follow the prompts to install the connector.


### Add the Connector in Studio
  1. In Studio, create a Mule project.
  2. In the Mule Palette view, click **(X) Search in Exchange**.
  3. In **Add Modules to Project** , type "ax" in the search field.
  4. Click this connector’s name in **Available modules**.
  5. Click **Add**.
  6. Click **Finish**.


### Configure in Studio
  1. Drag a connector operation to the Studio Canvas.
  2. For general settings complete these fields:
     * Company: Sets the company to use within all calls.
     * Language: Sets the language to use within all calls.
     * Log on as user: Sets the user to use within all calls.
     * Message id: Sets the message ID to use within all calls.
     * Partition key: Sets the partition key to use within all calls.
Connection parameters:
Parameter | Description  
---|---  
Username | The username to connect to Dynamics AX.  
Password | The password to connect to Dynamics AX.  
AOS Server Name | The name or IP of the server where the Application Object Server is running.  
AOS Services WSDL Port | The port number that the Services WSDL run on. Default is `8101`.  
Gateway Router Service Url | The address (host and port) of the Windows Gateway Services. This address is usually similar to `https://myserver.com:9333/router`  


For advanced connection complete these fields:
  * AOS Endpoint Port (Optional) - Use this configuration to override the service endpoint that is in the services' WSDL document.
  * Connection timeout - Used to set connection timeout for connector requests. This optional value is in milliseconds (0 for unlimited timeout).
  * Receive timeout - Use to set reception timeout for connector requests. This optional value is in milliseconds.


## Use Case: Query Table
  1. Add an HTTP Listener to the flow.
  2. Click the green plus sign to configure it.
  3. Set Host to localhost and Port to 8080.
  4. Click OK.
  5. Add Query Table operation from Microsoft Dynamics AX pallette.
  6. Configure connection by clicking on the green plus sign
  7. Set the above mentioned fields
  8. Complete the Query parameter with `dsql:Select Name from ProjTable`
  9. Add a Transform Message and set it with following:
```
%dw 2.0
output application/json
payload
```

  10. Perform a curl to `localhost:8080`


## Use Case XML
```
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
   xmlns:microsoft-dynamics-ax="http://www.mulesoft.org/schema/mule/microsoft-dynamics-ax"
   xmlns:http="http://www.mulesoft.org/schema/mule/http"
   xmlns="http://www.mulesoft.org/schema/mule/core"
   xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
   http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/microsoft-dynamics-ax
http://www.mulesoft.org/schema/mule/microsoft-dynamics-ax/current/mule-microsoft-dynamics-ax.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
  <configuration-properties file="mule-app.properties"/>
  <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
    <http:listener-connection host="localhost" port="8082"/>
  </http:listener-config>
  <microsoft-dynamics-ax:dynamics-ax-config name="Microsoft_Dynamics_AX_Dynamics_AX"
     doc:name="Microsoft Dynamics AX Dynamics AX">
    <microsoft-dynamics-ax:soap-connection disableCnCheck="true"
     gatewayRouterServiceAddress="${gateway-connection-config.gatewayRouterServiceAddress}"
     username="${gateway-connection-config.username}"
     password="${gateway-connection-config.password}"
     aosServerName="${gateway-connection-config.aosServerName}"
     aosWsdlPort="${gateway-connection-config.aosWsdlPort}"/>
  </microsoft-dynamics-ax:dynamics-ax-config>
  <flow name="dynamics-old-ax-demoFlow2">
    <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/query"/>
    <set-payload value="#[attributes.queryParams.queryToExecute]" doc:name="Set Payload"/>
    <microsoft-dynamics-ax:query-table itemsPerPage="5" doc:name="Query table"
       config-ref="Microsoft_Dynamics_AX_Dynamics_AX">
      <microsoft-dynamics-ax:query>#[payload]</microsoft-dynamics-ax:query>
    </microsoft-dynamics-ax:query-table>
    <ee:transform doc:name="Transform Message">
      <ee:message>
        <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
      </ee:message>
    </ee:transform>
  </flow>
</mule>
```

## See Also
  * Windows Gateway Services Configuration Guide
  * Run a query against an AOT table
  * Run an AOT static query
  * Call an AIF Document Service
  * MuleSoft Help Center