Article Source: http://geekswithblogs.net/charliemott
This article describes our approach to testing BizTalk integration with Dynamics AX 2009. It builds on the "Alternative Bindings" approach as described by Mike Stephenson.
We are communicating asynchronous with Dynamics. As such, in our developer / unit test bindings, we have replaced use of the AIF Adapter with the MSMQ Adapter. If you are communicating synchronously, you could use the WCF Adapter.
Mimic the Dynamics AIF Adapter
We also need to mimic the actions of the AIF Adapter. To do this, we have used 2 test pipelines and a test schema in our developer bindings:
- We created a test implementation of the AX envelope schema (AxEnvelope.xsd). This has the same namespace and structure as the actual AX schema. The difference is that our test schema has all the Header fields as promoted properties.
- On the send side, our send ports use our MimicDynammicsAifAdapterSend pipeline. This has an XML Assembler component. This wraps the outbound messages in the AxEnvelope envelope. With property demotion, the header fields are set from the context properties (as set in our orchestrations). This enables us to test these values in our BizUnit validation steps.
- On the receive side, our MimicDynamicsAifAdapterReceive pipeline has an XML Disassembler that strips off the envelope. The header fields are prompted to the message context properties. In particular, the MessageId envelope header field is required to be added to the message context so the response messages can be correlated to the message sent to Dynamics. The dissassember references the schemas: DynamicsAx5.Fault, DynamicsAx5.EntityKeyList, DynamicsAx5.EntityKey and all other message types we are expecting from Dynamics.
In order to mimic Dynamics sending a response to messages we send to Dynamics, we also built a custom BizUnit test step (AxSendResponseStep).
The response message can be a valid response (DynamicsAx5.EntityKeyList) or an invalid response (DynamicsAx5.Fault) as specified in the step parameters. In the Dynamics response message, the MessageId is replaced with the same MessageId in the received message. This ensures the Dynamics response messages can be correlated by BizTalk orchestrations.
Update: 03/04/2011 - This approach only applies to integration with AX4 and AX5. These versions provide the AIF Adapter. In AX6 (AX2012), services are exposed as WCF services. As such, regular approaches to stubbing out WCF services can be used.