Book Image

Microsoft Dynamics AX 2012 R2 Services

Book Image

Microsoft Dynamics AX 2012 R2 Services

Overview of this book

Table of Contents (17 chapters)
Microsoft Dynamics AX 2012 R2 Services
About the Authors
About the Reviewers

Creating custom services

In this section, we will discuss two custom services. One service focuses on exposing data from Microsoft Dynamics AX 2012 while the other focuses on exposing business logic.

The Title service

We will use the CVRTitleService service as an example to demonstrate how to create a simple yet powerful service. This service will allow an external program to do the following two things:

  • Retrieve the details of a title based on its ID

  • Retrieve a list of all titles

Creating the Title data contract

Let's start by creating a new class for the data contract that will contain the data for one title. Create a new class and name it CVRTitleContract. In the class declaration, add DataContractAttribute to specify that the class is a data contract. Also, declare the variable's ID, name, and description, as shown in the following code snippet:

public class CVRTitleDataContract
    CVRTitleId      id;
    CVRTitleName    name;
    Description     description...