If you have ever used the General Ledger AIF service of the Microsoft Dynamics AX 2009, you might have noticed the limitation of not integrating other than Ledger transactions. For example, you cannot send Customer and Vendor transactions through that AIF Service.
I came across a requirement where I needed to integrate external Vendor and Bank transactions through AIF. After spending sometime on testing as well as on X++ code tracing… I came to know that Microsoft is putting some restrictions on the code to not to accept the Ledger Journal transactions of types other than Ledger.
The following code is a standard X++ code that was written to prevent such integration.
37 38 39 40 41 42 43 44 45 46 47 48 49 | //LedgerJournalTableType (class) -- initializeLedgerJournalName (method) -- Line number 37 /*Commented to disable the Non-Ledger type restriction*/ if (!true /*this.isJournalNameValidJournalType()*/) /*Commented to disable the Non-Ledger type restriction*/ { AifFaultContext::setGlobalContextField(tableId, fieldId); AifFault::checkFailedLogFault(strfmt("@SYS114718", axLedgerJournalTable.parmJournalName(), axLedgerJournalTable.parmJournalType()), #InvalidJournalNameJournalTypeCombination); throw AifFault::faultList("@SYS98197", #ValidationFailed); } /*Initilizing the journal type from the journal name*/ ledgerJournalTable.JournalType = ledgerJournalName.JournalType; /**/ } |
Also I have changed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //Amer Atiyah, http://www.amerax.net/ //LedgerJournalTransType (class) -- validateAccountType (method) -- Line Number 1 protected boolean validateAccountType() { boolean isValid = true; ; switch (ledgerJournalTable.JournalType) { case LedgerJournalType::Daily : /* I had to comment this code to prevent the validation if (ledgerJournalTrans.AccountType != LedgerJournalACType::Ledger) { if (this.isConsumerStateTracked()) { // AX5 service limitation isValid = AifFault::checkFailedLogFault("@SYS117885", #AccountTypeMustBeLedger); } }*/ break; default : break; } return isValid; } |
What I like to mention in here is that Microsoft Dynamics AX 2012 now supports integrating Vendor, Customer, and Bank transactions out-of-the-box. I copied the following code from the LedgerJournalTransType class in Dynamics AX 2012 without doing any changes to it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | protected boolean validateAccountType() { boolean isValid = true; this.initializeLedgerJournalTable(); switch (ledgerJournalTable.JournalType) { case LedgerJournalType::Daily : if(LedgerJournalTrans.AccountType != LedgerJournalACType::Ledger && LedgerJournalTrans.AccountType != LedgerJournalACType::Bank && LedgerJournalTrans.AccountType != LedgerJournalACType::Vend && LedgerJournalTrans.AccountType != LedgerJournalACType::Cust) { if(this.isConsumerStateTracked()) { isValid = AifFault::checkFailedLogFault("@SYS117885", #AccountTypeIsNoSupported); } } break; default; break; } return isValid; } |
I had a case where I tried to call a Dynamics AX 2009 AIF Web service from an XML Web Service (.asmx). But the new thing in this case is that the AIF Web Service call is actually inside a dll referenced in this new asmx web service.
When you reference that dll into a web service/asp.net project in the Visual Studio .NET, and then call the function inside that dll which calls the Dynamics AX AIF Web Service… you will have the following error:
System.InvalidOperationException: Could not find default endpoint element that references contract 'AXGLServiceRef.GeneralJournalService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory() at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase`1..ctor() at AXWCFClassLibrary.AXGLServiceRef.GeneralJournalServiceClient..ctor() at AXWCFClassLibrary.Class1.checkme() at Service.HelloWorld(String name, String accval) in d:WebSite1App_CodeService.cs:line 21 |
This error is actually due to that the end point that this dll is trying to reach is unidentified to this web application. What you have to do is:
- Go to the class library project where you created that dll
- Go to app.config
- Copy the whole ServiceModel part
- Go to the web.config in your new web application
- Paste the ServiceModel part inside the Configuration part
By this, you will be able to execute without getting that endpoint error
If you ever called the AIF Sales Order Service in Dynamics AX 2009, then you had to specify the Customer Requisition (PurchOrderFormNum) field in SalesTable although this field is not really mandatory.
The Sales Order web service assumes that it is called from trading partners applications. Thus, whenever a sales order is created, this means that it has been created based on a request (Purchase Requisition most of the time) by this trading partner to your organization. And this requisition should be recorded in the PurchOrderFormNum field.
But why does the AIF Web Service create Journal type sales order then? The AxdSalesOrder class (the AX Document class) checks whether this sales order has been requested before by this customer (CustAccount field) or not. If it has been requested before, then this means that this customer (the one who sent this sales order document via the AIF Sales Order service) is purchasing based in the same Sales Order.. so Dynamics AX does not need to create another sales order, it creates Journal type sales order instead for the same customer and the same Customer Repulsion.
A great detail of the Sales Order Document Service is found in this link: http://msdn.microsoft.com/en-us/library/cc967401.aspx.
You might face the same scenario that I’m facing with one of my customers currently, that is migrating sales orders from an internal legacy system where you want only to migrate sales orders without checking for a Customer Requisition. If this is what you’re looking for, then all what you have to do is to comment the code in AxdSalesOrder class and prepareSalesTable method:
select firstonly localSalesTable where localSalesTable.CustAccount == _axSalesTable.parmCustAccount() && localSalesTable.PurchOrderFormNum == _axSalesTable.parmPurchOrderFormNum() && localSalesTable.SalesId != _axSalesTable.parmSalesId(); /*COMMENT FROM HERE if (localSalesTable) { _axSalesTable.parmSalesType(SalesType::Journal); }COMMENT TO HERE*/ |
When you call the out-of-the-box AIF Sales Order Web Service, you might face a very strange and non-understandable error message saying:
The request failed with the following error: The element ‘SalesTable’ in namespace’http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder’ has invalid child element ‘QuotationId’ in namespace’http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder’.
If you faced this, and looked for a solution you might have gone to Dianne Siebold’s WebLog:http://blogs.msdn.com/dsiebold/archive/2010/01/21/request-failed-error-in-aif.aspx. Honestly, in the beginning I did not get what she said. Then when I got what she is trying to say, I did not like it :D, with all my respect to her of course.
Now when you dig in the XSD generated from the Sales Order Service, you would notice that the field Customer requisition (PurchOrderFormNum) is mandatory… you have to include it in your message. This is what this “unclear” message is all about.
But the question that might cross to your mind is why I should include such field in my Sales Order although I can create new sales order in the Dynamics AX Sales Order Details form with filling this field.
This is what I will explain in my next post :).
When I installed Dynamics AX AIF to a new server with these specs:
- Windows 2008
- IIS 7
- .Net Business Connector
After installing those compoents + AIF Webservices (from the Dynamics AX 2009 media), you will not be able to view the .svc files in the IIS.
In order to vew the *.svc files and get the link in WSDL, you have to use the Service Model Registration toll in the .NET framework folder in windows. Follow these steps in order to have it viewed:
- Go to: Start> All programs> Microsoft Visual Studion 2008 (or 2005)> Visual Studio Tools> Visual Studio Command Prompt
- Write: cd <<<Windows installation path>>>windowsMicrosoft.NETFrameworkv3.0Windows Communication Foundation
- Write: ServiceModelReg.exe -i -x
If this completed successfully, you now are able to view/browse the svc (WCF services) in IIS 7.
Cool session. It was all about showing muscles of Dynamics AX of how this enterprise software could manage the integration with external systems.
It was all about AIF, .NET business connector and CLR Interoperability.
For each of them I gave a simple application, like the following:
· For AIF, I created a service using the Document Service Wizard. Then we extending it by adding a new operation. Then we published it on the local IIS. After this we were able to create a very simple console application to get data from Dynamics AX through the created web service.
· For .NET Business connector, I created I windows application from Visual Studio .NET to call using the .NET business connector a static method that is written in X++.
· For the CLR Interoperability, we called System.IO .NET library from within the X++. And then we a simple library in Visual Studio .NET, referenced it in Dynamics AX and then called it from within an AOT Job and X++.
Search the site
Dynamics AX 2012 Event
Recent Posts
- D365FO | Cannot Connect to SQL Server Database on Your Cloud Test Machines
- Intro to Microsoft Dynamics AX in Arabic – سلسلة حلقات مايكروسوفت داينامكس إيه إكس بالعربية
- Microsoft Dynamics Launch – Sunday, 24th February – Intercontinental Hotel, Riyadh
- Files of Our AX Brains Dec 2012 Event
- It was a great day!
- Tomorrow is the day for our Dynamics AX Brains Technical Seminar
- Dynamics AX Brains December 2012 Technical Seminar
- Windows Server 2012: Built from the Cloud Up
Tags
Archives
- October 2019 (1)
- January 2014 (1)
- February 2013 (1)
- December 2012 (4)
- September 2012 (2)
- December 2011 (2)
- November 2011 (3)
- July 2011 (3)
- June 2011 (4)
- May 2011 (3)
- April 2011 (4)
- March 2011 (12)
- February 2011 (2)
- January 2011 (3)
- December 2010 (1)
- November 2010 (1)
- October 2010 (5)
- August 2010 (1)
- July 2010 (3)
- June 2010 (4)
- May 2010 (5)
- April 2010 (1)
- March 2010 (9)
- February 2010 (4)
- January 2010 (4)
- December 2009 (11)
- September 2009 (1)
- August 2009 (1)
- July 2009 (2)
- September 2008 (1)
Random Testimonial
- ~ Mohamed Wajd Haikal, Software Team Leader at IDIS
"Amer is one of my best friends, he always tries to be the best by focusing on gaining new certifications and to have wide relationships"
- Read more testimonials »