Connect a Windows Mobile Device with Dynamics AX
18. August 2010 9 Comments
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
- Go to Basic → Setup → Application Integration Framework → Services
- Select Refresh button to update service list
- Enable CustCustomerService
- Generate the webservice
- To verify your service is working open the IIS manager
- Go to → Sites → Default Web Site → MicrosoftDynamicsAxAif50 → Content View
- Right Click on CustomerSerivce.svc and Browser
- You should see a web page with a link to a WSDL file
- Follow the link an you should see an XML document containing the service contract
Implement Mobile Device Project
- Open Visual Studio and Create a new Solution
- Add a new Smart Device Project
- Go to References and add a new service reference
- Provide the URL of your Dynamics AX CustomerService
- Open Form1.cs file
- Add a text field (Name: textBoxAccountNum),
a button (Name: buttonLookup)
and a label (Name: labelName) to your form - 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:
What if we wan’t to host this service somewhere? what do you think are good options? and how to go about it?
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
If I would like to use .net business connector with window mobile , How to do ?
Thank
my service is not visible on IIS-Sites → Default Web Site → MicrosoftDynamicsAxAif50 → Content View , how can i add that, please help me out…………
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…….
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 …….
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?
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.
i did not get any error while referncing the service, but there is no proxy available to use.