Consuming a Web Service in Dynamics AX 4

This will tell you how to use Common Language Runtime Interoperability feature in Dynamics AX 4 to reference a web service.  There is a pretty good discussion about this on Microsoft MBS community by Dilip and Mike Frank.

To continue, at least you need to have Dot Net Framework SDK 2.0.  (Not Visual Studio .Net) We will use the language translation service on as the referenced web service.

Download and Install .NET Framework Version 2.0 Software Development Kit.

Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

At the command prompt, run the following command:
Wsdl /l:cs /protocol:soap
This will generate a C# source code file of proxy classe, which in this situation is TranslationService.cs

Then we need to edit TranslationService.cs file to add namespace for it.
Use NotePad to edit TranslationService.cs, the edited codes should look like
// <auto-generated>

namespace DemoAXWebService //Add namespace declaration
    using System;
}//End namespace declaration

Compile the cs file to dll file. Type this in the command prompt
csc /t:library TranslationService.cs

This will generate the TranslationService.dll.
Copy the TranslationService.dll to Program FilesMicrosoft Dynamics AX40clientBin.

Start Microsoft Dynamics AX 4.0
Open Application Object Tree, and locate the Reference node. Right click, select Add Reference and register the TranslationService.dll in Dynamics AX.

Create a new job named TestWebService
static void TestWebService(Args _args)
    DemoAXWebService.TranslationService translateService
     = new DemoAXWebService.TranslationService();
    str strLanguage, strMessage;
    str translateResult;

    strLanguage = ‘en_de’;
    strMessage  = ‘Test Web Service’;
    translateResult = translateService.Translate(strLanguage, strMessage);

Run the job, you will get the result “Test-Netz-Service”.


This entry was posted in Axapta Development. Bookmark the permalink.

1 Response to Consuming a Web Service in Dynamics AX 4

  1. Søren Regenberg says:

    Hi Fred

    This is just what I needed. Adding the namespace to the CS file did the trick. Many thanks and please drop an email if I can do anything.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s