Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Exposing data from AX

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?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: Exposing data from AX

    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))

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: Exposing data from AX

    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.

  • ac70 Profile Picture
    ac70 10 on at
    RE: Expose Rest WCF Service in Dynamic Ax 2012 R3 Version

    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
    Martin Dráb 225,490 Super User on at
    RE: Expose Rest WCF Service in Dynamic Ax 2012 R3 Version

    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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans