Search This Blog

Thursday 20 December 2012

AIF Framework in Microsoft Dynamics AX 2012 Part 1

Following the features of Application Integration Frameworl in Microsoft Dynamics AX 2012.

. Enables companies to integrate and communicate with external business processes and partners.
 
. Exchange of data through formatted XML
 
. Formatted XML is referred to as a document
 
. Service can be hosted on
 
    . AOS
 
    . IIS
 

AIF Service Types:

 
There are following three types of  Services:
 

1. Document Services:

 
Query-based services that can be used to exchange data with external systems by sending and receiving XML documents
 

2. Custom Services:

 
Can be used by developers to expose any X++ logic such as X++ classes and their members, through a service interface.
 
 Example of Custom Services is Business Operation Framework.
 

3. System Services:

 
Provided by Microsoft Dynamics AX .System services include the query service,the metadata service, and the user session service.System services are not customizable ,and they are not mapped to any query or X++ code. 
 
 In this session i will explain only Document Services.
 

Document Services:

. The XML Document Framework contains these types of classes:
 
     . Axd<Document> classes (also known as an Axd class)
 
          . containg the business logic for related entities.
 
. Ax<Table> classes
 
    . abstraction of a table and encapsulate the business logic associated with creation and modification of records in the database table.
 

AXD Document Classes:

 
These are the main methods called when data is created or updated.
1.prepareForSaveExtended.
 
  .Called when records are created.
 
2.prepareForUpdateExtended.
 
 .Called when records are updated.

Docuement Service Operations:

.create
This item creates a record for a new item in the database.
 
.delete
 
This operation deletes a record in the database.
 
.find
 
This opearation searches for the specified database record.
 
.findkeys
 
This operation retrieves a list of entity keys that correspond to the specified search criteria
 
.read
 
This operation retrieves the specified record from the database.
 
.Update
 
This operation updates the record in the databaseOnly the fields that are contained in the message are updated.Values for all other database fields remain unchanged.
 

Implementation:

Now I will show you the implementation of the Application Integration Framework.
 
Note:In this session I am showing only the example of the Document Service of AIF.
 
Step 1:
 
First of all i have created the Project in which i have create two tables and then make relations between them.In the first table I  have created the employee table which contains the fields i.e emp date of birth,emp name,emp number and than I have created the employee department table in which i have created the fields employee department and employee experience.Employee is the parent table and employee department is the child table.Than made the Query to fetch the data from these tables.Note that i have created the outer join in the query to fetch all the records and than set the property update =  true because we will also update the record in this example.
 
you can see tables of my project in the below image:
 
 
 
 
 
 



















And in the below image you can see the Query that I have created you can also see its properties.

























Step 2:

Now we will go and create our document service .

just go to the tools->application integration framework->create document service

as you can see in the below image:
















 

 A new wizard will open.Now click the next button

A new screen will come and than select your query that you have created in early step.

You can see the below image.

 
Now click the next button.A new wizard will come here you can see the axd classes names that are generated and then select operations that you want to perform through this service. and then click on the checkboxes under axbc generation.These are the proxy classes need by the Application Integration Framework.

You can see the screen in the image below:





















Now click the next button. A new wizard will open and than click the generate button.This will create the new project which contains all the proxy classes that will be use by the service consumer.As you can see in the image below:

























Now we need to register that service as valid AX service.Just right click the service file that I have highlighted in the above project and than go to adds-in and than click the register service.It will take some time to register.

Now our service is ready but not yes accessible from the outside world we need to create the inbound ports.

just go to the System Administration -> Inbound ports.

A new screen will open as you can see in the below image:
















New click on the new button as you can see in the above image to create new inbound port.
And than enter the name of the port as i have highlighted in the above image and than check the
check box include exceptions in fault.Checking this checkbox is not necessary but its for development point of view that if during the insertion of data if some exceptions occur than we can easily see that.

Now click the Service operations button as you can see in the above image.After clicking this button a new wizard will open as you can see in the below image.

 
 

Now select the service operations that we have created in the project.These service operations will be consumed by this port.

After selecting the service operations close this wizard and then click the activate button as you can see the second last image in the above.

Now your service will be activate and is able to consume by the consumer code.After the activation of the service you will get the WSDL URI that will be use in the consumer code to refrence this service. As you can see the image below the generated WSDL URI.
















Now  the process of how to consume this service I will show this in the next part 2.
I hope this session will help you on how to configure AIF service.

Thanks

Muhammad Zahid.

 
 

No comments:

Post a Comment