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 :
Microsoft Dynamics AX (Archived)

Getting a list of customers via web services

(0) ShareShare
ReportReport
Posted on by

I want to get a list of customers via a web service in AX.  I was hoping to use the CustCustomerService class, but I'm not having much luck. My code is:

CustCustomerSvc.CallContext cc = new CustCustomerSvc.CallContext();
cc.Company = "DAT";
CustCustomerSvc.CustomerServiceClient csc = new CustCustomerSvc.CustomerServiceClient();
CustCustomerSvc.EntityKey[] ek = new CustCustomerSvc.EntityKey[1];
CustCustomerSvc.DocumentPaging dp = new CustCustomerSvc.DocumentPaging();
dp.PageSize = 100;
CustCustomerSvc.EntityKeyPage ekp = csc.getKeys(cc, dp);
foreach (CustCustomerSvc.EntityKey key in ekp.EntityKeyList)
{
    object ob = key.KeyData.GetValue(0);
    Debug.WriteLine(ob.ToString());
}

I published the service, but it doesn't seem to retrieve anything (doesn't return errors either). I get no entity keys even though all my companies have customers.

Am I doing something wrong? Do I need to create my own service?

What we'd like to do is have an external service that iterates through the customers and updates the Lat/Lon on their addresses.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    How about following the example in the documentation? It is explaining how to read customers using netTcp connection and a document service: technet.microsoft.com/.../jj710374.aspx

  • Community Member Profile Picture
    on at

    I saw that example, but it doesn't do what I'm asking for. I don't want to query specific customers. I want a list of all customers.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You've said that you are not getting back anything. My reply was to follow the example, which would at least return you something, from which you could improve your logic.

    Since you did not explain your exact requirements, it is hard to provide an exact solution, but I will try anyway.

    In our environment we have addressed the problem from a different angle though, we are running a batch job in AX, which then feeds the customer address details to an external service that calculates the lat/long values and we update it back to the table. So instead of push, we pull the information.

    If I would implement a Latitude/Longitude update from an external source, since that is on the address record of the customer, I would do a simple Custom AIF Service with an Entry point where the parameters take Customer account number, and the lat/long real figures. Then within the AX method you could do the search, and update of the record entries easily. Then since you are in C#, you could either pull the customer accounts list directly from SQL database, or expose it via another Custom AIF service as a Data contract containing the list of customer accounts in any format you want (AxaptaRecord, container/array).

    If you insist to update it from outside, here is another example of how you could retrieve a value, and then update it using C# and document services (instead of the custom service approach):

    https://blogs.msdn.microsoft.com/axsupport/2012/05/21/calling-the-update-operation-on-services-in-ax-2012/

  • Verified answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    If the service doesn't throw any error and it simply returns an empty value, it must mean that the service works but no applicable records were found. Make sure you have customers in the DAT company, the user has permissions to read them and they aren't filtered out by a document filter.

    If everything fails, don't forget that you can debug the service to see what exactly happens there.

  • Community Member Profile Picture
    on at

    Thanks. I'll just create my own class and service. I guess that will be the easier solution.

  • Community Member Profile Picture
    on at

    Martin, how do I debug web service calls from AX? Just placing a breakpoint in the code doesn't appear to be sufficient.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Here you go, using your favorite search engine would have revealed the same searching for "ax debug web service" as a first page hit:

    blogs.msdn.microsoft.com/.../debugging-services-in-ax-2012

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans