Creating custom services
In this section, we will discuss two custom services. One service focuses on exposing data from Microsoft Dynamics AX 2012, the other 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. The service will allow an external program to do the following two things:
Retrieve details of a title based on its ID
Retrieve a list of all titles
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:
[DataContractAttribute('Title')] public class CVRTitleDataContract { CVRTitleId id; CVRTitleName name; Description description; }
Next, add three parameter methods...