Sunday, May 1, 2016

Warehouse Mobile Devices Portal for New Microsoft Dynamics AX [Not Production]

Warehouse Mobile Devices Portal for New Microsoft Dynamics AX [Not Production]

Purpose: The purpose of this article is to illustrate how to configure Warehouse Mobile Device Portal in New Microsoft Dynamics AX and quickly make it available on mobile devices for the purposes of POC (Proof of Concept), demonstration or workshop using Demo environment

Scenario: Often times for the purposes of POC (Proof of Concept), demonstration or workshop it is needed to configure Warehouse Mobile Device Portal in New Microsoft Dynamics AX Demo environment. In this article we’ll explore nuances of how to set up Warehouse Mobile Device Portal in New Microsoft Dynamics AX Demo environment, and what are the options while setting up your demonstration scenarios  

Important: Please follow the official guidance when settings up Warehouse Mobile Device Portal in New Microsoft Dynamics AX for Production purposes: https://ax.help.dynamics.com/en/wiki/warehouse-mobile-devices-portal-for-microsoft-dynamics-ax/

Walkthrough

We’ll begin with New Microsoft Dynamics AX deployment in the Cloud via LCS (Lifecycle Management Services): https://lcs.dynamics.com. Once deployed the URL to access New Microsoft Dynamics AX may look like the following: https://alexaos.cloudax.dynamics.com/
For the purposes of this walkthrough we’ll deploy Demo topology of New Microsoft Dynamics AX

LCS project - Environments


LCS user owning the project under which we deploy New Microsoft Dynamics AX will be created as Admin user in New Microsoft Dynamics AX

System administration > Users > Users


Let’s take a quick look at hosts file on the respective VM

Hosts file


Hosts file


Alright, localhost (127.0.0.1) is mapped to alexaos.cloudax.dynamics.com 

127.0.0.1    alexaos.cloudax.dynamics.com

Now let’s take a quick look at IIS Web sites deployed via IIS Manager

IIS Manager


There’s AOSService IIS Web site deployed

IIS Manager > Sites > AOSService


We’ll examine AOSService IIS Web site bindings

Site Bindings


2 bindings do exist by default for AOS itself and SOAP Web Services endpoint on port 443 (HTTPS). Both bindings are registered for host names. Host Names: alexaos.cloudapp.dynamics.com, alexaossoap.cloudax.dynamics.com

Edit Site Binding


There’s also a respective certificate assigned

Certificate - General


Certificate – Certificate Path


AOSService IIS Web site is assigned to AOSService IIS Application pool

IIS Manager > Application Pools


Also there’s a registered domain name for alexaos.cloudax.dynamics.com that translates to a particular public IP address

Cmd - ping


If we look at the respective VM HTTPS endpoint is enabled by default on standard port 443

Azure VM HTTPS Endpoint


Okay, we looked around the setup available by default, and now we’ll set up WMDP (Warehouse Mobile Devices Portal) first to work in a web browser on the VM, then to work on the device outside of the VM and finally run WMDP in simulation mode from within New Microsoft Dynamics AX user interface   

Step 1: On the VM

First immediate step will be to download WMDP from Warehouse Management > Setup > Mobile device > Download Warehouse Mobile Device Portal. We’ll do it using Internet Explorer (IE) web browser on the VM

Dynamics AX


In order to enable download, we’ll change Internet Explorer web browser settings (Internet options > Security tab > Internet (zone) > Custom level) and enable appropriate radio buttons. Please note that for the purposes of POC in this walkthrough it is fine, in fact security settings of web browser will be managed differently and strictly for Production environments to ensure maximum level of protection 
When Download Warehouse Mobile Devices Portal installer windows pops it will provide a checklist of security best practices which need to be followed for Production environments. But again for the purposes of POC in this walkthrough we’ll mark all checkboxes to get past this step and begin download

Download Warehouse Mobile Devices Portal installer


Once WarehouseMobileDevicesPortal.msi is downloaded we can begin installation process

WarehouseMobileDevicesPortal.msi


Installation process is very intuitive

Microsoft Dynamics AX Warehouse Mobile Devices Portal Setup Wizard - Welcome


Microsoft Dynamics AX Warehouse Mobile Devices Portal Setup Wizard – Destination Folder


Microsoft Dynamics AX Warehouse Mobile Devices Portal Setup Wizard – IIS configuration


Note: Please note that on this step I specified port 9999 to be used for WDMP IIS Web site deployment

Microsoft Dynamics AX Warehouse Mobile Devices Portal Setup Wizard – Ready to install


Microsoft Dynamics AX Warehouse Mobile Devices Portal Setup Wizard - Completed


Once installation of WMDP is completed we can see respective Dynamics AX Warehouse Mobile Devices Portal DEFAULT IIS Web site deployed

IIS Manager > WMDP DEFAULT 


We can also review its bindings

IIS Manager > WMDP DEFAULT 


IIS Manager > WMDP DEFAULT > Site Bindings 


Please note that because I specified port 9999 during installation process appropriate binding for port 9999 has been created for HTTPS protocol

Also WMDP DEFAULT IIS Web site belongs to WMDP DEFAULT IIS Application pool

IIS Manager > Application pools


At this point if we try to access WMDP in a web browser on https://localhost:9999 we’ll get an error because WMDP has not been configured yet

WMDP


For the purposes of experiment, we’ll also add additional HTTP binding on port 9998

Add Web site Binding (HTTP)


Now WMDP IIS Web site bindings will look like the following

Site Bindings


IIS Manager > WMDP


Now we should configure WMDP before we can use it

One of the steps in configuration process is to register an app for WDMP. In order to do that we’ll log into Microsoft Azure portal and navigate to Active Directory  

Active Directory  


Next we’ll open Add application dialog on Applications tab

Active Directory > Applications


On Add application dialog we’ll select Native client application

Add application – Tell us about your application


For the purposes of POC in this walkthrough we’ll specify a fake redirect URL

Add application – Application information


Now application has been registered and we’ll navigate to Configure tab to retrieve necessary information and do additional setup

Application


On Configure tab we’ll take a note of Client ID GUID (which will be required on the subsequent steps) and also assign appropriate permissions for the application

Application > Configure


Specifically, we’ll add Microsoft Dynamics ERP as application

Permissions to other applications


And assign 3 permissions to it as shown below

Permissions to other applications


Let’s assume Client ID GUID is “XYZ” for simplicity of explanation

At this point with all necessary info on-hand we can modify Web.config file for WMDP. We can very quickly get to the file system folder where Web.config for WMDP resides by right clicking WMDP Web Site in IIS Manager and selecting Explore to open file explorer window 

IIS Manager > Sites > WMDP > Explore


Here’s Web.config file we need to modify

File explorer > Web.config


In Web.config file at minimum we need to provide a few pieces of information required for configuration. They are: Service reference URI, Auth service security resource, Service client ID (GUID we registered and memorized earlier), Service user name, Service user password (for the sake of simplicity for the POC we’ll specify Admin user credentials), Service auth URL. Pretty much everything is very straightforward. Speaking about Service auth URL, for example, if our domain is “microsoft” we’d specify “https://login.windows.net/microsoft.onmicrosoft.com”, or if our domain is “contosoax7” we’d specify “https://login.windows.net/contosoax7.onmicrosoft.com”. You can also see this name when you are logging in into Microsoft Azure portal, for example, https://manage.windowsazure.com/microsoft.onmicrosoft.com#Workspaces/All/dashboard. So it is easy to locate

This is how modified Web.config file will look like. Please note that I removed PublicKeyToken values from the text below to simplify reading (…)

Web.config

<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
  <configSections>
    <sectionGroup name="ServiceConnectionGroup">
      <section name="ServiceConnection"
              type="Microsoft.Dynamics.AX.Whs.Web.Configuration.ServiceSettings"
              allowLocation="true"
              allowDefinition="Everywhere"/>
      <section name="ServiceProtocol"
              type="Microsoft.Dynamics.AX.Whs.Web.Configuration.ServiceProtocol"
              allowLocation="true"
              allowDefinition="Everywhere"/>
    </sectionGroup>
  </configSections>
  <ServiceConnectionGroup>
    <ServiceConnection>
      <ServiceReference
        URI="https://alexaos.cloudax.dynamics.com/api/services"
        TimeoutSeconds="600"/>
      <Authentication
        ServiceSecurityResource="https://alexaos.cloudax.dynamics.com"
        ServiceClientID="XYZ"
        ServiceUserName="alex@microsoft.com"
        ServiceUserPassword="pass@word1"
        ServiceAuthenticationURL="https://login.windows.net/microsoft.onmicrosoft.com"/>
    </ServiceConnection>
    <ServiceProtocol>
      <SessionXmlDocument MaxSizeBytes="2500000"/>
      <DisplaySettingsXmlDocument MaxSizeBytes="2500000"/>
      <CompaniesList MaxSizeBytes="10151"/>
      <CultureID MaxSizeBytes="10"/>
    </ServiceProtocol>
  </ServiceConnectionGroup>

  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <httpCookies httpOnlyCookies="true" requireSSL="true"/>
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
    -->
    <compilation debug="false" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=…"/>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=…"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=…"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=…"/>
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…"/>
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…"/>
      </assemblies>
    </compilation>
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
    -->
    <authentication mode="None"/>
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.-->       
    <customErrors mode="On" defaultRedirect="~/Error"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <namespaces>
        <add namespace="Microsoft.Dynamics.AX.Whs.Web"/>
        <add namespace="System.Web.Mvc"/>
        <add namespace="System.Web.Mvc.Ajax"/>
        <add namespace="System.Web.Mvc.Html"/>
        <add namespace="System.Web.Routing"/>
        <add namespace="System.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="System.Xml"/>
        <add namespace="System.Web.Helpers"/>
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
    <httpHandlers>
      <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=…"/>
    </httpHandlers>
    <sessionState timeout="600"/>
    <globalization enableClientBasedCulture="true" uiCulture="auto" culture="auto"/>
  </system.web>
  <!--
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers>
      <remove name="MvcHttpHandler"/>
      <remove name="UrlRoutingHandler"/>
      <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=…"/>
    </handlers>
  </system.webServer>
</configuration>

Coming back to Bindings they look like the following at this point

Site Bindings


We’ll also do an additional step in HTTPS Binding configuration by adding a host name (I reused the original AOS host name for the sake of simplicity for the purposes of POC) and SSL certificate (I reused the original AOS SSL certificate for the sake of simplicity for the purposes of POC)

Edit Site Binding


Now WMDP IIS Web site bindings look like the following

Site Bindings


At this point if we access the following URL: https://alexaos.cloudax.dynamics.com:9999/ we can proceed with configuration of WMDP

Microsoft Dynamics AX Warehouse Mobile Device Portal


Our next step will be to load web application configuration according to modified Web.config file. For these purposes we’ll select “Load web application configuration” link

Web configuration loading


As the result we’ll see the following message: “Web configuration was loaded successfully. If there are any service user credentials stored in Web.config file, they should be removed now. Please set ServiceUserName and ServiceUserPassword to empty string.”. As suggested now it will be a good time to remove Admin credentials we used from Web.config file

Then we’ll reload WMDP and select “Log on to the mobile device” to select company in case of multi-company setup

Select company  


For the sake of this walkthrough we’re using a standard demo data set and we’ll select USMF company that has enough data pre-set up for us to continue

Sign in to AX (USMF)


On Sign in to AX screen we’ll provide valid Warehouse user credentials and then we can continue with our functional scenarios. This is great! But I’m curious if for the purposes of POC we can run WMDP via HTTP instead of HTTPS. That’s why I’ll repeat the process using HTTP URL 

Log on to the mobile device (HTTP)


Select company (HTTP)


As the result I’ll be getting the following error: “Sorry, an error occurred while processing your request. Please retry your request or contact your system administrator” 

Microsoft Dynamics AX Warehouse Mobile Devices Portal: Error


If we look into Event Viewer we’ll find an explanation for this error: “Exception type: HttpAntiForgeryException, Exception message: A required anti-forgery token was not supplied or was invalid” 

Event Viewer


Exception

Exception information:
    Exception type: HttpAntiForgeryException
    Exception message: A required anti-forgery token was not supplied or was invalid.
   at System.Web.Helpers.AntiForgeryWorker.Validate(HttpContextBase context, String salt)
   at System.Web.Helpers.AntiForgery.Validate(HttpContextBase httpContext, String salt)
   at System.Web.Mvc.ValidateAntiForgeryTokenAttribute.OnAuthorization(AuthorizationContext filterContext)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

WMDP is meant to be run via HTTPS, and we’ll switch to HTTPS for further steps
Great! We can run WMDP via HTTPS, but for convenience if inside of the VM we can introduce a dedicated host name for it, for example, “alexwmdp.cloudax.dynamics.com”. In order to do that we can change Hosts file 

Hosts file


And modify binding appropriately

Binding (Change)


Site Bindings


Now the same WMDP Web site is accessible via a new URL from within the VM thanks for translation introduced in Hosts file

Microsoft Dynamics AX Warehouse Mobile Devices Portal


Select company


Sign in to AX (USMF)


It is more convenient to use a meaningful name like “alexwmdp”, in fact if we want to access alexwmdp.cloudax.dynamics.com from outside of the VM this name will obviously not be resolved
So for the next step we’ll expose WMDP via internet. Again this will get us going quickly for the purposes of POC, in fact please do not use this configuration for Production purposes and follow the official guidance here instead: https://ax.help.dynamics.com/en/wiki/warehouse-mobile-devices-portal-for-microsoft-dynamics-ax/ 

Step 2: On Internet

On Microsoft Azure Portal we can find a Public Virtual IP (VIP) address of the VM as shown below

Public Virtual IP (VIP) address


Thus technically to access https://alexwmdp.cloudax.dynamics.com:9999 we can use IP address instead: https://2X.10X.19X.22X:9999/. This will not bear a fruit for us yet because custom 9999 port is not exposed, instead standard 443 port is exposed for HTTPS 

Can’t reach this page


In fact we can make the setup even more convenient and reusable if we will be using standard 443 port for HTTPS and register a custom domain name for WMDP. This is exactly what we’re going to do next

Let’s say we want WMDP to be accessible via the following URL: https://demo.alexwmdp.com
In order to achieve that we’ll change WMDP Web site binding as shown below

WMDP Web site


Site Bindings


Edit Site Binding


Please note that I’m still reusing the original SSL certificate which is going to give us Certificate warning in the future because this certificate is registered for a different domain name. In fact this will be fine for the purposes of this POC

In order to register a new domain name we’ll use one of domain registrars, in my case I already have Blogger web page open so I used Google domain registrar: https://domains.google.com to register alexwmdp.com domain that I’m going to use for WMDP

Domain


Please note that domain registrars will charge you a periodic fee for keeping your domain name after registration (fee amount may vary depending on domain registrar). Once domain name has been picked we can set up DNS records for subdomains. In particular, I wanted to use https://demo.alexwmdp.com to access WMDP. That’s why I’ll introduce appropriate A and CNAME DNS records to map to the VM where WMDP is installed. Please find detailed information about how to register A and CNAME DNS records for custom domain names for Microsoft Azure Cloud Services here: https://azure.microsoft.com/en-us/documentation/articles/cloud-services-custom-domain-name/

This is how resulting DNS records will look like

Domain - DNS


This is good, in fact for even greater convenience you can keep your DNS records configurations in one place with New Microsoft Dynamics AX environment – specifically, in Microsoft Azure Portal. In order to do that we can leverage DNS Zones functionality in Microsoft Azure. Please find more info about DNS Zones here: https://azure.microsoft.com/en-us/documentation/articles/dns-getstarted-create-dnszone/

And we’ll surely do so! On Microsoft Azure Portal we’ll create DNS Zone for alexwmdp.com

DNS Zone


And then introduce appropriate A and CNAME records for alexwmdp.com domain as shown below

Record set properties (A)


Record set properties (CNAME)


Once set up the result will be the same. To make sure everything works great in addition to DNS record for demo.alexwmdp.com I actually created DNS record for handheld.alexwmdp.com in DNS zones via Microsoft Azure portal. Both URL’s would point to one place now: https://demo.alexaniwmdp.com/ , https://handheld.alexaniwmdp.com/ 

Cmd – ping


Now we can verify the result by navigating to https://demo.alexwmdp.com

Microsoft Dynamics AX Warehouse Mobile Devices Portal  


Then we’ll select ”Log on to the mobile device” and select the company

Selection of company


Finally, when company is selected we can sign in to AX

Sign in to AX (USMF)


Please note that you can now access WMDP from outside of the VM in a web browser via Internet.

Please also note that because I reused originally installed SSL certificate we will get Certificate warning when opening this URL which you can bypass and proceed with URL. To get rid of Certificate warning we can create a dedicated SSL Certificate registered for the custom domain name we introduced 

At this point we can also conveniently access WMDP from the telephone using web browser. For example, this is how WMDP looks like on my Windows Phone

Phone  - Microsoft Dynamics AX Warehouse Mobile Devices Portal


Phone – Select company


Phone – Sign in to AX


This is all great! But if for the purposes of your POC, demonstration or workshop you prefer to use WMDP simulator inside of New Microsoft Dynamics AX instead of full-fledged deployed WMDP, it is also a possibility. Let’s see how it works

Step 3: AX Simulation (Dynamics AX 2012 R3 and New Dynamics AX)

We are all familiar with WMDP simulator in Microsoft Dynamics AX 2012 R3
The simulation mode was accessible via WHSWorkExecute form and WHSWorkExecute action menu item

WHSWorkExecute menu item

 

WHSWorkExecute form


When launched you could use a native Microsoft Dynamics AX 2012 R3 form to simulate WMDP

Login


Menu


You could also add WHSWorkExecute menu item to the menu structure and keep it always available in your environment. For example, adding “Work process” menu item to Global tools menu

GlobalToolsMenu


Work process


At this point in New Microsoft Dynamics AX Work process menu item is not exposed by default

Find “Work process”


In fact, you can make it available the same way it was done in Microsoft Dynamics AX 2012 R3
At this point I would like to add “Work process” to expose WMDP simulator in Warehouse management menu. Let’s create a quick model for this purpose

Model


Then we’ll associate a new project to the model

New project


But before modifying Warehouse management menu we’ll find the way to launch Work process form in a web browser. The beautiful thing about New Microsoft Dynamics AX is that web pages are URL addressable which means that once authenticated we can launch required web pages by typing in URL in a web browser

Let’s quickly add WHSWorkExecute form to the project, make it a default Startup object and launch a web browser (by Starting the project) to find out about URL we need to use

Project 



WMDP simulator inside of New Microsoft Dynamics AX


When we strip out unnecessary parts of the URL we’ll get the following URL that we can use to launch WMDP simulator inside of New Microsoft Dynamics AX: https://alexaos.cloudax.dynamics.com/?f=WHSWorkExecute&prt=initial&cmp=USMF 
Please note how forms are addressed via “f” GET URL parameter and display menu items can be similarly addressed via “mi” GET URL parameter 

WMDP simulator inside of New Microsoft Dynamics AX – Login


WMDP simulator inside of New Microsoft Dynamics AX – Menu


Now coming back to menu modification we can add an extension for Warehouse management menu and expose “Work process” menu item via menu

Project


After we did a necessary modification in Visual Studio we can build the model to see the results reflected in New Microsoft Dynamics AX

Build model


And here’s the result

Warehouse management menu


Summary: In this article we discussed how to configure Warehouse Mobile Device Portal in New Microsoft Dynamics AX and quickly make it available on mobile devices for the purposes of POC (Proof of Concept), demonstration or workshop using Demo environment. Please note that this information may also help you better understand the process of configuring Warehouse Mobile Device Portal for Production purposes according to the official guidance described here: https://ax.help.dynamics.com/en/wiki/warehouse-mobile-devices-portal-for-microsoft-dynamics-ax/.

Tags: New Microsoft Dynamics AX, Warehouse Management, Warehouse Mobile Devices Portal, WMDP, IIS, WHSWorkExecute.

Note: This document is intended for information purposes only, presented as is with no warranties from the author. This document may be updated with more content to better outline the issues and describe the solutions.

1 comment: