Translate

Wednesday, March 20, 2019

Consuming AIF web services deployed from Dynamics Ax from External client- Mobile app

Hi folks,

Hope you are well!!


I have found some interesting things on how to communicate to AX from external client using AIF Websrvice

Once after the service classes is created in AX and deployed under Inbound ports- the svc file exposes the client.

we need to refer this web service reference using C#.

IN VS we need to use 'Add referencne' option and specify the svc file path where it path can be found on AX inbound port.


For example the path looks like this.
http://SERVERNane/MicrosoftDynamicsAXAif60/Messenger/xppservice.svc
where Messanger in the path is the name of the service.

once the service reference is created we need to use and refer that in C# code

using MessangerSolution.MessangerApp;
=>Name of the service refrence created in C# is MessangerApp

declare the service
MessangerApp.BasicHttpBinding_PSV_Messenger app = new BasicHttpBinding_PSV_Messenger();

Providing credentials:
app.UseDefaultCredentials = FALSE;
app.Credentials = new System.Net.NetworkCredential("USERVNAME","SECURE PASSWORD","DOMAIN");

then you can invoke the service class methods like
app.PassMessage();

This also fixes the below issue on network credentials:
System.Net.WebException: The request failed with HTTP status 401: Unauthorized