web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Exposing data from AX

(0) ShareShare
ReportReport
Posted on by 10

I am new in Dynamic Ax too. Is there a tutorial which explains what are the operation to do on Dynamic Ax to expose the data?

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Hi ax70, it sounds like you're looking for information about AX web services in general, rather than about how to expose them as RESTful services. It that correct?

    If so, please create a new thread for your topic, because it doesn't belong here.

  • ac70 Profile Picture
    10 on at

    Hi Martin, yes. I created a class that I am trying to consume from a simple desktop application in c# but it does not work.

    This is my class in AX. I want to return all records from the table cusTable

    [SysEntryPointAttribute(true), AifCollectionTypeAttribute('return', Types::Record)]
    public List getCustomerNameList()
    {
       CustTable cusTable;
       List list = new List(Types::Record);
       
       // return in a list all Customer Name
       while select * from cusTable
       {
           list.addEnd(cusTable);
       }
       return list;
    }

    When I try to distribute the service group I get this error:

    Unable to generate service 'TestCustomerServiceDemo'.\n Error: Unable to create and return the AifCollectionTypeAttribute object for the.getAttributes() reflection API. Verify the parameters.

    In c# I imported the service reference and I call the method:

    ServiceReference1.CallContext context = new ServiceReference1.CallContext();
    var request = new ServiceReference1.TestCustomerServiceDemoGetCustomerNameListRequest(context);
    ServiceReference1.TestCustomerServiceDemoClient client = new ServiceReference1.TestCustomerServiceDemoClient();
    var response = client.getCustomerNameList(request);

    Can you help me please?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Before we get into your actual question, let me deal with some moderator's stuff.

    I moved this discussion from Expose Rest WCF Service in Dynamic Ax 2012 R3 Version, becuase you confirmed that your question isn't about the same topic. Please don't try to hijack threads that are about different things. If there is no suitable thread, simply create a new one (in the right forum, with a descriptive title etc.). And provide enough information about your problem.

    Also, your code was difficult to read, because you posted it in a wrong way. Use Insert > Insert Code (in the rich formatting view) for this purpose. I've already update code in your reply above, therefore you can see how it looks.

  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    First of all, a custom service isn't a tool appropriate for returning all customer. Instead, look at Query Service and AIF Document Services.

    Anyway, the bug in your particular code is caused by the fact that you didn't specify which type of data you return in the collection. You should say that it's CustTable, so the right data contract can be generated. For example:

    AifCollectionTypeAttribute('return', Types::Record, tableStr(CustTable))

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans