19 October 2021

Call Dynamics AX2012 AIF Webservice from Postman

Lately I was forced to call a Dynamics AX2012 webservice from Postman. The service is deployed as an HTTP service inbound port in AX on the IIS instance.

First of all I had to authenticate against AX to get around "IIS 8.5 Detailed Error - 401.1 - Unauthorized" - there are some posts in the WWW suggesting to use Fiddler as a supporting tool for the authentication. In my case I was able to use NTLM authentication from postman:

Even though this is still beta it is working quite well for me. 

After that I did some tests with GET and POST. In the header it is important to set

Content-Type = text/xml; charset=UTF-8
SOAPAction = http://tempuri.org/AXService/ProcessWhatever

In the POST scenario I was facing "400 Bad request". This is quite chalanging cause it just means that there is something wrong within the Body. In my case I finally wrote a working XMLwhich looks something like this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<h:CallContext xmlns:h="http://schemas.microsoft.com/dynamics/2010/01/datacontracts"
<h:Language i:nil="true"/>
<h:LogonAsUser i:nil="true"/>
<h:MessageId i:nil="true"/>
<h:PartitionKey i:nil="true"/>
<h:PropertyBag i:nil="true" 
<ABCServiceRequest xmlns="http://tempuri.org">
</ABCServiceRequest >

The last error I saw was "500 internal server error" - Unexpected character encountered while parsing value. This was due to a wrong value within the body of the XML.

After all that was solved I now can try the AX interface through postman and I'm happy to see "200 Ok" and the response from the service

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <ABCServiceRequest xmlns="http://tempuri.org">
            <response>processed :) </response>
        </ABCServiceRequest >

No comments: