The Infolog

A blog of Dynamics AX development tips and tricks

Skip to: Content | Sidebar | Footer

Using AIF services

30 September, 2013 (13:46) | Uncategorized | By: Howard Webb

Here are the steps to get AIF up and running and accessible. In this example I have created an excel add-in to pull on hand information for items.

 

Create a port

 

Firstly you need to create a port to allow access to your data. There are two ways of creating a port, you can either create an advanced port (which gives you a lot more control) or create one by using service groups. I have used the advanced option but tagged on the end of this is a quick summery on creating a service group.

Open up an AX client and browse to System administration/setup/Services and Application Integration Framework/Inbound ports:

Click on new, giving the port a name, description, etc.AI

 

 

Click on “service operations” and then select the services you wish to expose, in this case we are using inventInventoryOnHand:

 

 

Next set the data coming out in the XML by selecting the “customise documents” check box and then clicking on the “data polices” button. This lists the fields your XML document will have in it, it is advisable to remove any you do not need to keep the file size down:

 

 

You can also set things like extra security and logging but they are not needed in the scope of this.

 

With the port fully setup click activate and the port should then activate. This will give you a new field – WSDL URL which will be the service URL:

 

You can now check that your service is accessible by pasting the URL in to a browser (You should get an XML file returned – the xsd).

 

Adding a display method

 

I had also wanted to use a display method which was not originally setup – in this case the item name. After a lot of issues I have managed to set this up.

Firstly add a new Parm method to the AX table class (AXTableName) which will return the value you wish to use:

 

 

Save and compile this new method. Next go to tools ->Application Integration Framework -> Update service. Update the service that you will be using making sure to update the classes:

 

 

This should then automatically create a project and the correct parm methods for you:

 

 

If you are using a service group the xds should now be ok, however if you are using an advanced port I have found it better to open up the data polices and make sure that the extra field is there.

Using the service

 

I have created a small Excel add-on in C# which will pull all of the items and how many are in stock and them move that information in to an Excel spread sheet.

To use the service you will first need to add the service reference in the project. To do this you use the url. Once this has loaded correctly you can call your service and get data out. I will attach the Visual Studio project that I created

 

Creating a service group

 

Create a service group by opening up the AOT, browsing to ‘Service Groups’:

 

Select the services you would like to access and drag and drop them in to your new service group:

Right click and then select deploy and your service will have a port setup in the Inbound port settings.

 

Print Friendly, PDF & Email