Services AX2012
Services AX2012
Services in Microsoft
Dynamics AX 2012
White Paper
http://microsoft.com/dynamics/ax
Audience ..................................................................................................... 3
Prerequisites ............................................................................................... 3
Purpose....................................................................................................... 3
Conclusion .................................................................................................. 7
Audience
This white paper targets developers and architects who are planning to use services in Microsoft
Dynamics AX 2012.
Prerequisites
To benefit from this white paper, you must understand the following areas:
Programming models in Microsoft Dynamics AX 2012. For more information, see the white
paper “Selecting the Best Development Technology for your Application Development
Scenario_AX2012”, which is also on the Microsoft Connect site.
Basics of Microsoft Dynamics AX 2012 Services and Application Integration Framework.
Purpose
The purpose of this white paper is to provide an overview of services available in Microsoft Dynamics
AX 2012 and to provide guidance about the types of services that are best suited for a given scenario.
Document services
Introduced in Microsoft Dynamics AX 4.0, documents represent business objects, such as customers,
vendors, and sales orders. Document services enable you to exchange data with external systems by
sending and receiving XML documents. The following figure shows the internal details of a document
service.
The DocumentService class exposes the operations of the service. The DocumentService class
calls the functionality in Axd <Document> classes that contain any customizations to the business
logic for modeled entities. For example, the AxdCustomer class contains the customization logic to
create, update, or delete a customer entity. Axd <Document> classes can use Ax<Table> classes
to create, update, or delete document tables, or optionally to apply customizations during read
operations.
Document services are generated from a query that models the business entity. For example, a
customer query will run the Document Service Generation Wizard to create the service artifacts.
Document services include logic to handle the details of how a query will be serialized or de-serialized
from XML that is sent across a network. For example, the document services framework can serialize
and de-serialize dimension attributes and perform natural key substitution. The framework deals with
the polymorphic nature of queries, the date effective fields, and so on. All the data-layer
improvements have been handled in the framework. The creator of a document service only has to
make sure that the business entity is properly mapped to the query object.
All artifacts produced in a document service are customizable so that a developer can further fine-tune
the functionality based on the requirements.
Synchronization APIs
Two new APIs have been introduced in the document services framework to enable the
synchronization of entities between Microsoft Dynamics AX 2012 and external systems. These APIs are
not present in the preinstalled document services or in the Document Service Generation Wizard.
Developers must extend this base support to enable their own scenarios.
getKeys method: Similar to the existing findKeys method, but applies the document filters
that have been configured for the service and port. Filters provide a mechanism for restricting
the overall set of documents that will be returned by a document service. For example, a filter
on a customer document on the Name field would return only those customers whose name
matches the filter.
getChangedKeys method: Extends the getKeys method by adding a parameter that
contains a date and time. The values returned are the ones that changed in the root data
source or any child data source of the document after the specified date and time.
Custom services
Custom services in Microsoft Dynamics AX 2012 allow developers to expose any X++ logic through a
service interface. Custom services were supported in Microsoft Dynamics AX 2009, but the framework
support for some data types was limited. For any complex type, developers were required to write
custom serialization and de-serialization logic.
System services
System services are a new category of services that have been added in Microsoft Dynamics AX 2012.
These services are not customizable and are not mapped to any query or X++ code. These services
are written in managed code and hosted on the AOS at a fixed address specified in the server
configuration file.
Query Service
Query Service exposes APIs to execute any Application Object Tree (AOT)–defined or ad hoc client-
defined query against the system. It can also execute a dynamically generated query by using X++.
The results are returned as an ADO.NET DataSet object. This feature is especially useful in creating
Microsoft .NET Framework applications that use controls that can be bound to the returned result.
The URL for Query Service is as follows
net.tcp://<hostname:port>/DynamicsAX/Services/QueryService
where hostname and port are on the computer running the AOS.
The caller of Query Service needs to have appropriate permissions to retrieve all the requested
information. If certain fields in the requested set are not permitted, they are trimmed. If any data
source in the join list is not permitted, the service call fails with an error.
Metadata Service
Metadata Service enables clients to get information about some key metadata in the AOT. Clients can
get information about which queries or services exist in the AOT and various details about each
instance. This feature is useful in scenarios in which some metadata details need to be checked or
published by an application. Another important scenario is retrieving labels for different locales for
building and displaying custom user interfaces.
The URL for Metadata Service is as follows
net.tcp://<hostname:port>/DynamicsAX/Services/MetadataService
where hostname and port are on the computer running the AOS.
User Session Service
User Session Service allows the caller to retrieve information about the calling user. This includes
details such as the user’s company, timezone offset, and locale.
The URL for User Session Service is as follows:
net.tcp://<hostname:port>/DynamicsAX/Services/UserSessionService
where hostname and port are on the computer running the AOS.
Service and data Auto-generated based on the Developer defined Fixed and cannot be updated
contracts query and wizard options
Transport protocol Any supported adapter Any supported adapter Only net.tcp
Usage Use to expose a business entity Use to expose any Use always on utility services
through a service interface. custom business logic for any caller.
Used in integration. All AIF (even a business entity)
framework artifacts can be through a service
applied on these services. interface.
AIF framework support
for transforms is present
but not for pipelines,
schema constraints, or
others.
Entity complexity The Document Service Generation Wizard Suitable when the entity complexity is
handles queries of any complexity and low. The schema can be written as a
size and generates the service data contract class and relevant data
seamlessly. member attributes set.
For example, some queries contain data If tables and relationships are used in a
sources and relationships that include data contract, then any feature around
dimensions, polymorphism, date-effective dimensions, polymorphism, and so on,
information, and so on. The document needs to be handled in code by the
framework handles these types of queries developer. This task may be time
seamlessly. consuming.
Integration All integration stack elements such as Schema constraints and value
requirements pipelines, transforms, and schema substitution are not honored for custom
constraints can be applied to document services.
services. However, transforms that convert
between the AifXMLMessage format and
other formats and pipelines for
preprocessing and postprocessing of
XML messages can be used.
Flexibility in Because a document service is derived The data contracts are written by
service contracts from a query, any change to the query developers and can be controlled to
object or its data source schema is likely make sure that the underlying schema
to change the service contract. changes do not have any effect on
This tight coupling between the service them.
contract and the underlying query-table The control that a developer has in
schema could be limiting for certain defining the service contracts can be
scenarios. good for service clients.
Microsoft Office Office add-in tools, shipped as a part of No preinstalled integration with Office
add-in support Microsoft Dynamics AX 2012, have built- add-ins exists.
in support for consuming document
services for updating data.
Conclusion
The following table summarizes some of the key scenarios for all the service types in Microsoft
Dynamics AX 2012.
Use for easily exposing business entities with varying complexity as a service.
Document services Use for supporting any medium to complex integration scenario involving entities.
Query Service Use for implementing read operations for any Microsoft Dynamics AX, ad-hoc, or
existing AOT query.
Metadata Service Use for retrieving certain key metadata information from Microsoft Dynamics AX.
User Session Service Use for retrieving any user session information.
This document is provided “as-is.” Information and views expressed in this document, including URL and other
Internet Web site references, may change without notice. You bear the risk of using it.
Some examples depicted herein are provided for illustration only and are fictitious. No real association or
connection is intended or should be inferred.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You
may copy and use this document for your internal, reference purposes. You may modify this document for your
internal, reference purposes.
Microsoft, the Microsoft Dynamics Logo, Microsoft Dynamics, Windows, and Excel are trademarks of the Microsoft
group of companies.