How to refresh AX WSDL configuration from a command prompt
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ6bRxMwp64bq7Xsujv47cLeZncCmrKRss0qEUOHc3ZBApwIGUy3Sxw_be5u6liJy8qSubYMW-wE0eVCt3sOEY-Hozxyo7opp0r147Pb8E8h8vcuM020UnwexjLYYCfkz1a15-5iuwjToN/s400/2-2-2015+3-46-32+PM.png)
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
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
Post a Comment