Connect a Windows Mobile Device with Dynamics AX

It’s easy to connect a mobile device like a smartphone with Dynamics AX using web services. This tutorial requires Microsoft Dynamics AX 2009 with AIF Webservices installed and Visual Studio for Smart Device development.

Deploy AIF Service

  1. Go to Basic → Setup → Application Integration Framework → Services
  2. Select Refresh button to update service list
  3. Enable CustCustomerService
  4. Generate the webservice

    Aif Services

    Aif Service

  5. To verify your service is working open the IIS manager
  6. Go to → Sites → Default Web Site  → MicrosoftDynamicsAxAif50  → Content View

    IIS 7 Manager on Windows Server 2008

    IIS 7 Manager on Windows Server 2008

  7. Right Click on CustomerSerivce.svc and Browser
  8. You should see a web page with a link to a WSDL file
  9. Follow the link an you should see an XML document containing the service contract

Implement Mobile Device Project

  1. Open Visual Studio and Create a new Solution
  2. Add a new Smart Device Project
  3. Go to References and add a new service reference
  4. Provide the URL of your Dynamics AX CustomerService
  5. Open Form1.cs file
  6. Add a text field (Name: textBoxAccountNum),
    a button (Name: buttonLookup)
    and a label (Name: labelName) to your form
  7. Double Click on the button and implement the service call:
private void buttonLookup_Click(object sender, EventArgs e)
{
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential();
    credentials.Domain = "YOUR_DOMAIN_NAME";
    credentials.UserName = "YOUR_USER_NAME";
    credentials.Password = "YOUR_USER_PASSWORD";

    QueryCriteria query = new QueryCriteria();
    query.CriteriaElement = new CriteriaElement[1];
    query.CriteriaElement[0] = new CriteriaElement();
    query.CriteriaElement[0].DataSourceName = "CustTable";
    query.CriteriaElement[0].FieldName = "AccountNum";
    query.CriteriaElement[0].Operator = Operator.Equal;
    query.CriteriaElement[0].Value1 = textBoxAccountNum.Text;

    CustomerService service = new CustomerService();
    service.Credentials = credentials;
    try
    {
        AxdCustomer customer = service.find(query);
        if (customer != null &&
            customer.CustTable != null &&
            customer.CustTable.Length > 0)
        {
            labelName.Text = customer.CustTable[0].Name;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Service Call failed",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Hand,
                        MessageBoxDefaultButton.Button1);               
    }           
}

You application should look like that:

Windows Mobile 5 Emulator

Windows Mobile 5 Emulator

About erpcoder
Azure Cloud Architect and Dynamics 365 enthusiast working in Research & Development for InsideAx

9 Responses to Connect a Windows Mobile Device with Dynamics AX

  1. Ahmed says:

    What if we wan’t to host this service somewhere? what do you think are good options? and how to go about it?

    • erpcoder says:

      I cases where a device cannot connect directry to AX, it might be a good idea to use sql server compact edition in order to keep some data on the device. But you have to implement a way to sync the offline device db with your dynamics ax db

  2. aha says:

    If I would like to use .net business connector with window mobile , How to do ?
    Thank

  3. sunny says:

    my service is not visible on IIS-Sites → Default Web Site → MicrosoftDynamicsAxAif50 → Content View , how can i add that, please help me out…………

    • sunny says:

      one more thing,,, when i add reference of ax service in my smart device project for barcode scanner, reference was added successfully but when i try to use that reference in my code its show nothing and when i check Web reference– refernece.cs file in my project file, that was blank……….. there is no code in that class,why its behaiving like this,.,,,.please help…….

      • sunny says:

        eine weitere Sache,,,,,, wenn ich hinzufügen Referenz der Axt Service in meinem Projekt für intelligente Geräte für Barcodescanner, Referenz wurde erfolgreich hinzugefügt, aber wenn ich versuche, diese Referenz in meinem Code verwenden, seine Show nichts und wenn ich überprüfen, Web-Referenz refernece.cs Datei in meinem Projekt-Datei, die war leer ……….. gibt es keinen Code in der Klasse, warum seine behaiving wie diese,.,,,. bitte helfen …….

      • erpcoder says:

        I dont understand your comment. Did you add the reference to a webservices to your visual Studio Project? Did you get any Errors adding the Service?

    • erpcoder says:

      Did you generate and deploy the .NET service artifacts to your MicrosoftDynamicsAxAif50 Directory? Also there is a set of predefined Services available, you have to choose which to deploy.

  4. sunny says:

    i did not get any error while referncing the service, but there is no proxy available to use.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: