Integrating Microsoft Dynamics AX with other applications can be challenging task especially if its with non-Microsoft platforms like PHP, Java, cURL, etc. It adds more complexity if the access is needed over the internet while using Windows authentication.

In this blog post, I would like to share how I successfully integrated Microsoft Dynamics AX 2012 with PHP application using cURL over the internet using NTLM. This integration is direct and there is no wrapper service in between. You can also use the cURL commands directly from the command line tool. This blog assumes that you are familiar with AIF and services, Dynamics AX 2012 development, some PHP and cURL. The development of AIF service is also beyond the scope and it is assumed that we already have AIF services ready for consumption. I will be demonstrating this for both Custom and Document AIF services.

Services used for this demo

1. Customer document service

2. Custom AIF service for item details

I will be sharing the challenges I faced and their resolutions.

1. Create an Inbound HTTP port 

Go to System administration/Setup/Services and Application Integration Framework/Inbound ports

Create a new port and select

Services operations – Customer create

Adapter : HTTP

Now you have to do 2 things:

a. Add service routing behavior

b. Set security to NTLM

a. Add service routing behavior

Our inbound port is ready but not yet deployed. Click Configure to open WCF settings.


Now add service routing behavior. This step is mandatory. It will expose your IP address in the WSDL instead of the machine name. I wasted a couple of hours getting errors that the system is unreachable. You cannot use your machine name in the WSDL. It will work within the network but outside the network you should use your static IP addresss. This is where you do that:




b. Set security to NTLM

To use secure transport communication, you should not use basic authentication. Also, Windows will not work with Php and cURL. Instead, use NTLM. This needs to be done at 2 place, once in your inbound port and next in your IIS authentication settings.

To set NTLM for inbound port, go to the WCF configuration and make the changes below:




Deploy the inbound port. We are done with AX level settings.

Make similar changes in your IIS authentication for that service endpoint:


Now the configurations are done. Now, we’ll call this service using cURL and PHP.

Create a customer using AX 2012 Customer Document service:

1. First create a request xml for Customer create. It should look like the following:

Customer XML


cURL to create customer

Save the above xml file and call it CustR.xml

Next, open cURL and execute the script below:

curl.exe –ntlm –user domain\userName:password  -H “Content-type: text/xml; charset=utf-8” -H “SOAPAction: http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/create” –trace-ascii dump.txt –data-binary @CustR.xml –v

Parameter name Purpose
user add credentials here with the format domain\user:password
data-binary specify the file name where your data is. In our case, it was the request xml
SoapAction Mention the service action here.
H Its for specifiying the message headers. Details like Content-type, SoapAction, etc should come here.
NTLM This is the authentication we are using. It can be basic, negotiate or anyauth

Now, lets execute this using cURL. Boom! my customer got successfully created here. Here is the response:

customer creaet

Now, let me convert this code into Php. My script becomes the following:


For Custom AIF services:

Likewise, for Custom services you need to follow the same steps. AX does not expose the schema for a custom service so that becomes a pain point. Here is a sample working xml message:

<Envelope xmlns=”http://schemas.xmlsoap.org/soap/envelope/”>

<CallContext xmlns=”http://schemas.microsoft.com/dynamics/2010/01/datacontracts”>
<AXPulseCustomService xmlns=”http://tempuri.org”>

That’s all folks. Thank you for reading. In case of confusion or any help, feel free to email me at Bilal@AXPulse.com

Leave a Reply

Recent Comments