Browsing all articles tagged with AIF Archives - Amer Atiyah, Microsoft Dynamics 365 Blog
2

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;
}
2

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:

  1. Go to the class library project where you created that dll
  2. Go to app.config
  3. Copy the whole ServiceModel part
  4. Go to the web.config in your new web application
  5. Paste the ServiceModel part inside the Configuration part

By this, you will be able to execute without getting that endpoint error

1

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*/
0

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 :).

0

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:

  1. Go to: Start> All programs> Microsoft Visual Studion 2008 (or 2005)> Visual Studio Tools> Visual Studio Command Prompt
  2. Write: cd <<<Windows installation path>>>windowsMicrosoft.NETFrameworkv3.0Windows Communication Foundation
  3. Write: ServiceModelReg.exe -i -x

If this completed successfully, you now are able to view/browse the svc (WCF services) in IIS 7.

4

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++.

Download the presentation from here.

Dynamics AX 2012 Event

Recent Posts

Tags

Archives

Random Testimonial

  • ~ Shibu Purushothaman, Sr. Programmer at WorleyParsons

    0bd63bf"Working with Amer was a pleasure. He is a true professional with in depth knowledge of Dynamics AX, .Net and other Microsoft Technologies. His professional approach to design, implementation and training made our migration to Axapta easy, and with very little down time. Another quality that I think deserves a special mention is that working with him is a pleasure, not even once did we feel uncomfortable with Axapta even though we were from a .net platform. He took time to attend to our doubts, and made the transition from .net to Axapta a very smooth ride. I highly recommend Amer and cant wait to work with him again."

  • Read more testimonials »