Microsoft Dynamics AX 2012 –
Windows 8 Store App
Purpose: The purpose of this document is to illustrate how to develop Windows 8 Store Apps which are integrated with Microsoft Dynamics AX 2012.
Challenge: For the purposes of demonstration or Proof of Concept it may be needed to quickly develop Windows 8 Store App which is integrated with Microsoft Dynamics AX 2012. In order to complete this task at the minimum you will need a machine with Windows 8 OS, Visual Studio 2012 and access to Microsoft Dynamics AX 2012 instance.
Solution: For the purposes of this walkthrough I'll use Microsoft Dynamics AX 2012 R2 Demo VM which can be downloaded from Customer/Partner Source. I also have Windows 8 OS and Visual Studio 2012 installed on my laptop. Windows 8 now includes Hyper-V, so I'll deploy Microsoft Dynamics AX 2012 R2 Demo VM under Hyper-V. This is all I need to develop Windows 8 Store App and integrate it with Microsoft Dynamics AX 2012.
Task: Windows 8 Store App which I'll develop in this walkthrough will display Product Catalog (list of released products in particular company) retrieved from Microsoft Dynamics AX 2012.
Walkthrough:
Connect Microsoft Dynamics AX 2012 R2 Demo VM to the Network
Please note that I created additional External network virtual adapter in Hyper-V Virtual Switch Manager
If you successfully connected Microsoft Dynamics AX 2012 R2 Demo VM to the Network you will see the following indication
Retrieve current IP Address of Microsoft Dynamics AX 2012 Demo VM
Please use ipconfig command to retrieve Windows IP Configuration which includes IPv4 Address
Please use ping command to make sure your host computer can access Microsoft Dynamics AX 2012 Demo VM connected to the same network using IP Address
Modify Hosts file on host machine (C:/Windows/system32/Drivers/etc) to include mapping to Microsoft Dynamics AX 2012 Demo VM machine
192.168.0.102 ax2012r2a.contoso.com
|
Create a list of Released products in Microsoft Dynamics AX 2012
Development:
Inbound port – AlexServices
Please note that AlexServices is Enhanced port using HTTP Adapter
Select service operations – AlexServices
Please note that AlexServices Inbound port exposes InventItemService Web Service operations
On host machine please make sure you can access WSDL URI for AlexServices Inbound port
Create Visual Studio 2012 Windows Store App project
Add Service reference to DynamicsService in Visual Studio 2012 Windows Store App project
Please note that I used FQDN (fully qualified domain name) of Microsoft Dynamics AX 2012 Demo VM machine which includes machine name and domain
After Service reference to DynamicsService is added Visual Studio 2012 will generate a number of proxy classes automatically
Implement ConfigureEndpoint partial method to configure the service endpoint in Reference.cs
static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials)
{
clientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Administrator", "pass@word1", "Contoso");
clientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
serviceEndpoint.Binding = basicHttpBinding;
}
|
This is required because likely your host machine will belong to one domain and Microsoft Dynamics AX 2012 Demo VM to another. In my case my host machine belongs to microsoft.com domain and Microsoft Dynamics AX 2012 Demo VM belongs to contoso.com domain. By implementing ConfigureEndpoint partial method you configure the service endpoint to use impersonation and specific credentials which will allow you to successfully log in into Microsoft Dynamics AX 2012 Demo VM when consuming Microsoft Dynamics AX 2012 Web Service from your host machine. Please note that specified credentials are default credentials for Administrator account in contoso.com domain in Microsoft Dynamics AX 2012 Demo VM.
Load application data from Microsoft Dynamics AX 2012 by calling Item Web Service
public async Task LoadApplicationData()
{
ItemServiceClient client = new ItemServiceClient();
try
{
QueryCriteria queryCriteria = new QueryCriteria();
CriteriaElement criteriaElement = new CriteriaElement();
criteriaElement.DataSourceName = "InventTable";
criteriaElement.FieldName = "NameAlias";
criteriaElement.Operator = Operator.Equal;
criteriaElement.Value1 = "Alex";
queryCriteria.CriteriaElement = new CriteriaElement[1];
queryCriteria.CriteriaElement[0] = criteriaElement;
ItemServiceFindResponse results = await client.findAsync(queryCriteria);
this.products = new ObservableCollection<CatalogProduct>();
if (results != null)
{
foreach (AxdEntity_InventTable item in results.Item.InventTable)
{
CatalogProduct product = new CatalogProduct();
product.ProductId = item.ItemId;
product.Title = item.ItemId;
product.Description = item.ItemId;
product.ImageUri = "../Microsoft_Dynamics_Logo.png";
this.products.Add(product);
}
}
}
catch (FaultException ex)
{
client.Abort();
}
await client.CloseAsync();
}
|
Please note that in this project I use ObservableCollection of CatalogProduct objects describing Released products in Microsoft Dynamics AX 2012
Result
My Windows 8 Store App has its own Tile on Start screen
As the result my Windows 8 Store App will display Product catalog with info about Released products retrieved from Microsoft Dynamics AX 2012
Version: Windows 8, Visual Studio 2012, Microsoft Dynamics AX 2012 R2
Summary: In this walkthrough I demonstrated how to quickly develop Windows 8 Store App which is integrated with Microsoft Dynamics AX 2012. For the purposes of demonstration or Proof of concept you can use Microsoft Dynamics AX 2012 R2 Demo VM which can be downloaded from Customer/Partner Source. Please also note that the same development techniques (exposing and consuming Web Services) will be used when developing production Windows 8 Store Apps integrated with Microsoft Dynamics AX 2012. From authentication perspective Microsoft Dynamics AX 2012 supports various mechanisms such as Windows Integrated authentication, Federated authentication and Claims based authentication (Microsoft account, etc.). Please note that in this walkthrough for the sake of simplicity I used impersonation and Windows Integrated authentication.
Tags: Microsoft Dynamics ERP, Microsoft Dynamics AX 2012, Windows 8, Windows 8 Store App, Modern UI, Visual Studio 2012, AIF, Application Integration Framework
Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the concepts and describe the examples.