How to refresh AX WSDL configuration from a command prompt



My build/release process is almost entirely automated, except for one step, where we refresh the WSDL/WCF configuration.  So far, I've only been able to do it conventionally with the mouse.


I wrote a little command line tool in C# that you can incorporate into your build scripts that should refresh your WCF configuration in your AXC file automatically.


It has one dependency on the AX client configuration tool obviously, which is located at:
C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\AxCliCfg.exe




Usage: RefreshAXCConfig.exe <axc file> <aos name> <WSDL Port>
Example: RefreshAXCConfig.exe C:\CUS.axc DevAOS 8101

The C# code is simple below, and make sure to add the reference to AxCliCfg.exe. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Xml;
using Microsoft.Dynamics.Configuration;

namespace RefreshAXCConfig
{
 class Program
  {
  static void Main(string[] args)
   {
    Tuple<Guid, string> result;
    string axcFile;
    string strAOS;
    int intWSDLPort;
         
    if (args.Length == 0)
    {
    Console.WriteLine("Usage: RefreshAXCConfig.exe <axc file> <aos name> <WSDL Port>");
    Console.WriteLine("Example: RefreshAXCConfig.exe CUS.axc Dev-vwaos05 8101");
       return;
      }
      try
       {
         axcFile = args[0];
         strAOS = args[1];
         if (int.TryParse(args[2], out intWSDLPort) == true)
         {
          result = FormRegenerateWcfDialog.GetConfigurationAsString(strAOS, intWSDLPort);

          XmlDocument xmlDoc = new XmlDocument();
          xmlDoc.LoadXml(result.Item2);

         File.WriteAllText(axcFile, Regex.Replace(File.ReadAllText(axcFile),
                               @"<\?xml.*\</configuration\>", xmlDoc.InnerXml));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error encountered: {0}", e.Message);
            }

            return;
        }
    }
}





Comments

Popular posts from this blog

D365FO - Data integration by OData

Create or Update Product attributes using X++ in D365 F&O

Layers concept in D365