The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm="some_name"’.

Today I spent quite some time struggling how to figure out was wrong with my client implementation of an AIF webservice. I kept getting the error “The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Basic realm="some_domain_name"’.”

It was the realm part I didn’t understand. I had configured the service in AX to use basic authentication. From a reference environment, I knew the configuration had been working.

It turned out that my focus on the realm part was wrong because the reason to the error was invalid login credentials. How invalid login credentials can trigger the above error message is not for me to say. I would have expected a message like “Failed to log in to Microsoft Dynamics AX” instead. Just thought I would share my experience…

Troubleshooting Enterprise Portal error messages

If you have been working with enterprise portal development, you will probably have gone through the same levels of frustration as I because error messages are not good in adding usable information into these messages. Over time I have collected some sites with suggestions on how to troubleshoot these more or less cryptric messages.

Error: Enterprise Portal Web Parts show "Unable to render content" error

Error: Unable to render content due to an error. Please contact your system administrator.

Generel troubleshooting:

AIF – getting offline WSDL files

Quite often when dealing with AIF service I am asked to send a WSDL for a service to a 3rd party partner. Typically the partner dowsn’t have access to the service in that phase of the project. This means that I would have to send physical wsdl files (and not just an URL). In my experience the “singleWSDL” feature introduced with .net framework 4.5 doesn’t work for AIF services. In these cases AIF can be quite thedius to work with because the wsdl references other wsdl files as well as xsd’s. So in order to being able to send an offline wsdl file to a partner, you have to do a little bit of manual work. Ofcourse there are many ways to achieve the same, but here’s a guide of way, that I have found quite easy to work with.

  • Make sure the service has been published.
  • Open visual studio and create a console application. Add a new service reference pointing to the your service. Visuial studio now creates proxy classes as well as downloads referenced wsdl’s and xsd’s. You should see something similar to this in your project:
    Please note the 3 WSDL files and 6 XSD files.
  • Locate the physical location of the files (right click in VS and look at the file properties)
  • Copy all of the WSDL and XSD to a new folder of your choice (outside the project). This folder now contains the files that we want to send to our partner. But before sending them, we need to do some minor modifications.
  • Open the RoutingService.wsdl in your editor (VS will do just fine). Find and edit all import statements:
    You will se that the Locations attribute references a http address. Edit the location to point to the local file residing in the current folder.
    You will want to do the same for the service location:
    Make sure to point to the local file instead of the url.
  • Do the same for the other 2 WSDL files. It’s quickly done.
  • When finished You can test your work by going back into visual studio. Just simulate adding a new service reference pointing to the local wsdl files instead. Remember it is the RoutingService.wsdl that is Your point of entry. If VS doesn’t complain You are now finished.
  • Finally zip the folder and sent it to the partner.

If You know of a better/easier way please post a comment…

How to implement basic authentication in Dynamics AX2012 webservice

Recently I had to configure an inbound port for basic authentication. Furthermore I had to produce a guide in order to being able to set it up in the same way in other environments.

Lucky for me, I found this great guide, that I would like to share. You can also use it as a template for configuring other types of authentication.

AX2012 CIL debugging

AS You know there are a lot of guides out there on how to debug CIL. However when problems occur I find that quite a lot are missing some important things. So here’s my shot at a guide on how to debug CIL code.

In AX2012 some code is run in CIL (Common Intermediate Language). In general it means that our x++ code is compiled into .net. For instance batchjobs and other serverside code is run in CIL (unless configured otherwise).
If You want to read more regarding the background please visit this link – X++ compiled to .NET CIL.

Sometimes a mismatch can occur between the x++ code and the CIL code, and in these cases, it is nice being able to debug. I will try to list some important things that You may want to concider/check.

  • You will have to use at least VS 2010
  • I would recommend doing a local debug session – meaning your visual studio should be installed directly on the AOS. You can setup remote debugging but that just opens for a whole lot of new problems. Keep it simple – keep it on the AOS.
  • If possible You will prefer to have exclusive access – meaning no other users should be logged on. When debugging serverside code, you will hit every breakpoint triggered accross users. This means if you are debugging in an area where a lot of users are working, you will have to struggle with breakpoints being hit in a way you can’t possible imagine.

In order to configure your environment for CIL debugging You need to do this:

  1. Install VS2010/VS2012/VS2013 depending on your ax version on the AOS
  2. Run the Microsoft Dynamics AX Setup and choose to install the Visual Studio Tools.
  3. Generate/locate the sources
    When CIL compillation is performed it outputs .xpp files in C:\Program Files\Microsoft Dynamics AX\60\Server\<AOS_INSTANCE_FOLDER>\bin\XppIL and source files for Visual studio here C:\Program Files\Microsoft Dynamics AX\60\Server\<AOS_INSTANCE_FOLDER>\bin\XppIL\Source
    On some occations I have experienced the the source folder does not exist. In these cases stop the AOS service, delete all contents of the XppIl folder, restart the AOS (Maybe You need to perform a full CIL before). If you are not doing local debugging, You will need to setup a share for this folder.
  4. Configure the AOS for debugging. Go to the Dynamics AX Server configuration tool and be sure that the following checkmarks are set
  5. Launch visual studio in admin mode. Be aware that when VS connects to AX it uses the configuration from the client configuration tool. Make sure that you have set up the configuration you need – connecting to the correct layer etc (not important if you are just debugging).
    Launch the Dynamics AX Application Explorer to browse the AOT and set the breakpoints of your choice. When You double clikc a method a new solution is automatically created in solution explorer.
  6. Right click the newly created solution and select “properties”.
    Select “debug source files”.
    Add the path for the source files (local path or remote share)
  7. Now You are ready to attach Visual Studio to the AX32Serv process. Click the “Debug” menu item and select “attach to process”. Locate the AX32Serv process and attach to it. If VS is not in admin mode VS will now ask you to restart in elevated mode.
  8. Go back into AX and do the things you need in order to hit the breaktpoint.
  9. If You are not hitting any breakpoint you need to check, that you are set up to run code in CIL. Inside AX open a development environment. Go to Tools –> Options –> Development
    Make sure that the checkbox “Execute business operations in CIL” is checked.

Deadlocks show up in AIF exception log when CRM synchronizes multiple companies.

Recently I was working on a case where some issues occured when trying to synhronize data between MS dynamics ax 2012 and MS CRM.

Scenario description:

In MS CRM the following maps have been set up for synchronization in two integrations.


Each integration uses its own AX user for connection.

From the CRM point of view, the synchronization seems to succeed. However going through the exception log in AX it seems that quite a few deadlocks have occurred, please see screendump below:


And here’s a screendump from the “general” tab showing the error message – “Cannot select a record in Change Tracking Version (AifSqlCtVersion). Change Tracking Version: 0.
Deadlock, where one or more users have simultaneously locked the whole table or part of it.


The deadlocks seems to have disappeared by themselves.
From this blog post this issue seems to be a known issue – – however the ax database had not recently been updated.


The cause:

The cause seems to be the SQL optimiser doing a clustered index scan (RecId) in the query below, resulting in blocking:



The solution:

  • Login to Dynamics AX –> Open a Development workspace, and navigate to AOT –> Dictionary -> tables,
    Find the table AIFSQLCTVERSION , and create a new non-unique index for CTVERSION field
  • Login to SQL server Management studio, and create a new plan guide for the query adding index hint
    GO(replace the index name I_100021KOO_CTVERSIONIDX with the actual name of the newly created index)


Microsoft CRM: Synchronizing with multiple AX companies results in continuously opening new active AOS-connections

Recently I was presented with a very interesting problem that occured when Microsoft CRM was synchronizing with Microsoft Dynamics AX 2012 using the DynamicsConnector for MS Dynamics AX. The installation guide can be found here.

In basics it was a standard setup in both ends. When syncing only one company everything would work just fine, but when syncing two or more companies the online users would be filled with active connections that wouldn’t close by themselves. In the end this would lead to the AOS not accepting new clients or even a crash due to lack of RAM.

The strange thing was that everything was setup according to the guidelines and was working fine in a reference environment. A MS support request was created and I will try to summarize all of our findings and the solution that fixed the problem.

The problem in short:

  • When running the synch of 2 or more companies simultaneously, the client session on AX continues to increase till the crash of AOS.
  • Running synch of 1 company only (in other words 1 integration) the client sessions do not increase; looks like they are recycled.
  • The problem occurs in all maps and seems to be a general problem in our scenario.
  • The synchronization for all companies is running on the same AX account.

The solution:

  • The verified solution from MS was to create separate accounts for each synchronization.