Microsoft Dynamics AX Support

This blog contains posts by the Microsoft Dynamics AX Support teams Worldwide

How to Call the Read Operation on an AIF Web Service

How to Call the Read Operation on an AIF Web Service

Rate This
  • Comments 4

If you know the primary key of an entity you can call the read operation on a web service.  The response document contains all of the fields for that entity.  The code below is an example of how to call the read operation.  I am using a custom service but the code would be very similar for whatever service you want to call the read operation on:

Query4Service

proxy = new Query4ServiceClient();

AxdQuery4 query3 = new AxdQuery4();

AxdEntity_LedgerJournalTable_1 trans = new AxdEntity_LedgerJournalTable_1 ();  

 

EntityKey[] entityKeyList = new EntityKey[1]; 

EntityKey key = new EntityKey();

 

KeyField[] keyFields = new KeyField[1];

 KeyField keyField = new KeyField();

keyField.Field = "JournalNum";

keyField.Value = "000065_010";

keyFields[0] = keyField;Query4ServiceReadResponse response = proxy.read(request);

key.KeyData = keyFields;

entityKeyList[0] = key;

AxdEntity_LedgerJournalTable_1[] returnedTrans = response.Query4.LedgerJournalTable_1;

Query4ServiceReadRequest request = new Query4ServiceReadRequest(entityKeyList);

Leave a Comment
  • Please add 4 and 7 and type the answer here:
  • Post
  • Would you be able to show same example using AX 2012 services? Thank you.

  • Hi Max,

    Here are some examples.

    Calling the LedgerPurchaseInvoice Service in AX 2012

    blogs.msdn.com/.../calling-the-ledgerpurchaseinvoice-service-in-ax-2012.aspx

    Calling the Update Operation on Services in AX 2012

    blogs.msdn.com/.../calling-the-update-operation-on-services-in-ax-2012.aspx

    Creating Financial Dimension Combinations in AX 2012

    blogs.msdn.com/.../creating-financial-dimension-combinations-in-ax-2012.aspx

    Calling the InventTransferJournalService in AX 2012

    blogs.msdn.com/.../10253599.aspx

    If you need something specific, let us know and we'll be glad to work on it.

    Thanks,

    Scott Wright

  • Is it possible to call these Services using AIF ports? I would like to use the standard class InventInventoryOnHandService and pass in an XML file to an inbound port and have it respond with an XML file with the quantity values (avail physical, ordered, etc.)

    It looks like I should be able to use something like msdn.microsoft.com/.../hh352313.aspx, but the online documentation is designed around creating a record in the sales order, so you pass it sales order and sales line values. I just want to pass a parameter that doesn't get read anywhere.

    Becky Newell wrote this: blogs.msdn.com/.../how-to-call-the-read-operation-on-an-aif-web-service.aspx

    But there is no clear way to translate that to an XML request file

  • Tom,

    Yes using the File Adapter or MSMQ adapter can work to read data from an external request.  (Additionally an Outbound queue can be used also.  Using outbound queues are initiated by code within AX so they are internal.)  If the request is coming from external to AX, then you would use an Inbound port with a Response Address to do this.  So you would construct a “read” request XML document and place it in the inbound port URI folder location.  This file would be processed by AIF inbound processing via batch job.  (There is documentation out there to the four classes you add in the batch job for AIF processing.)  The response then is another XML message (to file or MSMQ) with the desired data that would go where the Response Address is set.  

    technet.microsoft.com/.../aa642551.aspx contains information on what a "Read" Action XML would look like.

    Hope that helps, if you have further issues it might be worthwhile to open a support ticket.

Page 1 of 1 (4 items)