Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Getting a list of customers via web services

Posted on by 430

Hi Experts,

I want to get a list of customers via a web service in AX.

I need a c# code sample to read all customers from Dynamics Ax 2012 using aif service and display customer number, customer name alias, customer first name on console.

Can anyone suggest me that how to achieve this.

Thanks

Sona Jee

*This post is locked for comments

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Getting a list of customers via web services

    I've created my own service TestServiceClient and solution in VS. And this is works:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace TestProject
    {
        public partial class Form1 : Form
        {
            ServiceReference1.TestServicesClient client = new ServiceReference1.TestServicesClient();
            ServiceReference1.CallContext context = new ServiceReference1.CallContext();        
    
            string[] custList;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                client.ClientCredentials.Windows.ClientCredential.Domain   = "######";
                client.ClientCredentials.Windows.ClientCredential.UserName = "######";
                client.ClientCredentials.Windows.ClientCredential.Password = "######";            
                
                context.Company = "###";
                
                custList = client.getCustList(context);                         
    
                for (int i = 0; i < custList.Length; i++)
                {
                    listBox1.Items.Add(custList[i].ToString());
                }
            }
        }
    }
    


  • Sona Jee Profile Picture
    Sona Jee 430 on at
    RE: Getting a list of customers via web services

    Yes i added a ServiceReference in my solution but i am getting same error.

  • Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Getting a list of customers via web services

    Did you add a ServiceReference to your solution?

  • Sona Jee Profile Picture
    Sona Jee 430 on at
    RE: Getting a list of customers via web services

    Hi Rustem Galiamov

    I  tried with above  link but i received following error:

    "The type or namespace ‘<namespace name>’ does not exist in the class or namespace ‘<parent namespace>’ (are you missing an assembly reference?)”.

    This error comes when i am using the CriteriaElement.

    I just want to know which assembly reference needed for CriteriaElement.

    Thanks

    Sona Jee

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Getting a list of customers via web services

    Hi Sona Jee!

    Take a look at this discussions:

    https://community.dynamics.com/ax/f/33/t/70030

    https://community.dynamics.com/ax/f/33/t/221600

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans