This is a knowledgeshare for those of you that need to programmatically change the AIF endpoint address at runtime. The primary reason you may want to do this is if your .Net solution needs to target several different AOS’s (all running the same AIF service).
The example below uses a VSTO solution, but the principle can be applied to any .Net solution.
Setup two runtime configurable settings:
· WebServiceURI - web service uri for example net.tcp://AOSSERVER:8101/DynamicsAx/Services/LNPS_DynamicScriptServiceGroup
· UpnIdentity – The user the AOS service account runs under aosservice@domain.virtual
NOTE: There is a known limitation in AIF which means that you have to use the AOS service account as the UPN identity.
Next adjust your AIF client definition as follows:
// Aif Service Client EndpointIdentity spn = EndpointIdentity.CreateUpnIdentity((string)UpnIdentity.Value2); Uri uri = newUri((string)WebServiceUri.Value2); var address = newEndpointAddress(uri, spn); LNPS_DynamicScriptClassClient client = newLNPS_DynamicScriptClassClient("NetTcpBinding_LNPS_DynamicScriptClass", address); // Create an instance of the CallContext class. CallContext context = newCallContext(); // Set context company and language context.Company = (string)Company.Value; context.Language = "en-gb"; |
In my case, I set these as named-ranges on the Excel workbook and set the sheet as hidden and password protected, so that only technical staff could amend during deployment.
Courtesy Chris Lowe (TA LexisNexis)