Professional Documents
Culture Documents
Welcome ........................................................................................................ .... 0-1 Microsoft Dynamics Courseware Contents ........................................................ 0-2 Documentation Conventions .............................................................................. 0-3 Student Objectives ............................................................................................. 0-4
1-1
Objectives........................................................................................................ ... 1-1 Introduction...................................................................................................... ... 1-1 Concepts ......................................................................................................... ... 1-2 Integrations...................................................................................................... ... 1-9 Summary ........................................................................................................ .. 1-14 Test Your Knowledge ....................................................................................... 1-15 Quick Interaction: Lessons Learned ................................................................. 1-16 Solutions.......................................................................................................... . 1-17
Chapter 2: Architecture
2-1
Objectives........................................................................................................ ... 2-1 Introduction...................................................................................................... ... 2-1 High Level Features and Concepts .................................................................... 2-2 Topology.......................................................................................................... ... 2-7 Usability ......................................................................................................... ..... 2-9 Support for Data Model Changes ..................................................................... 2-14 Summary ........................................................................................................ .. 2-15 Test Your Knowledge ....................................................................................... 2-16 Quick Interaction: Lessons Learned ................................................................. 2-17 Solutions.......................................................................................................... . 2-18
3-1
Objectives........................................................................................................ ... 3-1 Introduction...................................................................................................... ... 3-1 Installation ....................................................................................................... ... 3-2 Lab 3.1 - Configure Services to Use IIS ........................................................... 3-16 Lab 3.2 - Install MSMQ..................................................................................... 3-19 Upgrade........................................................................................................... . 3-22 Summary ........................................................................................................ .. 3-29 Test Your Knowledge ....................................................................................... 3-30 Quick Interaction: Lessons Learned ................................................................. 3-31 Solutions.......................................................................................................... . 3-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Application Integration Framework and Services in Microsoft Dynamics AX 2012 Chapter 4: Administration 4-1
Objectives........................................................................................................ ... 4-1 Introduction...................................................................................................... ... 4-1 Set Up Batch ...................................................................................................... 4-2 Lab 4.1 - Set Up Batch ....................................................................................... 4-6 Integration Ports ................................................................................................. 4-9 Adapters ......................................................................................................... .. 4-15 Summary ........................................................................................................ .. 4-24 Test Your Knowledge ....................................................................................... 4-25 Quick Interaction: Lessons Learned ................................................................. 4-27 Solutions.......................................................................................................... . 4-28
5-1
Objectives........................................................................................................ ... 5-1 Introduction...................................................................................................... ... 5-1 Service Types..................................................................................................... 5-2 Document Services ............................................................................................ 5-7 Lab 5.1 - Add Validation and Defaulting to a Web Service............................... 5-24 Lab 5.2 - AIF Document Service Wizard .......................................................... 5-25 Custom Services .............................................................................................. 5-27 System Services............................................................................................... 5-27 How AIF Exchanges Data ................................................................................ 5-31 Customizing the AIF Pipeline ........................................................................... 5-41 Business Operations Framework ..................................................................... 5-52 Lab 5.3 - Business Operations Framework ...................................................... 5-56 Security .......................................................................................................... .. 5-58 Summary ........................................................................................................
.. 5-64 Test Your Knowledge ....................................................................................... 5-65 Quick Interaction: Lessons Learned ................................................................. 5-68 Solutions.......................................................................................................... . 5-69
6-1
Objectives........................................................................................................ ... 6-1 Introduction...................................................................................................... ... 6-1 Call an External Service ..................................................................................... 6-2 Create and Call a Custom Service by Using a Basic Port.................................. 6-6 Lab 6.1 - Create and Call a Custom Service by Using a Basic Port................. 6-10 Call a Document Service by Using NetTcp ...................................................... 6-13 Lab 6.2 - Call a Document Service by Using NetTcp ....................................... 6-17 Call a Document Service with the File Adapter ................................................ 6-20 Lab 6.3 - Call a Document Service with the File Adapter ................................. 6-26 Create a Synchronous Document Exchange between BizTalk and AIF .......... 6-30 Exchange Documents by Using the MSMQ Adapter........................................ 6-36 Call the Metadata Service ................................................................................ 6-42
ii
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Table of Contents
Lab 6.4 - Call the User Session Service........................................................... 6-46 Create and Deploy Outbound Exchange.......................................................... 6-48 Lab 6.5 - Create and Deploy an Outbound Exchange...................................... 6-60 Summary ........................................................................................................ .. 6-67 Test Your Knowledge ....................................................................................... 6-68 Quick Interaction: Lessons Learned ................................................................. 6-69 Solutions.......................................................................................................... . 6-70
7-1
Objectives........................................................................................................ ... 7-1 Introduction...................................................................................................... ... 7-1 Monitoring Services and AIF .............................................................................. 7-3 Troubleshooting............................................................................................... . 7-10 Lab 7.1 - Debugging Services .......................................................................... 7-16 Summary ........................................................................................................ .. 7-19 Test Your Knowledge ....................................................................................... 7-20 Quick Interaction: Lessons Learned ................................................................. 7-21 Solutions.......................................................................................................... . 7-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
iii
iv
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Introduction
Microsoft Dynamics AX 2012 provides many services that can be used by the Microsoft Dynamics AX components and with third-party applications. Services are programmable artifacts in Microsoft Dynamics AX 2012. There are many out-of-the-box document services that are shipped with Microsoft Dynamics AX 2012, which can be used as it is, or customized to fit requirements. Additionally, new document services can be created, and any static method call can be exposed as a service. All customizable application and framework X++ services in Microsoft Dynamics AX 2012 are compiled to Microsoft Intermediate Language (MSIL). These services can be grouped together and deployed to ports, which is a new concept introduced in Microsoft Dynamics AX 2012. A port represents a Windows Communication Foundation (WCF) service endpoint. By default, a port is hosted on the Application Object Server (AOS). Microsoft Dynamics AX 2012 also ships with three non-customizable system services: the Metadata service, the Query service, and the User session service. With these services, clients can interact with and retrieve system information, thus enabling the development of more powerful applications, data queries through Office add-ins, and inquiries into system structure.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-1
Concepts
1-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Service operations
update A service group is a collection of services that are intended to be managed together. Each service group is associated with one WSDL rather than having one WSDL for each
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-3
Adapters
Schemas
1-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Refactored Services
In Microsoft Dynamics AX 2012 Microsoft improved services with the following key areas: Simple setup and configuration A first class programming model Aligning with industry standards Richer integration of specific features Performance enhancements
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-5
1-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Improved troubleshootin g
1-7
Performance Enhancements
The following list describes enhancements in services and AIF that result in improved performance: Compiled CIL is used to process Services. To achieve scale and redundancy, you can configure AOS servers with the Network Load Balancing (NLB) for Microsoft Dynamics AX services. The AOS-clustering solution affects only the RPC- based connections and does not allow you to load balance Microsoft Dynamics AX services. Client applications can access services through the WCF runtime without using .NET Business Connector, which was required for services and AIF in previous releases of Microsoft Dynamics AX. A deployment on an intranet does not require IIS because services are now hosted on the AOS by default. You can host services on IIS for requests that originated from the Internet; however, the routing service on IIS dispatches these requests to the AOS host. All service requests, regardless of the origin, are processed on the AOS. The services framework uses connection pooling to reduce the overhead of creating and destroying a session on service calls. All of the services references are placed in a single web services description language (WSDL) file. The single helps helps developers reuse types when they are consuming Microsoft Dynamics AX services.
Architecture
Microsoft Dynamics AX exposes its functionality through services that are based on Windows Communication Foundation (WCF) and hosted on Application Object Server (AOS) by default, or Internet Information Services (IIS) with extra configuration. All services requests, regardless of their origin, are handled by the WCF runtime that is hosted on AOS. External applications and client applications on the local area network consume Microsoft Dynamics AX services by accessing them directly from AOS.
1-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Integrations
Most Microsoft Dynamics AX 2012 implementations will require integrating with one or more other systems. Some examples of outside systems that would require integration to Microsoft Dynamics AX 2012 include: An ERP in another division A corporate website A shipping station Creating and maintaining these integrations can be one of the more difficult tasks that are performed in an implementation, and careful planning should be performed to ensure smooth implementation and operation of these integrations. Services and Application Integration Framework (AIF) provides a capable platform for implementing these integrations.
Service Types
To support a range of options for customization and programmability, including writing integrations, Microsoft Dynamics AX provides the following types of services: Custom Services are services that you create to expose X++ logic through a service interface. You can use the business logic with inbound or outbound transfers.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-9
Integration Planning
Planning is an important part of any data integration effort. When you integrate Microsoft Dynamics AX with other systems, one of the first steps is the planning phase. In this phase, the implementation team must define high-level requirements and make decisions about the design of the integration. After these requirements are defined, the partner, IT staff, and development staff can work together to define the best way to implement the exchange in Application Integration Framework (AIF). The decisions that must be made about the design of the integration fit into two primary categories: decisions about the data and decisions about the environment. Data - Central to integration is the data. While planning the integration, you must make many decisions about the data that is being exchanged and the associated business rules. This phase often involves the expertise and knowledge of business users, because these users understand the meaning of the data and can define the requirements for integration. Environment - Configuration requirements define the environment that is used for integrations. Factors that affect these requirements include the network configuration, the hardware and software configuration of the external system, and the level of trust between Microsoft Dynamics AX and the external system.
1-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Is the data sent from Microsoft Dynamics AX to an external system, or is the data received by Microsoft Dynamics AX from an external system? Is the integration based on the "pull" model or the "push" model? In the "pull" model, the external system requests data from Microsoft Dynamics AX. In the "push" model, an event in the application causes data to be sent to the external Is there any business logic that needs to be implemented for this integration that would not be found in existing AIF documents? Do the documents that are sent or received need to be transformed? Do the transformations have to be performed before data is sent or when data is received? What is the extent of the data transformations? Are the transformations performed by Does the external system have any restrictions about how data is exchanged? In other words, the external system can only create .csv documents, and it can only save them to the local Is the external system an inhouse system or an external trading partner?
This information helps you determine the type of transport adapter that is required for the exchange. This information helps you determine how users and security must be configured.
1-11
1-12
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Skills Required
The following are the skills and expertise that is needed to fully take advantage of services and AIF: X++ development C# and Visual Studio Internet Information Services (IIS) administration, if IISbased web services are deployed Windows Communication Foundation (WCF)
1-13
Summary
Services and AIF for Microsoft Dynamics AX 2012 provide a first class programming experience for integrations and creating applications. These technologies allow data to be passed into external systems from Microsoft Dynamics AX 2012, and into Microsoft Dynamics AX 2012 from external systems, by using XML and other formats. In Microsoft Dynamics AX 2012, services and AIF were refactored for simplicity, alignment with industry standards, and to add more capabilities. These changes include: Reducing high level concepts from 17 to 4 Adding features that allow services and AIF to be used for more than integrations Support for WS-* compliant services Service groups Support for non XML files Batched messaging Change tracking
1-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2. What is the preferred method for integrating to Microsoft Dynamics AX 2012? ( ) .NET Interop ( ) .NET Business Connector ( ) Services
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-15
2.
3.
1-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Solutions
Test Your Knowledge
1. Categorize the following features: a 1. Service Groups d 2. Integration port h 3. Support for non-XML files e 4. Performan ce improved f 5. Support data model changes g 6. Improved troubleshooting c 7. Change tracking b 8. Batched messaging a. Service groups help a developer group related services together. b. In Microsoft Dynamics AX 2012, you can submit large amounts of data by using the batch XML schema. This schema helps you group single messages into message sets that can be submitted together by using a single XML document. c. In Microsoft Dynamics AX 2012, you can configure the database to keep track of when changes happen at the table level. When so configured, you can use the getChangedKeys service operation to retrieve entity keys for only those documents that have changed based on certain criteria, such as a specified date and time. d. Integration ports provide a simple interface to control data going into and coming out of services and AIF. e. Several improvements were made to enhance the overall performance of services and AIF in Microsoft Dynamics AX 2012. f. The document services framework supports the data model changes that are implemented in Microsoft Dynamics AX 2012. g. In Microsoft Dynamics AX 2009, the troubleshooting and logging of AIF was performed at the service operation level. In Microsoft Dynamics AX 2012, services and AIF troubleshooting and logging is performed at the integration port level. h. Data that is not XML, for example, a comma- delimited file, can now be imported into and exported from Microsoft Dynamics AX.
2. What is the preferred method for integrating to Microsoft Dynamics AX 2012? ( ) .NET Interop ( ) .NET Business Connector () Services
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
1-17
1-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
CHAPTER 2: ARCHITECTURE
Objectives
The objectives are: Review high level flows in Services and Application Integration Framework (AIF). Discuss the topology of the Services and AIF model. Describe moving service configurations by using integration ports in AIF. Discuss the new process of change tracking. Review the transforms that are available for customization in banking. Demonstrate Excel Document Service Registration. Review support data model changes in Microsoft Dynamics AX 2012. Application Integration Framework (AIF) helps companies integrate Microsoft Dynamics AX with external business processes and partners through the exchange of XML over various transport media. As mentioned in the "Architecture lesson" of Chapter 1: Introduction to Services and Application Integration Framework all services are WCF based and hosted on AOS. When intranet communication is needed for services that are using IIS, the requests are routed to AOS for processing. Inbound and outbound messages can take advantage of message transforms or value substitutions when they are configured to do this.
Introduction
2-1
2-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Service operations Service groups
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-3
AX database. Microsoft Dynamics AX then returns the information to the requesting system, and the appropriate filtering and security are applied. The request message contains the entity keys or a query that specifies the data that the external system is requesting.
2-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Receive and create data Microsoft Dynamics AX receives documents from another authorized system and creates new records in the Microsoft Dynamics AX database.
Parallelism
To improve performance for data exchange by using asynchronous adapters, AIF supports parallelism. Parallelism specifies that inbound messages are processed by one or more AOSs without regard to the order in which they are received or produced. This helps you scale out message processing by adding multiple AOSs. Note that you can enable parallelism only for inbound channels. Parallel processing in AIF is implemented on a channel-by-channel basis. Follow these steps to implement parallel processing. 1. Click System Administration > Setup > Services and Application Integration Framework > Inbound Port or System Administration > Setup > Services and Application Integration Framework > Outbound Port. 2. Select a channel and select the Process requests in parallel check box. Conversational parallelismalso known as ordered parallelismmeans that you can specify certain messages to be processed sequentially in a channel, even when parallelism is enabled for that channel. This is done by including a special XML element called <ConversationId> in the messages that require sequential processing. All messages with the same ConversationId will then be processed sequentially. NOTE: If you do not select the Parallel processing field in the Channels form, all inbound messages for a particular endpoint will be processed sequentially and the <ConversationId> element in a message is ignored.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-5
2-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Service Groups
Developers can group services and service operations that are managed and consumed together into a service group. All the services in a service group are published through a basic port, in a single WSDL file. The WSDL contains all service and data contracts for the service operations of the service group, which simplifies developing the code that consumes services. NOTE: A Web Service Description Language (WSDL) file defines the operations that are available for a service. Developers can create a service group in the Application Object Tree (AOT). Developers can use the AutoDeploy property to specify whether the service groups that they create are automatically deployed and activated when they are created. Developers must manually deploy and activate any service groups that are not automatically activated. NOTE: Service groups are associated only with basic integration ports.
Topology
There are certain factors to consider when you plan the topology of services and Application Integration Framework (AIF).
Adapters
In Microsoft Dynamics AX 2012 services and Application Integration Framework (AIF), integration ports use adapters. These adapters enable Microsoft Dynamics AX to communicate by using various transport protocols. Microsoft Dynamics AX 2012 provides the following four adapters that represent predefined bindings: HTTP adapter - This adapter enables synchronous exchanges through web services on Internet Information Services (IIS), which can expose services on a network or the Internet. NOTE: Web Services should in general never be deployed by using basic HTTP binding. HTTPS bindings or similar, should be selected even for internal use. When you use the HTTP binding, all data will travel unencrypted and can be read by anyone on the same segment on the network. NetTCP adapter - This adapter enables synchronous exchanges by using support for WS-* standards over the Transmission Control Protocol (TCP) transport.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-7
Performance Improvements
The following list describes enhancements in services and AIF that result in improved performance: To achieve scale and redundancy, you can configure AOS servers with the Network Load Balancing (NLB) for Microsoft Dynamics AX services. The AOS-clustering solution affects only the RPC- based connections and does not allow you to load balance Microsoft Dynamics AX services. For more information, refer to Configuring network load balancing for services (http://go.microsoft.com/fwlink/? LinkID=247480&clcid=0x409 ). Client applications can access services directly on AOS; IIShosted services use the WCF routing service and no longer depend on the .NET Business Connector, which was required for services and AIF in previous releases of Microsoft Dynamics AX. The services framework uses connection pooling to reduce the overhead of creating and destroying a session on service calls.
service to route all service requests to AOS where all service requests are processed.. AOS then returns a response to the service consumer through IIS. Microsoft Dynamics AX deploys services that are hosted on IIS to a subfolder of the virtual directory that is associated with the web site that you provide.
2-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Usability
New usability features of services and Application Integration Framework (AIF) are added to Microsoft Dynamics AX 2012. The following are components of the new features. Moving service configurations by using integration ports in AIF Change tracking based on date and time of changes Templates for the transforms for Banking Configure services for Office add-ins
Office Add-ins
The new add-in for Microsoft Excel and Microsoft Word help users to view, analyze, and update information in Microsoft Dynamics AX. The Microsoft Excel add-in has built-in support for consuming document services for updating data.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-9
2-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Procedure: Export the Integration Port Configuration Data
Use the following procedure to export the integration port configuration data. 1. Create a new definition group for exports. Click System administration > Common > Data export/import > Definition groups. a. Click New. b. Enter a unique name for the group into the Definition group field. c. Optionally enter a description. d. Click the Options tab and clear all the check boxes. e. Click the Include table groups tab and clear all the check boxes. f. Click OK. 2. Select tables for the definition group by clicking Select tables. a. Click Add, and then for inbound ports, select AifInboundPort in the Name of table field. b. Select Include document references and Specify related tables check boxes. c. Click the Select related tables button. On the Select related tables form, select the desired related tables to include and then click Close. d. Optionally, add export criteria by selecting the Apply criteria check box, and then click Export criteria. Enter the desired filter criteria and then click OK. e. Close the Select tables form. 3. Export the data to a local or network file share by clicking Export to on the Definition groups form. Select the file name and path, and then select the file type. Click OK to export the data to the specified file. 4. Close the Definition group form. 5. Repeat steps 1 through 4, using AifOutboundPort in the Name of table field in step 2.a instead of AifInboundPort. NOTE: During export, you might receive the following message: "TableDirPartyCollection was not found." If you receive this message, add export criteria, which is described in Step 3 of the "Export the Integration Port Data" procedure, to export only new and customized ports.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-11
IMPORTANT: If the production environment is part of a cluster, you must restart all AOS instances to guarantee that all configurations are updated.
Change Tracking
In Microsoft Dynamics AX 2012, you can configure the database to keep track of when changes happen at the table level. When so configured, you can use the getChangedKeys service operation to retrieve entity keys for only those documents that have changed based on certain criteria, such as a specified date and time. Change tracking must be enabled in the database for the database tables that are used by the document service. To do this, you will need to configure change tracking. To retrieve the entity keys for documents that were changed, you must publish the getChangedKeys service operation through an integration port. Additionally, you will need to create a document filter and add filtering criteria. NOTE: You can use change tracking only if the document service is exposed through an inbound enhanced integration port.
IMPORTANT: You must create at least one document filter. Otherwise, no entity keys are returned from the getChangedKeys service operation.
2-12
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Once enabled, you can use change tracking in two ways: Submit an XML document to AIF that specifies the getChangedKeys action in the message header. Call the getChangedKeys method on a document service class. Only the entities that are changed on or after the _changedDateTime parameter are returned. The response message contains a list of entity keys. These keys represent the documents that have been changed according to the criteria that you specified, such as documents that were changed after a certain date and time. NOTE: For more information on configuring change tracking refer to Configuring AIF for change tracking (http://go.microsoft.com/fwlink/? LinkID=247482&clcid=0x409 ).
classes. An XSLT can be applied on this master data to transform the AIF XML file to the payment file for a specific payment format.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-13
2-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
Summary
Application Integration Framework (AIF) helps companies integrate Microsoft Dynamics AX and communicate with external business processes and other enterprise applications within and outside the boundaries of the business through the exchange of XML over various transport media.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-15
2-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 2: Architecture
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2-17
Solutions
Test Your Knowledge
1. Which of the following can not be a basic port? () Outbound ( ) Inbound ( ) Endpoint ( ) Startpoint 2. Which of the following Axd document service operations are available in AIF? (Select all that apply) () Create () Read () Update () keysFind 3. Which of the following is not a service type? ( ) Custom services ( ) Document services () NetTCP services ( ) System services 4. Which of the following best describes synchronous and asynchronous transports? (Select all that apply) () Requests are tightly coupled to responses. () Requests are placed into a queue, called the gateway queue. ( ) Invoke business logic by using preprocessing options. ( ) Requests develop new file links by using post-processing.
2-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Introduction
Review the upgrade considerations for Services and AIF. Knowing the installation and upgrade considerations for Services and Application Integration Framework (AIF) in Microsoft Dynamics AX 2012 is critical for successful implementation.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-1
Installation
Installation and configuration of Services and AIF has changed. In Microsoft Dynamics AX 2012, the Application Object Server (AOS) is the Windows Communication Foundation (WCF) service host for Microsoft Dynamics AX services, and web services on IIS is an optional component. Additionally, the BizTalk adapter has been depreciated in favor of using the Windows Communication Framework (WCF)-based adapters that are included with BizTalk.
IIS
Installing Microsoft Dynamics AX web services on IIS is optional. The Application Object Server (AOS) is the Windows Communication Foundation (WCF) service host for Microsoft Dynamics AX services that are available to users and applications across an intranet. To make Microsoft Dynamics AX services available over the Internet, you must host them on Internet Information Services (IIS). If you do not need to expose the Microsoft Dynamics AX services over the Internet or need any of the additional bindings that IIS provides, you do not need to install services on IIS.
3-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
NOTE: This procedure has already been completed in the Hyper-V image.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-3
IMPORTANT: You must restart IIS after Setup installs the web services. Select Restart IIS after installation is complete to automatically restart IIS. 10. Click Next to continue. 11. On the Specify an AOS account page, provide the service accounts for the AOS instances that you will use with web services on IIS. Click Next to continue. 12. On the Prerequisite validation results page, resolve any errors. When no errors remain, click Next. 13. On the Ready to install page, click Install. 14. After the installation is complete, click Finish to close the wizard.
For IIS 7, use the following steps to configure the application pool that is associated with the Microsoft Dynamics AX 2012 web services for IIS 7. This step is required to set the correct version of the .NET Framework. 1. Click Start > Administrative Tools > Internet Information Services (IIS) Manager. 2. Click SEA-DEV > Application Pools.
3-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-5
MSMQ
Microsoft Message Queuing (MSMQ) is a technology that enables applications that are running at different times to communicate across heterogeneous networks and systems that might be temporarily offline. MSMQ provides guaranteed message delivery, efficient routing, security, and priority-based messaging. It can be used to implement solutions for asynchronous and synchronous messaging scenarios. To send documents by using Message Queuing, you must install it on a computer on the network and create at least one public queue. To receive documents by using Message Queuing, you must install Message Queuing and create at least one queue.
MSMQ Limitations
Messages that are processed by the MSMQ adapter have a size limit of 4 megabytes (MB). For this reason, we do not recommend using Message Queuing to import data in bulk, such as by using the AIF batched-
message schema.
3-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
d. Click the Add button to display the Select Users, Computers, Service Accounts, or Groups dialog box.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-7
Use the following procedure to install Message Queuing 4.0 on Windows Server 2008 or Windows Server 2008 R2 for Services and AIF. 1. Click Start > Administrative Tools > Server Manager. 2. In Server Manager, click Roles > Application Server. 3. Right-click Application Server and then click Add Role Services.
3-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5. In the "The MSDTC service will be stopped and restarted. All dependent services will be stopped. Applications using MSDTC may need to be restarted to use the new settings. Please press yes to proceed." dialog click Yes.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-9
Configure MSMQ
In Windows Server 2008 R2, Message Queuing is managed either by using Computer Management, or if the Message Queuing Directory Service Integration feature is installed, by using Active Directory Users and Computers. Message Queuing is located under the specified computer object in Active Directory Users and Computers. Additionally, if the Message Queuing Directory Service Integration feature is installed, then certain aspects of Message Queuing in Active Directory can be managed from Active Directory Sites and Services. NOTE: More information about MSMQ can be found at the Message Queuing (http://go.microsoft.com/fwlink/?LinkID=247484&clcid=0x409 ) TechNet site.
3-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-11
M i c r o s o f t O f f i c i a l T r a i n i n g M a t e r i a l s f o r M i c r o s o f t D y n a m i c s
Y o u r u s e
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-13
3-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-15
Challenge Yourself!
Use the provided information to configure services to use IIS.
Step by Step
1. Double-click D:\Setup.exe. 2. Under Install, click Microsoft Dynamics AX components. 3. If the Setup support files have not yet been installed on this computer, the Select a file location page is displayed. The Setup support files are required for installation. Provide a file location or accept the default location and then click Next. On the Ready to install page, click Install. NOTE: In the Hyper-V image setup install files have already been installed. 4. Click Next on the Welcome page. 5. In the Modify Microsoft Dynamics AX installation page, click Add or modify components, and then click Next. 6. On the Add or modify components page, select Web services on IIS and then click Next. 7. On the Prerequisite validation page, resolve any errors. When no errors remain, click Next. 8. On the Specify Business Connector proxy account information page, enter the password for the proxy account that is used by the .NET Business Connector. Click Next.
NOTE: The proxy account for the .NET Business Connector is "CONTOSO\SQLService", and the password is "Pa$$w0rd" in the course Hyper- V image.
3-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
IMPORTANT: You must restart IIS after Setup installs the web services. Select Restart IIS after installation is complete to automatically restart IIS. 10. Click Next to continue. 11. On the Specify an AOS account page, provide the service accounts for the AOS instances that you will use with web services on IIS. Click Next to continue. NOTE: The AOS service account is "CONTOSO\AX_AOS_Service" in the course Hyper-V image 12. On the Prerequisite validation results page, resolve any errors. When no errors remain, click Next. 13. On the Ready to install page, click Install. 14. After the installation is complete, click Finish to close the wizard. NOTE: In they Hyper-V image AIF on IIS will install with warnings because it is being installed on a domain controller. The installer creates a local group called "Microsoft Dynamics AX Web Service Administrators," but because this is a domain controller is created as a group on the domain. The installer then attempts to set permissions to <Local computer>\"Microsoft Dynamics AX Web Service Administrators", but fails because it is a domain group. 1. Click Start > Administrative Tools > Internet Information Services (IIS) Manager. 2. Click SEA-DEV > Application Pools. 3. In the Application Pools pane, right-click MicrosoftDynamicsAXAif60 application pool and then click Basic Settings. 4. In the Edit Application Pool dialog box, select .NET Framework 4.0 or a later version, such as V4.0.30319. Select Integrated from the Managed pipeline mode list. Notice that the Start application pool immediately option is selected. Click OK to return to IIS Manager.
5. 6. 7. 8.
Click SEA-DEV. Right-click SEA-DEV and then click Stop. Right-click SEA-DEV and then click Start. Open Microsoft Dynamics AX 2012.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-17
3-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Challenge Yourself!
Use the provided information to install and configure MSMQ.
Step by Step
NOTE: The steps for Lab 3.2: Install MSMQ are the same as the steps in the Installation lesson. 1. Enable Read, Write, and Allow Create all child objects access to necessary computers. a. Go to Start > Administrative Tools > Active Directory Sites and Services. b. Expand Sites > Default-First-Site-Name , right click Servers, and then and then click Properties. c. Click the Security tab of the Servers Properties dialog box. d. Click the Add button to display the Select Users, Computers, Service Accounts, or Groups dialog box. e. Click the Object Types button to display the Object Types dialog box, click to enable Computers and then click OK. f. In the Enter the object names to select field type "SEADEV" and then click OK. g. Enable the following permissions for this computer object: o Allow Read o Allow Write o Allow Create all child objects h. Click Advanced to display the Advanced Security Settings for Servers dialog
box.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-19
14. Click HTTP Support. NOTE: Click Yes, I've set the required permissions, in the Have you set the required permissions in Active Directory Domain Services? message box. 15. Click Next and then click Install.
3-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-21
Upgrade
Services and AIF changed significantly in Microsoft Dynamics AX 2012. The upgrade process handles many of these changes, but there are places where manual intervention is necessary. This lesson describes how Services and AIF are upgraded automatically and where manual intervention is necessary.
Before Upgrade
Before upgrading, you should be familiar with Services and AIF. Process Messages on the Source System Before you run the upgrade process, make sure that all AIF messages have been processed on the system that is being upgraded. Check the following locations to verify that all messages have been processed: All inbound message locations - These locations include file system directories, Message Queuing queues, and any locations where AIF receives inbound messages. The queue manager - All messages in the queue manager are unprocessed and must be deleted. Click System administration > Periodic > Services and Application Integration Framework > Queue manager. Upgrade Considerations The enhancements to Services and AIF in Microsoft Dynamics AX 2012 cause significant changes in functionality, configuration, database schemas, and document schemas (or .xsd files). When you plan an upgrade from an earlier version of Microsoft Dynamics AX, consider the following guidelines: You must recompile and test all interfaces that used the earlier version of Microsoft Dynamics AX to make sure that the interfaces work with Services in Microsoft Dynamics AX 2012. Customizations that relate to services must be brought forward. In Microsoft Dynamics AX 2012, the MSMQ and BizTalk adapters are replaced with equivalent functionality that is provided by Windows Communication Foundation (WCF). You must recompile any automated integration processes that used these adapters. In BizTalk, you should change your port definitions to use the BizTalk WCF adapters and review your orchestrations and message definitions for necessary updates.
3-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Upgrade Process
The process that Microsoft Dynamics AX 2012 uses to upgrade AIF code is complex, and involves several procedures. Code Upgrade The step for the upgrade of AIF code upgrades existing Axd <Document> classes and methods. During the code upgrade, the following classes are upgraded: The Axd <Document> classes that are included with Microsoft Dynamics AX Custom Axd <Document> classes Custom classes that implement the AifServicable interface Data Upgrade During the data upgrade, AIF data in the Microsoft Dynamics AX database is upgraded. Configuration settings for AIF endpoints are copied to configuration settings for integration ports.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-23
Endpoint constraint s
3-24
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
AIF adapters
AIF channels
AIF pipelines
Information about data and action policies is not copied. In Microsoft Dynamics AX 2009, data and action policies were applied at the action level. In Microsoft Dynamics AX 2012, data and action policies are applied at the level of the integration port. Therefore, you must use the forms for inbound and outbound integration ports to define your data and action policies after the upgrade. NOTE: In earlier versions of Microsoft Dynamics AX, you were required to assign data policies to each endpoint action Integration ports Information about AIF adapters is not copied. Use the forms for integration ports to associate adapters with integration ports. Address of Information about AIF channels is integration not copied. Use the forms for ports inbound and outbound integration ports to configure the address and response address for each integration port. In earlier versions of Microsoft Dynamics AX, you could associate an endpoint with multiple channels or addresses. In Microsoft Dynamics Integration AIF pipelines are automatically port pipelines upgraded to integration port pipelines.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-25
During the upgrade process, the service code is marked with the appropriate attributes, such as create, read, or find. This step enables the auto-inference feature in Microsoft Dynamics AX 2012 to work with the upgraded code. IMPORTANT: You must configure each upgraded service to assign appropriate attributes. In earlier versions of Microsoft Dynamics AX, each AIF endpoint was associated with a specific company. In Microsoft Dynamics AX 2012, integration ports do not have to be associated with a specific company. However, you can use the forms for inbound and outbound integration ports to restrict service calls to a specific company. For an inbound message, the services framework retrieves the company ID from the message header. If the message header does not contain a company ID, the
3-26
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
After Upgrade
After upgrading, you must configure the SysEntryPointAttribute attribute and validate the migration of AIF endpoints.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-27
batch. These settings also control the preprocessing of requests and post-processing of responses.
3-28
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Summary
Understanding installation and upgrade for Services and AIF is an important aspect of using Services and AIF in Microsoft Dynamics AX 2012. The following list shows the high level concepts that must be understood. Services and AIF are installed on the AOS by default, but the NetTCP services that are published through the AOS are only available on the intranet. Services should be published on IIS to be available on the Internet. MSMQ must be installed and configured to work with AIF. Balancing does not apply to Services. To load balance services, NLB must be implemented. The upgrade process runs in two steps: one for data and one for code. After the upgrade process runs, the upgrade needs to be validated.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-29
3-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3-31
Solutions
Test Your Knowledge
1. In which situations can you use AIF Services hosted on an AOS? ( ) When using Web Services over the internet ( ) When using NetTcp Services over the intranet ( ) All of the above () None of the above 2. Which adapter is used to communicate with BizTalk in Microsoft Dynamics AX 2012? ( ) MSMQ ( ) BizTalk () HTTP 3. Can load-balanced AOS clusters balance network traffic for services. ( ) Yes () No 4. What are the two steps that are used by the upgrade process? (Select all that apply) (Select all that apply) ( ) Schema Upgrade () Data Upgrade () Code Upgrade ( ) Port Upgrade
3-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
CHAPTER 4: ADMINISTRATION
Objectives
The objectives are: Set up batch for AIF and Services. Describe the types and options for integration ports. Review the adapters that are available in services and Application Integration Framework. Administering services and AIF requires setting up and maintaining AIF batch jobs, setting up integration ports, and understanding the types of adapters available.
Introduction
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-1
Set Up Batch
Application Integration Framework (AIF) uses its gateway queue to handle asynchronous message routing in an orderly way. To move message into and out of the gateway queue, AIF requires a Microsoft Dynamics AX batch job that runs a particular set of services. The following are the four services that move documents through the gateway queue, listed in the order that they should run: 1. AIFGatewayReceiveService this service communicates with the adapters, receives messages from their external source locations, and puts them into the gateway queue to wait for processing. 2. AIFInboundProcessingService this service takes incoming messages from the gateway queue and then processes the documents according to the rules that are specified by the inbound port. 3. AIFOutboundProcessingService this service processes an outbound document according to the rules that are specified by the integration port and then adds the envelope XML code to create a fully-formed AIF message. The service then places the message into the gateway queue to send. 4. AIFGatewaySendService this service sends the messages to the correct external destinations. These services should run in a specific order because they depend on each other. For example, the gateway receive service must run before the inbound processing service. Otherwise, the inbound processing service will have no data to process until the next time it runs. Typically, these services run as four tasks in one batch job. You can create other batch job configurations, depending on your business requirements. For example, to schedule the AIF services to run at different time intervals, you can divide the services among multiple batch jobs. When you create the batch job, you can specify the order in which the services run by specifying conditions for the tasks.
4-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
6. In Remaining servers, click 01@SEA-DEV and then click the back arrow (<) button. 7. Notice that 01@SEA-DEV is now in Selected servers.
8. Click Close.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-3
grid. b. Press CTRL+N to create a new task. c. In the Task description field, type "AIFGatewaySendService". d. In the Company Accounts field, type "CEU". e. In the Class name field, select AIFGatewaySendService in the drop-down. f. In the Batch group field, type "AIF".
4-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
g. Click the Has conditions grid and then press CTRL+N to create a condition. h. In the Task ID field, select the task for AIFOutboundProcessingService in the drop-down. i. Accept the default Expected status of Ended. 7. Click Close.
8. Set the batch job recurrence a. Select the AIF batch group. b. Click Recurrence. c. In the Count field under Recurring pattern section, type "1". NOTE: A recurrence of one minute is set so that testing time is reduced. d. Click OK to close Recurrence. 9. Change the batch job status. a. Select the AIF batch group. b. Click Functions > Change status and then click Waiting. 10. Click Close.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-5
Challenge Yourself!
Use the provided information to set up batch for services and AIF.
Step by Step
NOTE: In the Hyper-V image delete the contents of C:\TEMP to avoid file adapter errors later related to an inbound port pointing to C:\TEMP.
NOTE: The steps for Lab 4.1: Set Up Batch are the same as the steps in the Set Up Batch lesson. 1. Create a batch group: a. Click System administration > Setup > Batch group. b. Press CTRL+N to create a new batch group. c. In the Group field, type "AIF". d. In the Description field, type "AIF batch group". e.Click Batch servers. f. In Remaining servers, click 01@SEA-DEV and then click the back arrow (<) button. g. Notice that 01@SEA-DEV is now in Selected servers. h. Click Close. 2. Create a batch job:
a. Click System administration > Inquiries > Batch jobs > Batch jobs. b. Press CTRL+N to create a new batch job.
4-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
c. In the Job Description field, type "AIF". d. Press CTRL+S to save the job. e. Click View tasks. 3. Create a batch task called "AIFGatewayReceiveService". a. Press CTRL+N to create a new task. b. In the Task description field, type "AIFGatewayReceiveService ". c. In the Company Accounts field, type "CEU". d. In the Class name field, select AIFGatewayReceiveService in the drop-down. e. In the Batch group field, type "AIF". 4. Create a batch task called "AIFInboundProcessingService". a. Press CTRL+N to create a new task. b. In the Task description field, type "AIFInboundProcessingServic e". c. In the Company Accounts field, type "CEU". d. In the Class name field, select AIFInboundProcessingService in the dropdown. e. In the Batch group field, type "AIF". f. Click the Has conditions grid and then press CTRL+N to create a condition. g. In the Task ID field, select the task for AIFGatewayReceiveService in the dropdown. h. Accept the default Expected status of Ended. 5. Create a batch task called "AIFOutboundProcessingService". a. Return to the task grid. b. Press CTRL+N to create a new task. c. In the Task description field, type "AIFOutboundProcessingServic e". d. In the Company Accounts field, type "CEU". e. In the Class name field, select
f. g. h. i.
AIFOutboundProcessingService in the drop-down. In the Batch group field, type "AIF". Click the Has conditions grid and then press CTRL+N to create a condition. In the Task ID field, select the task for AIFInboundProcessingService in the drop-down. Accept the default Expected status of Ended.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-7
4-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Integration Ports
In Microsoft Dynamics AX 2012, integration ports provide simplified administration of services and Application Integration Framework (AIF). Integration ports replace the AIF endpoints and related concepts that were used in previous releases of Microsoft Dynamics AX. Each integration port can expose one or more services, and each integration port has a unique Uniform Resource Identifier (URI) that identifies the port's address. Each integration port also has a direction. An integration port can be either an inbound or an outbound integration port. An inbound integration port is a destination for messages that originate from outside Microsoft Dynamics AX. An outbound integration port is a destination for messages that originate from your Microsoft Dynamics AX system. Inbound integration ports can be one of two types: basic or enhanced. NOTE: Labs and demonstrations that cover creating and configuring integration ports are found in Chapter 6: Working with Services.
URI
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-9
4-10
M i c r o s o f t O f f i c i a l T r a i n i n g M a t e r i a l s f o r M i c r o s o f t D y n a m i c s
Y o u r u s e
Chapter 4: Administration
Option Batch error processing Description Select the behavior when an error is encountered in a batched request for processing. Batched requests are separate requests that use the same message-set identifier. The following options are available: Continue Halt Select this check box to specify that requests are processed in parallel. Select this check box to enforce schema validation. Select this check box to enable the create service operation to update an existing document if it Specify the transforms for requests. Specify or configure pipeline components for each service request operation. Specify or configure pipeline components for each service response operation. Specify the transforms for responses. Specify the translation of values for field data, based on business rules. For example, internal item numbers can be translated to either vendor- specific item numbers or industry-standard numbers, depending on Specify query constraints for the getKeys and getChangedKeys service operations.
Parallel processing XML validation Replace existing documents on create Inbound transforms Inbound pipeline Outbound pipeline Outbound transforms Value mapping
Document filters
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-11
Include exceptions in fault Respond after error in asynchronous request Restrict to company Restrict users Trusted intermediary users
Logging disabled select this option to turn logging off. When you select this Specify that X++ error messages from the service are displayed to port users. Specify that the port automatically sends error messages as responses in asynchronous scenarios. Select the company to which you want to grant exclusive access to the port. Limit use of the integration port to specified users or user groups. Authorize trusted intermediaries. Typically, trusted intermediaries are middleware components, such as installations of Microsoft BizTalk Server, which help keep inbound requests secure.
4-12
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Outbound Port
An outbound port is used by Microsoft Dynamics AX to call an external system. Outbound ports are created by using System administration > Setup > Services and Application Integration Framework > Outbound Ports or by using System administration > Setup > Services and Application Integration Framework > Electronic payment services > Outbound ports for electronic payment. NOTE: The Outbound ports for electronic payment form is used to send payments in several standard formats. For more information, refer to the Configuring an outbound integration port for payments (http://go.microsoft.com/fwlink/?LinkID=247492&clcid=0x409 ) walkthrough. An outbound port provides the configuration options that are shown in the following table Option Port name Adapter Description Name of the port The type of adapter that the integration port uses to provide the transport mechanism for messages. Some adapters can use an additional response address. The URI that points to the source that the integration port uses. Select the service operations that are available on the integration port. Specify XML Schema Definition language (XSD) restrictions and field-level legal values for documents that are handled through the Select this check box to enforce schema validation. Select the type of character encoding to use by default, such as UTF8. Specify or configure pipeline components for each service response operation. Specify the transforms for responses. Specify the translation of values for field data, based on business rules. For example, internal item numbers can be translated to either vendorspecific item numbers or industry-standard numbers, depending on the trading partner.
XML validation Default encoding format Outboun d pipeline Outbound transform s Value mapping
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-13
Activate a Port
Activating an integration port allows a port to process transactions, while deactivating an integration port stops a port from being able to process transactions. No setting changes can be made on an active integration port. To change settings, deactivate the integration port. Make the required changes, and then activate the port. CAUTION: Activating an integration port causes all integration ports on the Application Object Server (AOS) to reactivate. You should avoid clicking the Activate button when integration ports are processing messages. CAUTION: Inactivating an integration port causes all integration ports on the Application Object Server (AOS) to reactivate. You should avoid clicking the Deactivate button when integration ports are processing messages.
Logging disabled select this from option to turn Specify that X++ error messages the service are displayed to port users. Select the company to which you want to grant exclusive access to the port.
4-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Trusted Intermediary
Trusted intermediaries are typically used for business-to-business data exchanges. A trusted intermediary is a type of submitting user that can act on behalf of another user, such as a claims user. A trusted intermediary is not a type of Microsoft Dynamics AX user. Instead, trusted intermediaries are typically middleware applications, such as Microsoft BizTalk Server or Electronic Data Interchange (EDI) services. These applications are represented by Microsoft Dynamics AX users or user groups that are authorized to submit inbound requests to an integration port. By using trusted intermediaries, you can delegate authentication to a trusted source, whereas authorization continues to be managed by Microsoft Dynamics AX through the role-based security framework. Trusted intermediaries are associated with integration ports. You can define custom intermediaries when configuring an integration port. A trusted intermediary must always be an Active Directory user, never a claims user. A trusted intermediary can impersonate any other Microsoft Dynamics AX user, even a claims user. When the submitting user is a trusted intermediary, AIF provides authorization to the user that is defined in the message header by the <LogonAsUser> element. Otherwise, this element is ignored. NOTE: When you use a trusted intermediary, make sure that the trusted intermediary represents a known, valid partner or a trusted system.
Adapters
In Microsoft Dynamics AX 2012 services and Application Integration Framework (AIF), integration ports use adapters. These adapters enable Microsoft Dynamics AX to communicate by using various transport protocols. Microsoft Dynamics AX 2012 provides the following four adapters that represent predefined bindings: HTTP adapter provides for synchronous message exchanges by using an HTTP or HTTPs transport. NetTCP adapter provides for synchronous exchanges by using WS-* standards support over the Transmission Control Protocol (TCP) transport. This adapter corresponds to the WCF-NetTcp binding in Windows Communication Foundation (WCF). MSMQ adapter provides support for queuing by using Message Queuing as a transport. Message Queuing is also known as MSMQ. Message Queuing is a type of asynchronous communication. This adapter corresponds to
the WCF-NetMsmq binding in WCF. File system adapter provides support for the asynchronous exchange of documents through file system directories.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-15
Registering Adapters
An adapter must be registered before it can be used. Adapters that are included with Microsoft Dynamics AX are automatically registered during installation. Whenever a new adapter is added to the Application Object Tree (AOT), you must register the adapter to make it available in the configuration forms for enhanced integration ports. Services and Application Integration Framework (AIF) require that you register adapters, services, and service groups any time that you change them in the Application Object Tree (AOT).
Select Adapters
After adapters have been registered, you must select the adapters that you want to use for integration. In the Address group or the Response address group, click the arrow in the Adapter field, and then select an adapter in the list. You can select the appropriate adapter for your connection when you configure an enhanced integration port. For example, in an outbound scenario, the chart of accounts can be sent from Microsoft Dynamics AX to two external systems. The first system can be configured to receive messages by checking for files in a specific file system directory. For this system, the integration port uses the file system adapter. The second system can be configured to use Message Queuing to receive messages. Message Queuing is also known as MSMQ. For this system, the integration port uses the MSMQ adapter.
4-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
In this outbound scenario, both messages are first put in the gateway queue in Microsoft Dynamics AX. To start and stop processing in the queues, you can use the Microsoft Dynamics AX batch job feature. When a batch job starts, it retrieves messages from the queue. The batch job sends the first message to the first system by using the appropriate file system directory. The batch job also sends the second message to the appropriate MSMQ queue for the second system. An example of an inbound scenario is creating a sales order. For an inbound integration port, you can provide a response address where AIF sends the results of processing an inbound message. For example, when an inbound message creates a sales order, a response message contains the sales order ID of the new sales order, if the inbound message is completed successfully. Responses can also contain error information. To provide a response address, select the check box in the Response address group. For an inbound integration port, you can select the same adapter type or different adapter types for inbound messages and responses.
Specify URIs
Before you can configure an adapter, you must specify its URI. The format of the URI varies, depending on the type of adapter that you selected: If the adapter type is File system adapter, the URI is the file system path of the directory where the port retrieves documents if the address is an inbound address, or where the port saves documents if the address is an outbound or response address. To select a directory, click the arrow in the URI field, and then browse to a folder. Make sure that your AOS service account has the appropriate read or write permissions for the directory. NOTE: When you submit multiple documents to a port that uses the file system adapter, the documents are processed in order based on their file names. To control the order in which documents are processed, use file names that include a sequencing scheme, such as "PO_0001" and "PO_0002". If the adapter type is NetTcp, the URI is automatically provided by Microsoft Dynamics AX, based on the port name. You can view the URI after you save the port configuration by pressing CTRL+S, for example. If the adapter type is MSMQ, the URI is based on the queue that you select. To select a queue, click the arrow in the URI field, and then select a queue in the list. The server must be configured to provide Message Queuing services, and queues must be defined before they can be used by the integration
port.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-17
Configure Adapters
After you specify the URI of the adapter that you selected, you can configure the adapter. In the Address group or the Response address group, click Configure . One of the following configuration forms opens: o For the file system adapter, the File system adapter configuration form opens. You should specify a Microsoft Dynamics AX user account as the default message owner when file ownership cannot be resolved deterministically by using the Use default owner for Administrators group adapter configuration. For example, when User Account Control (UAC) is enabled in Windows, files that were created by an administrator account will have the Owner attribute in the file properties set to the Windows Administrators group. Similarly, files that were created from a process that is running on a network service will have NT AUTHORITY\NETWORK SERVICE as the file owner. NOTE: Instructions for how to change the default file owner can be found in the "Call a Document Service with the File Adapter" lesson in Chapter 6: Working with Services. For adapters that are based on Windows Communication Foundation (WCF), the WCF configuration form contains the WCF Configuration Editor tool, SvcConfigEditor.exe, if it is installed. The types of adapters that are based on WCF include NetTcp, HTTP, and MSMQ. The WCF Configuration Editor tool is installed as a component of some versions of Windows SDK and by Microsoft Visual Studio 2010. This tool provides a graphical user interface (GUI) that you can use to create and modify configuration settings for WCF services.
4-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
If the WCF Configuration Editor tool is not installed, the WCF configuration file opens in Notepad. You can change the WCF configuration information by modifying the XML code in Notepad. Save the file when you are done.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-19
Batched Messaging
Microsoft Dynamics AX document services and Application Integration Framework (AIF) enable large amounts of data to be processed at the same time. A batched message is a single document that contains multiple, individual messages that are grouped together so that they can be processed as a unit. Batched messages can be processed only by using the file system adapter. Batched messages use the batch schema. This XML schema provides the <Batch> element, which can contain one or more <Envelope> elements. Each <Envelope> element contains a single AIF message. Each single AIF message in the batch must be smaller than 10 MB. The namespace of the batch schema is http://schemas.microsoft.com/Microsoft Dynamics/2009/06/documents/Batch. You can retrieve the Extensible Stylesheet Definition (XSD) file for the batch schema from the following location where you installed Microsoft Dynamics AX:
4-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Program files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\Application\Share\Include\Mess ageSe t.xsd The optional <Batch> element contains the two attributes that are described in the following table. Name Batch ID Description A string value that is unique for a particular batched message. The messages in the batch are processed in parallel when the port is configured for parallel processing.
Conversation A string value that several inbound messages can have in common. The conversation ID is a signal to ID AIF to process only one message in the conversation group at a time.
After a batched message is received, Microsoft Dynamics AX splits the document into its component requests, and then processes each request separately. If the integration port is configured to send responses, each component request receives a separate, corresponding response message. Each response message contains a <RequestMessageId> element. This element contains the GUID from the corresponding <MessageId> element in the header of the original request. The following diagram shows how batched messages are processed by AIF. Notice that the batched message is de-batched after the inbound transform stage, and that the request messages remain separate from that time forward.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-21
File
The file system adapter enables asynchronous exchanges through file system directories. To use the file system adapter, you must enable and configure at least one file system directory, or folder, messages. If both inbound messages and outbound messages are used, separate folders are required. Instructions for configuring the file adapter can be found in Chapter 6: Working With Services. NOTE: The AOS service must have read and write access to the inbound directory and to the outbound directory if it is configured. IMPORTANT: By default, AIF uses the file owner to determine which Microsoft Dynamics AX user to process the AIF request. Also, Windows Server 2008 defaults the file owner to the local administrators group if a user is in the local administrators group. To process files that are associated with the local administrators group, use the Use Default owner for Administrators group option.
MSMQ
The MSMQ adapter enables asynchronous exchanges through message queues. To use this adapter, you must install Message Queuing (MSMQ) on a computer on the network. You must also create at least one public queue to configure the MSMQ Adapter for Microsoft Dynamics AX. NOTE: Instructions for installing MSMQ can be found in Chapter 3: Installation and Upgrade Lab 3.2: Install MSMQ, and instructions for configuring MSMQ including creating queues, can be found in Chapter 6: Working with Services.
4-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Enabling Prioritization of Messages
To enable prioritization of messages when you are using Message Queuing: Use only non-transactional queues. Transactional queues do not support message prioritization. In the configuration file for the MSMQ adapter, or by using the WCF Configuration Editor tool, specify True for the ExactlyOnce setting for the relevant MSMQ integration bindings.
Web Services
AIF supports HTTP and NetTcp adapters for synchronous exchanges of data by using web service communication. The HTTP adapter enables synchronous exchanges through web services on Internet Information Services (IIS), which can expose services on a network or the Internet. Web services on IIS require IIS 7.0. You can deploy AIF web services on a dedicated IIS server or a dedicated IIS farm. Alternatively, you can share an IIS server or IIS farm with other Microsoft Dynamics AX components, such as Workflow, Enterprise Portal for Microsoft Dynamics AX, and report server. We recommend that you deploy AIF web services on a dedicated IIS server or a dedicated IIS farm. The NetTcp adapter enables synchronous exchanges through web services on the AOS, which can expose services on a company's intranet. These adapters enable synchronous exchanges by using support for WS* standards over the Transmission Control Protocol (TCP) transport. You can use this adapter to expose services on a network. NOTE: NetTcp is the only adapter that is supported by system services. NOTE: Instructions for configuring the web service adapters can be found in Chapter 6: Working with Services.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-23
Summary
Some of the key concepts that are required to administer services and AIF include: An AIF batch job must be set up and running for MSMQ and File System adapters to process transactions. The AIF batch job must contain the following batch tasks: o AIFGatewayReceiveService o AIFInboundProcessingService o AIFOutboundProcessingService o AIFGatewaySendService Inbound integration ports can be basic or enhanced. Outbound integration ports are always enhanced. Integration ports must be activated to process transactions. Services and AIF come with four adapters: o File System o MSMQ o NetTcp o HTTP
4-24
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-25
5. Which of the following are web services adapters? (Select all that apply) ( ) File System ( ) HTTP ( ) NetTcp ( ) MSMQ
4-26
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-27
Solutions
Test Your Knowledge
1. Which step allows a port to process transactions? ( ) Select an adapter () Activate ( ) Ctrl+N ( ) Selecting service operations 2. Put the following batch tasks in the order they should run: Step: 3 : AIFOutboundProcessingService 2 : AIFInboundProcessingService 4 : AIFGatewaySendService 1 : AIFGatewayReceiveService 3. Categorize the following items: h 1. Port name c 2. Adapter f 3. URI e 4. Service operations b 5. Data policies g 6. Value mapping a 7. Logging mode d 8. Inbound pipeline a. You can store copies of documents that are exchanged and then view them by using the History form. Select the logging mode. b. Specify XML Schema Definition language (XSD) restrictions and field-level legal values for documents that are handled through the integration port. c. The type of adapter that the integration port uses to provide the transport mechanism for messages. Some adapters can use an additional response address. d. Specify or configure pipeline components for each service request operation. e. Select the service operations that are available on the integration port. f. The URI that points to the source that the integration port uses. g. Specify the translation of values for field data, based on business rules. For example, internal item numbers can be translated to either vendor-specific item numbers or industrystandard numbers, depending on the trading partner. h. Name of the port.
4-28
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Chapter 4: Administration
4. When should an adapter be registered? MODEL ANSWER: Whenever a new adapter is added to the Application Object Tree (AOT), you must register the adapter to make it available in the configuration forms for enhanced integration ports. 5. Which of the following are web services adapters? (Select all that apply) ( ) File System () HTTP () NetTcp ( ) MSMQ
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4-29
4-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Introduction
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-1
Service Types
Microsoft Dynamics AX supports integration with the Application Integration Framework (AIF) components by using the Microsoft Dynamics AX services programming model. With this programming model, you can customize the document services that are included with Microsoft Dynamics AX, create new custom services, and consume external web services. To support a range of options for customization and programmability, Microsoft Dynamics AX provides the following types of services: Document Services: represent data and business logic within Microsoft Dynamics AX. You can use or customize the over 70 standard Axd document services that are included with Microsoft Dynamics AX. If none of the standard document services meet your needs, you can create a new document service by using the AIF Document Service Wizard.
Each document is represented by a class; the name of a document class is preceded by Axd. For example, AxdSalesOrder is the name of the document and also the name of the document class. The terms "document" and "Axd document" and "document class" can be used interchangeably. Custom Services: services that you create to expose X++ logic through a service interface. You can use the business logic with inbound or outbound transfers. System Services: these services cannot be customized. The Query Service, Metadata Service, and User Session Service are Windows Communication Foundation (WCF) services included with Microsoft Dynamics AX. They provide access to data returned in queries, metadata for AOT objects such as tables and extended data types (EDTs), and data about the calling user such as default language and default company.
With Microsoft Dynamics AX you can use external web services from X+ + code and web services that are hosted by Microsoft Dynamics AX from .NET Framework languages such as Microsoft Visual C#. Microsoft Dynamics AX supports application integration and data exchange in intranet and Internet-facing scenarios. Services that are based on WCF classes are hosted on the AOS for applications to integrate within a company's intranet. To use or expose services over the Internet, you must install and use Internet Information Services (IIS).
5-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
The following table outlines the defining characteristics of a Custom Service. Characteristic Service Definition and Data Contracts Deployment Mode Hosted Location Transport Protocol Usage Description Defined by the developer Integration Ports AOS or IIS Any supported adapter Use to expose any custom entity (including simple business entities) through a service interface AIF framework supports transforms but not pipelines, schema constraints, or other data processing options
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-3
5-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Performance requirements Service Type Document Services Description The incoming XML is passed to the document services framework, which parses the XML to validate the Axd schema, and then invokes the relevant operation. The framework enables customization to Custom services use the underlying .NET XML Serializer to serialize and de-serialize the XML into a data contract object. No other logic is present. For simple entity schemas, this approach is faster than document services. For complex schemas, you might have to write a lot of custom
Custom Services
Integration requirements Service Type Document Services Description All integration stack elements such as pipelines, transforms, and schema constraints can be applied to document Schema constraints and value substitution are not honored for custom services. However, transforms that convert between the AifXMLMessage format and other formats and pipelines for preprocessing
Custom Services
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-5
Custom Services
Microsoft Office Add-ins support Service Type Document Services Description Office Add-in tools, included with Microsoft Dynamics AX, have built-in support for using document services for No preinstalled integration with Office add-ins exists.
Custom Services
The following table summarizes some of the key scenarios for all service types in Microsoft Dynamics AX. Service Type Custom Services Common Scenarios Use to expose simple business entities as a service, or to expose custom logic from Microsoft Dynamics AX. Use to expose business entitles with varying degrees of complexity, or to support a medium- to-complex integration scenario involving business entities. Use to implement read operations for any Microsoft Dynamics AX, ad-hoc, or existing AOT query.
Document Services
5-6
Y o u r u s e o f t h i s c o n t e n t i s s u b j e c t t o y o u r c u r r e n t s e r v i c e s a g r e e m e n t
Document Services
In Microsoft Dynamics AX, the Application Integration Framework (AIF) includes a set of services that is based on documents (such as a sales order, a customer, and so on). These services use the existing Axd<Document> classes that are included with Microsoft Dynamics AX. This set of services is called document services. In AIF, data is exchanged with external systems through business logic that is exposed as services. An exchange starts with a document service. The document service calls functionality in a document class that contains the Microsoft Dynamics AX business logic. The service exposes service operations that can be called by an external system and take one or more documents as a parameter. The document is serialized into XML, and header information is added to create a message that can be transferred in to or out of Microsoft Dynamics AX.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-7
The XML Document Framework classes are the basis of the document services that come with Microsoft Dynamics AX. You can use these document services as is or customize them for your business requirements. The XML Document Framework also helps you create new document services that are based on your own business logic. In AIF, a document is a representation of the data model in Microsoft Dynamics AX, meaning that a document reflects the data as it exists in the application. For example, the sales order document contains a sales order header with the sales order data and the corresponding sales order lines. This document structure reflects the existing records in the application.
5-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Sent to the customer when the sales order packing-slip updated. You can send your exchange rates to another subsidiary. Free-text invoice Creates a sales order in the application. This document has significantly fewer restrictions on input data than the Sales Order document. Inventory Updates inventory amounts and counting journal balances with inventory document information from a third-party Inventory on hand External users can receive current information about onhand inventory amounts. Inventory Creates an inventory profit and loss record that is based on profit and loss information from a third-party journal warehouse management system.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-9
R C R
Purchase invoice
R R
CRUD CRUD
CRUD CRUD R CR
5-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
R R R R CR
external systems to read information about product groups. systems can read Shipping methods External information about shipping methods. External systems can receive Warehouse information about a warehouse. Bill of materials Allows for synchronization of a (BOM) bill of materials with external systems, for example, when production is outsourced to a Cash discount Delivers a list of cash discounts that are available to a specific user. Credit card Allows for the import of corporate credit card Customer Payment transactions. You can create customer payment Journal records based on a customer invoice. Expense report You can enter and submit expense reports. Fixed asset Delivers a list of assets and allows for the creation of new fixed asset records. Fixed Delivers a list of the asset asset conditions. Fixed asset conditions condition describe the physical status of a fixed asset, such as good, new, refurbished, improved, or used. Fixed asset group Delivers a list of the asset groups. Fixed asset location Delivers a list of the asset locations. Locations describe where a fixed asset resides and can include an address. Delivers a list of the asset major types. Fixed asset major types are high-level asset groupings, that are used for
R C C CR CRU
R R
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-11
External systems can create profit and loss journals. This makes it possible Delivers a list of general journals, CR and allows for the creation of new general journals with ledger account types that support multicurrency Creates a production picking C list journal. Subcontractors can report item consumption. External systems can create C project hour journals. Project invoice for Danish e- R invoice. Creates an electronic invoice for the Danish tax authorities. Users can enter customer CUD return orders. R C
You can send a return order acknowledgement to the customer. Creates a production route card journal. A subcontractor can report progress (hours spent, good quantity, error quantity, Sales invoice You can send an invoice to a customer or to a service that creates and mails invoices. Sales e-invoice Sales invoice for Danish einvoice. Creates an electronic invoice for the Danish tax Service agreement Allows for the exchange of electronic service agreements including the service agreement header andthe lines. Service order Allows for exchange of electronic service orders including the service order header Vendor Allows for synchronization of vendor data with external systems. Vendor group Allows for synchronization of vendor groups with external systems.
5-12 Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
CRUD
CRUD CRUD
Delivers payment information for a specific vendor. Budget Users can create, read, update, Transaction and delete budget register entries Catalog Import Users (Vendor, Purchasing agent. or Purchasing manager) can maintain the vendor's imported catalog in Microsoft Customer Customer electronic payment Electronic service Payment Document Users can submit Handling unattached documents and push them into workflow for association with records. Product Master Allows for read and write of Dimension Values product dimension values for a product master. Product Service External systems can read or write products into shared product repository. Meter External systems can record reading meter readings in the service environmental sustainability dashboard. Substance flow External systems can record substance flow transactions in the environmental sustainability dashboard. EU sales Allows for the generation of EU list sales list files, which are used for reporting reporting to government Warehouse Item External systems can create and retrieve warehouse items. Barcode Service External systems can retrieve barcode information for a Create Inventory released External product. systems can create Transfer Order inventory transfer orders. Inventory Transfer External systems can post inventory transfer orders. Order Posting Read Inventory Transfer Order External systems can read inventory transfer orders.
FR C
R, F, GCK, GK CRF, FK, GCK, RF, FK, GCK, GK C, GCK, GK C, GCK, GK RF, FK, GCK, GK
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-13
Customers can receive vendor quotes in response to a request for quote. can send requests for Customer quote to vendors. Allows for the creation, retrieval, and cancellation of purchase requisitions. Request For Quote Customers can manage request for quote documents. Sites Sales Quotation Journal External systems can read sales quotation journals.
Line Discount List External systems can retrieve line discount lists. Multiline Discount List Sales Confirmation Sales Quotation Total Discount External systems can retrieve multiline discount lists. External systems can read sales order confirmations. External systems can read, create, update, and delete sales quotations. External systems can retrieve total discount lists.
5-14
Y o u r u s e o f t h i s c o n t e n t i s s u b j e c t t o y o u r c u r r e n t s e r v i c e s a g r e e m e n t
Axd<Document> Classes
The Axd<Document> classes present XML data as an electronic document. Each class represents a single document in Microsoft Dynamics AX. Also Axd<Document> classes aggregate data from a number of internal Ax<Table> classes to form the document content. In addition, Axd<Document> classes perform the actual serialization and deserialization of the inbound and outbound XML documents, respectively. The term Axd<Document> class is a general reference to specific classes that implement actual document logic. For example, AxdSalesOrder is an instance of an Axd<Document> class. Each document class inherits from the AxdBase base class, as shown by the following AxdSalesOrder class: class AxdSalesOrder extends AxdBase { } By default, all methods of the AxdBase class are enabled when a document class is created. To disable a method, you must override it and return an error. For example, the AxdPurchaseInvoice.read method is disabled, as shown in the following code.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-15
Ax<Table> Classes
The Ax<Table> classes (previously known as AxBC classes) provide an object interface to the individual tables. The Axd<Document> classes always use the Ax<Table> classes to read from or write to the underlying tables. For example, the AxdSalesOrder document class uses the AxSalesTable class to access the SalesTable table.
this.setDeliveryState();
5-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
The following code shows the accessor method parmCashDisc in AxSalesTable, which only sets the SalesId field if the default is not set on the SalesTable. protected void setSalesId() { NumberSequenceReference numberSequenceReference; if (this.isMethodExecuted(funcName())) { return; } if (this.isSetMethodsCalledFromSave()) { if (this.isFieldSetExternally(fieldNum(SalesTable, SalesId))) { if (!this.salesTable()) { numberSequenceReference = SalesParameters::numRefSalesId(); this.checkNumber(numberSequenceReference.numberSequenceTable(),fi eldNu m(SalesTable,SalesId),this.parmSalesId()); if (numberSequenceReference.NumberSequenceId && numberSequenceReference.numberSequenceTable().Continuous) { NumberSeq::newReserveNum(numberSequenceReference).reserve(this.p armSal esId()); } } } else { if (this.isFieldSet(fieldNum(SalesTable, SalesId))) { return; } if (!this.parmSalesId()) { this.parmSalesId(NumberSeq::newGetNum(SalesParameters::numRefSale
sId()).
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-17
Axd<Document> Queries
An Axd<Document> query describes the structure of the XML document and controls the data that is retrieved from Microsoft Dynamics AX. The document query is a standard query in the AOT under the Queries node, and it functions as a data source, just as a query does for a form or report. Fields that are disabled in the query are not retrieved from the database because the query is run when the data is being serialized or deserialized in the document class.
5-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Send Framework
The send framework is used when the document's recipient cannot be determined from the document's context. As a result, the sendElectronically method is neither created nor used on the main table that is associated with the document query. When the send framework is used, the sendDocument or sendMultipleDocuments method is called from the Main method on the AxdSend <Document> class. The AxdSendContext Class is passed as an argument to the sendDocument or sendMultipleDocuments methods. Some documents that use the send framework require the AxdSendContext class to bypass RLS while others do not. The following table shows outbound documents that use the send framework. Document Price List Document class AxdSendPriceList AxdSendContex t class is called Yes
Chart of Accounts
AxdSendChartofAccounts
No
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-19
5-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-21
5-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-23
Scenario Simon, the Systems Implementer, needs to validate that birthdays are added for all customers that were created by using the AXCustTable class.
Challenge Yourself!
Use what you have learned to validate that birthdays are added for all customers created using the AXCustTable class.
Step by Step
1. Open Microsoft Dynamics AX 2012. 2. Click Ctrl+Shift+W to open a development workspace. 3. Right-click AOT > Classes > AXCustTable and then click Override method > More... > More... > ValidateWrite. 4. Change validate write to the following code and then click save: protected void validateWrite() { super(); if (this.parmBirthDate_IT() == dateNull()) { throw error("Birthday is required for web entry"); } }
NOTE: A hard-coded error message was used to make this example easier to read. The best practice is to use a label rather than hard-coded strings.
5-24
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Challenge Yourself
Generate a new document service for the AxdDlvMode query by using the AIF document services wizard.
Step by Step
1. Open Microsoft Dynamics AX 2012. 2. Click Ctrl+Shift+W. 3. Click Tools > Wizards > AIF Document Service Wizard, or click Tools > Application Integration Framework > Create Document Service. The Welcome screen appears. 4. Click Next. 5. In the Select document parameters screen, in the Query field, select the AxdDlvMode query. The Document name will default. NOTE: For this lab enter "DlvMode1" in Document name. 6. Type a descriptive name in the Label field. 7. Click Next. 8. In the Select code generation parameters screen, the class names default based on the query you selected. 9. Select the "read" service operation. TIP: Be sure to select all the service operations that you might need for the document service that you are creating. If you want to add more service operations after exiting the wizard you will have to create a new document service that has a different name and add the service operations to it.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-25
5-26
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Custom Services
In Microsoft Dynamics AX, you can use custom services to expose X+ + functionality to external clients. No additional code is required to expose any existing X++ classes. Microsoft Dynamics AX provides standard attributes that can be set on the DataContract class and its members to automatically serialize and de-serialize data that is sent and received across a network connection. Many predefined types, such as collections and tables, are also supported. Use custom services when the schema for the entity can be written as a simple data contract class and relevant data member attributes set. If tables and relationships are used in a data contract, you must create code for a more complex feature such as dimensions. You can use all functionality of transforms for data processing with custom services. CAUTION: The service operation names Create, Find, Update, and Delete are reserved for use only in AIF Document Services. Use of those service operation names in a custom service will generate an exception and might cause the system to time out when you try to call the service from an external client.
Data Contracts
Microsoft Dynamics AX supports the use of .NET and X++ types as data contracts for service operation input and return parameters. This helps you to pass complex data types without having to explicitly implement XML serialization and deserialization. The data contract serialization and deserialization is handled by Windows Communication Foundation (WCF).
System Services
System services are Windows Communication Foundation (WCF) services that are included with Microsoft Dynamics AX. These services help clients interact with and retrieve system information. The system services include the following: Metadata service Helps you query for data about the structure of your installation. You can retrieve metadata for labels, menus, menu items, tables, extended data types, data types, enums, queries, web menus, web menu items, info parts, cues, dimensions, form parts, web controls, service groups, and services.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-27
Metadata Service
The metadata service returns information about AOT objects in Microsoft Dynamics AX such as tables, services, extended data types (EDTs), enums, and so on. The metadata service has two types of service operations: Service operations that return names or keys return the names or keys for all queries, tables, menus, and so on. The names are returned in a string array.
5-28
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Query Service
The query service is one of the Microsoft Dynamics AX system services that helps you issue a query for data without using an Application Integration Framework (AIF) document service or creating a custom service. The query service returns data in a dataset and implements a paging mechanism so that you can manage large amounts of data that are returned by a query. The query service runs the query that you specify and returns the data in a dataset. The three types of queries that you can call with the query web service are: Static query is already defined in the Application Object Tree (AOT) under the Queries node. When calling the query service by using a static query, you pass in the query name as a string. User-defined query is defined by using the QueryMetadata class. Dynamic query is defined in an X++ class that extends the AifQueryBuilder class. All query logic is contained in the query builder class. Use a dynamic query when you want to perform the following tasks: o Using the query service to call a complex query that cannot be created by using a static query or a userdefined query o Assuming full control over the query behavior and results When you use the query service to call a static or user-defined query, the query service handles the details of how the query is run, for example, the dataset name is defaulted to the name of the query. If using the SysQueryBuilder class, you can specify the dataset name in the
getDataSetName method. NOTE: For more information on the query service, refer to the Query Service (http://go.microsoft.com/fwlink/?LinkID=247495&clcid=0x409 ) topic on Technet.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-29
5-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-31
XSD
Each document in AIF has a set of schemas that defines the structure and format of the XML that the document can serialize and de-serialize. This is called the document XML Schema Definition (XSD) or the schema. The document schema defines the structure and format for all possible fields in the document. NOTE: When creating an integration port for an exchange, you can enable different fields for each document, which will be reflected in the schema.
Document XSD
In AIF, the schema for each document is generated by iterating through the query that is associated with the document class. For example, the PurchPurchReqService document service class is associated with the AxdPurchaseRequisition document class and a query by the same name. The data source for this query contains multiple nested tables with the VendPurchOrderJour table at the parent level. When an XML document is sent or received in AIF, the XML is validated against the document schema. Microsoft Dynamics AX generates the schema internally by calling the getSchema method as shown in the following diagram.
5-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
AxdExtType_
5-33
AxdArray_
Arrays
AxdEnum_
Enumerations
5-34
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Non-Editable Fields
In an inbound message, the XML cannot contain data for fields that are non- editable in the table (the AllowEdit property is set to No). That is, for each non- editable table field, the field element must not be in the inbound XML or the field element must be filtered out in the endpoint action data policy.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-35
Time Values
When .NET serializes time values to XML, it includes fractional seconds and an offset. For example, .NET could create an XML element similar to the following: <AxTime>23:18:29.8108671-08:00</AxTime> AIF will accept an XML time value in this format. However, when it deserializes a time value, the fractional seconds and offset are truncated and the value will contain hours, minutes, and seconds (hh:mm:ss). AIF de-serializes the previous time value to the following: <AxTime>23:18:29</AxTime> Some documents contain time zone elements. The valid time zone values are specified in the document schema.
AIF Messages
When AIF receives and processes an inbound message, it generates an outbound message in response that has a <Header> tag section and a <Body> tag section. The XML tag names in the <Header> are mostly the same across all messages. The tag names in the <Body> section vary between different inbound messages, and between different outbound messages. The tags that are required in the <Body> section depend on which service option is specified in the <Action> tag in the <Header> section.
5-36
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Within the EntityKeyList tags in the message, one or more EntityKey tags could contain the IDs of the records to be read. The EntityKey tags must conform to the EntityKey.xsd that is included with Microsoft Dynamics AX. When AIF receives the correctly formatted message, it will send back a message that contains the customer data.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-37
<KeyField > <Field>AccountNum</Field> <Value>1101</Value> </KeyField > </KeyData > </EntityKey >
5-38
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
ports. o Click System administration > Setup > Services and Application Integration Framework > Outbound ports. 2. On the Service contract customizations FastTab for one of the inactive ports, select Customize documents and then click Data policies to open the Document data policies form. NOTE: Service contracts are only available on enhanced ports. 3. In the Document name field, click a document name.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-39
Shared-Types Schema
The shared-types schema defines the enums and extended data types (EDTs) that are used by a document service. The shared-types schema consolidates all the data types into one schema that is imported by all document service schemas. The namespace for the shared-types schema is http://schemas.microsoft.com/dynamics/2008/01/sharedtypes. If you publish a new service that contains a new enum or EDT, the sharedtypes schema is automatically updated. The shared-types schema is imported by the WSDL. NOTE: Automatic updates to the shared-types schema could cause schema mismatches. If you want to view the shared-types schema, view the schema for any service from either the Inbound ports or the Outbound ports form. Click View imported schemas to view the shared-types schema. IMPORTANT: If providing a document XSD to an external party, you have to provide the shared-types schema also. This is because the sharedtypes schema is imported by the XSD, and without the shared-types schema, the external user is not able to utilize the service XSD.
5-40
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-41
Transforms
Transforms provide an extensible framework that developers can use to apply Extensible Stylesheet Language Transformations (XSLT) or .NETbased transforms to messages. .Net-based transforms can convert messages to or from any proprietary format. Microsoft Dynamics AX services and AIF can process XML documents only if the documents comply with the service XSD. If an incoming document is based on XML but uses a different schema, you can use Extensible Stylesheet Language (XSL) to transform the document to the AIF schema. If an incoming document is not based on XML, such as a comma- delimited file, you can use a .NET Framework assembly to convert the file to the AIF schema. CAUTION: We do not recommend adding multiple instances of the same .NET assembly to the Manage transforms form by using a different name for each instance. When multiple instances of the .NET assembly are listed in the form, each instance refers to the same .dll file. Changes to the .dll file will affect all ports that reference the transform, regardless of the transform's name in the Manage transforms form. You can apply transformations, or transforms, to documents that are processed by an inbound or outbound integration port. In inbound integration ports, you can specify transforms for inbound messages or outbound responses. In outbound integration ports, you can specify transforms for outbound messages. Transforms for inbound exchanges are run before transforms for outbound exchanges. Transforms process the whole message. Therefore, the body and headers of the message are processed.
5-42
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5. Click Load. 6. Browse to the file that contains the transform and then click Open.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-43
Custom Pipeline
You can use pipelines to add custom processing to documents that are processed by an inbound or outbound integration port. In inbound integration ports, you can use pipelines for inbound requests or outbound responses. In outbound integration ports, you can use pipelines for outbound messages. For inbound exchanges, pipelines are run after transforms. For outbound exchanges, pipelines are run before transforms. Pipelines process only the body of the message.
5-44
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-45
7. In the Internal value field, enter the internal value. 8. In the External value field, enter the corresponding external value. 9. Press CTRL+S to save the lookup entry.
5-46
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
8. To view the XML code for the XSLT that you imported, click View. 9. Close the form.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-47
Catalog Import
To create and maintain procurement catalogs on your procurement site, you can allow vendors to submit catalog maintenance request (CMR) files by using the vendor self-service portal. Before a vendor can use the vendor self-service portal to import catalog files, you must set up an integration port by using Application Integration Framework (AIF). Only users who are assigned to the System Administrator role can configure integration ports. This task is only one of the steps that are required to enable imported catalogs. Before you can configure a port to receive CMR files from vendors, you must set up a root folder where all the files are stored.
Value Mapping
During value mapping, field data values are translated based on business rules. For example, you can translate internal item numbers to vendor-specific item numbers or industry-standard numbers, depending on the trading partner. Value mapping can be performed on inbound and outbound XML documents, and is configured on each port. Value mapping creates a translation index between a field in Microsoft Dynamics AX and an external field in the
document. This index gives you more flexibility when you must handle various internal, vendor-based, or industry-based codes.
5-48
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
External code
ISO currency code The following table describes the data values that you can map. Category Partners Addresses Data Vendor code Customer code Country/region code Country code State code Zip/postal Item number code Warehouse code Unit code Currency code Mode of delivery code Delivery terms codes Charges code Sales tax code
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-49
Use defaulting
5-50
M i c r o s o f t O f f i c i a l T r a i n i n g M a t e r i a l s f o r M i c r o s o f t D y n a m i c s
Y o u r u s e
5-51
5-52
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-53
5-54
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Batch
Synchronously
Asynchronously
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-55
Challenge Yourself!
Use the provided information to create a process by using the Business Operation Framework.
Step by Step
1. Click Ctrl+Shift+W to open a new development workspace. 2. Right-click AOT > Classes and then click New Class. 3. Double-click AOT > Classes > Class1 and then paste the following code:
[DataContractAttribute] class SimpleDataContract { int property1; }
4. Click Ctrl + S to save the class. 5. In the SimpleDataContract class, click Ctrl + N to create a new method. 6. Paste the following code:
5-56
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Click Ctrl + S to save the class. Click Ctrl+Shift+W to open a new development workspace. Right-click AOT > Classes and then click New Class. Right-click AOT > Classes > Class1 and then click Rename. Rename the class "SimpleService". Double-click AOT > Classes > SimpleService and then click Ctrl + N to create a new method. 13. Paste the following code:
[SysEntryPointAttribute] public str operation1(SimpleDataContract _dataContract) { str returnValue; returnValue = strFmt('Input was %1', _dataContract.property1()); } return returnValue;
14. Click Ctrl + S to save the class. 15. In the AOT, right-click Services > New Service. 16. Right-click the new service > Rename, and then enter "SimpleService" as the new name of the service. 17. Right-click SimpleService > Properties. 18. In the Class property, select the name of service class. For this exercise, select SimpleService. 19. In the AOT, expand the SimpleService node to show the Operations node. 20. Right-click Operations > Add Operation to show the Add service operations form. 21. Select the Add check box next to each operation that you want to add, and then click OK. 22. Right-click SimpleService and then click Save. 23. In the AOT, right-click Service Groups and then click New Service Group. 24. Right-click the new service group > Rename and then enter "SimpleServiceGroup" as the new name of the service node reference.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-57
Security
Role-Based Security
Microsoft Dynamics AX 2012 introduces role-based security as its security system. In role-based security, access is not granted to individual users, only to security roles. Users are assigned to roles. A user who is assigned to a security role has access to the set of privileges that is associated with that role. A user who is not assigned to any role has no privileges. In Microsoft Dynamics AX, role-based security is aligned with the structure of the business. Users are assigned to security roles based on their responsibilities in the organization and their participation in business processes. The administrator grants access to the duties that users in a role perform, not to the program elements that they must use.
5-58
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
AIF Users
The following types of users can work with services and AIF: Submitting user Authorized port user Claims user
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-59
Claims User
A claims user is a type of Microsoft Dynamics AX user. Claims users are authenticated by an external system, not by Application Object Server (AOS). To gain authorization to access services, a claims user must be authenticated and then impersonated by a trusted intermediary user.
5-60
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Proxy User
If a proxy is used, .NET Business Connector can connect on behalf of Microsoft Dynamics AX users when authentication is performed by an AOS instance.
System administrat or
SYSADMIN -
Every service operation is associated with an entry point privilege. This privilege provides permissions for the tables that the service reads or modifies. For example, the SalesSalesOrderServiceCreate service operation is associated with the SalesSalesOrderServiceCreate privilege. The ServiceOperation duty provides privileges for all service operations. Other duties provide privileges for specific service operations, depending on the responsibilities of the duty and its
associated roles. For example, among the privileges that the DOCommerceOnlineSalesOrderMaintain duty provides is the SalesSalesOrderServiceCreate privilege.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-61
adapter classes, and pipeline components. Pipeline components are X++ classes that are called during processing of the AIF pipeline.
5-62
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-63
Summary
5-64
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-65
5. How many document services are provided in Microsoft Dynamics AX 2012? ()5 () 70 () 20 ( ) 500 6. Which tasks can be performed in the AIF pipeline? (Select all that apply) ( ) xsl transforms ( ) .NET assembly transforms ( ) Value mapping ( ) Custom logic 7. What are the service types that are available in Microsoft Dynamics AX 2012? (Select all that apply) ( ) Development Service ( ) Custom Service ( ) Document Service ( ) System Service 8. What framework did the Business Operations Framework replace? ( ) Application Integration Framework ( ) Send Framework ( ) RunBase Framework ( ) FormLetter Framework
5-66
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-67
2.
3.
5-68
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Solutions
Test Your Knowledge
1. Put the following steps in order: Step: 2 : The request is received by the IIS where the AIF services are hosted. IIS retrieves the user credentials. 3 : The request is passed to AIF, which validates that the user is a valid Microsoft Dynamics AX user with appropriate permissions to start the operation. 4 : After AIF determines that the user has access to the service, the message is processed. 1 : The client calls a service method, such as the Customer.read method, and passes the entity key of the requested customer in a SOAP message. 2. Which one of the following documents define the structure and format of all possible fields for an AIF XML document? () XSD schema ( ) CSV master ( ) XML source ( ) AIF structure management document 3. Categorize the following items: f 1. Excluded field list b 2. Noneditable fields a 3. Outbound null values c 4. Inbound null values d 5. Time zone storage e 6. Time values a. Null values are not serialized for outbound documents. Arrays can contain empty elements and will be serialized. b. XML cannot contain data for fields that are non-editable. c. Empty string elements are interpreted as zero- length strings and not null values when processing an inbound document. d. The valid time zone values are specified in the document schema. e. AIF accepts XML with fractional seconds. However, when it de-serializes a time value, the fractional seconds and offset are truncated and the value will contain hours, minutes, and seconds (hh:mm:ss). f. Fields starting with Del_ Fields marked with status of Not visible
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5-69
5-70
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Your use of
5-71
5-72
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Introduction
Set up the AIF components for an outbound exchange, and then create and test an outbound exchange. The labs, demonstrations, and procedures in this chapter reinforce the concepts that were covered in previous chapters. This chapter will give you the information necessary to use the following major functions in Services and AIF: Call an external service Create and call a custom service by using a basic port o Create a custom service o Create and deploy a service group o Call the service Call a document service by using NetTcp o Create an inbound port o Send a Sales Order o Inquire about an Item Call a document service with the file system adapter o Create files and folders with appropriate permissions o Create an inbound port
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-1
6-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-3
6-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
IMPORTANT: Replace the string [YOUR_BING_APPID] in the #define statement with the application ID that you received from the Bing developer site.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-5
7. 8. 9. 10.
Click the Ctrl+S keyboard shortcut to save changes. Close the code editor. Right-click AOT > Services then click New Service. Right-click the new service, click Rename, and then type "Greetings" . 11. Right-click AOT > Services > Greetings then click Properties. 12. Set the Class property to Greetings.
6-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-7
8. Click OK. 9. Open Program.cs. In the code editor, replace the empty Main function with the following C# code:
6-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
10. Click Debug > Start Debugging and then notice the response. 11. Close Visual Studio.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-9
Lab 6.1 - Create and Call a Custom Service by Using a Basic Port
In this lab, you will create a custom service to add two numbers and then deploy the service by using the service group's autoDeploy property. Scenari o Simon, the System Implementer, needs to create a custom service to add two numbers and then deploy the service by using the service group's autoDeploy property.
Challenge Yourself!
Use the information provided to create a custom service to add two numbers, then deploy the service using the autoDeploy property of the service group.
Step by Step
1. Open Microsoft Dynamics AX 2012. 2. Click the Ctrl+Shift+W keyboard shortcut to open a new development workspace. 3. Right-click AOT > Classes and then click New Class. 4. Right-click the new class, click Rename, and then type "Arithmetic". 5. Right-click AOT > Classes > Arithmetic and then click New > Method. 6. Replace the contents of method1 with the following: [SysEntryPointAttribute] public int intAdd(int _int1, int _int2) { return _int1 +_int2; } 7. Click the Ctrl+S keyboard shortcut to save changes.
8. Close the code editor. 9. Right-click AOT > Services and then click New Service.
6-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
DEV:8101/DynamicsAx/Services/ArithmaticGroup 37. Click Go. Wait for Visual Studio to find the service.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-11
40. Click Debug > Start Debugging and then notice the response. 41. Close Visual Studio.
6-12
M i c r o s o f t O f f i c i a l T r a i n i n g M a t e r i a l s f o r M i c r o s o f t D y n a m i c s
Y o u r u s e
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-13
7. You can modify the document data policy to match the fields that you want to return in the response. If you do not specify a data policy, then all sales order schema elements are included in the response message by AIF. If you specify a data policy but do not modify the default data policy, then only the default elements are included in the sales order schema. 8. Activate the integration port. 9. Make note of the address that is displayed in the WSDL URI text box. 10. Close the Inbound ports form.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Console.WriteLine("For sales order: " + resp.SalesTable[0].SalesId); Console.WriteLine("Customer Account is: " + resp.SalesTable[0].CustAccount); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); cl.Abort(); } cl.Close();
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-15
10. Press F5 to run the project. 11. Enter a sales order SO-101224 and press Enter.
12. Press Enter to exit and then close visual studio. If the sales order is successfully read, the application displays the sales order ID and the customer account number. Otherwise, the application displays an exception message.
6-16
Y o u r u s e o f t h i s c o n t e n t i s s u b j e c t t o y o u r c u r r e n t s e r v i c e s a g r e e m e n t
Challenge Yourself!
Use the provided information to call the inventitemservice.read document service with NetTcp.
Step by Step
1. Open System administration > Setup > Services and Application Integration Framework > Inbound ports. 2. Click New. 3. Name the new integration port "ItemReadNetTcp". 4. In the Adapter list in the Address group, select NetTcp. 5. On the Service contract customizations FastTab, click Service operations. 6. In the Select service operations form, select InventItemService.read in the Remaining service operations list. Click the left arrow to move the service operation to the Selected service operations list. Close the form. 7. You can modify the document data policy to match the fields that you want to return in the response. If you do not specify a data policy, then all sales order schema elements are included in the response message by AIF. If you specify a data policy but do not modify the default data policy, then only the default elements are included in the sales order schema. 8. Activate the integration port. 9. Note the address that is displayed in the WSDL URI text box. 10. Close the Inbound ports form.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-17
6-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
} cl.Close(); Console.ReadLine();
21. Press F5 to run the project. 22. Enter "1000" for the Item ID and press Enter. 23. Press Enter to exit and then close visual studio.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-19
6-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-21
Click OK. Select Response address. In Adapter, select File System Adapter. In the URI field, type "C:\AIF\SalesOrderCreateFileOUT". Click Service operations. In Remaining service operations group, select SalesSalesOrderService.create and then click the less than (<) button. 15. Notice that SalesSalesOrderService.create has been added to Selected service operations group. 16. Click Close. 17. Select Customize documents and then click Data Policies. 18. In the Document data policies form, sort the table on the Element name column and then select Enabled for the following elements: o CustAccount (/SalesOrder/SalesTable/CustAccount) o ItemId (/SalesOrder/SalesTable/SalesLine/ItemId) HINT: Use filters to find these elements. 19. Click Close and then click Activate. 20. Close the infolog.
6-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
<ItemId>1000</ItemI d> <SalesQty>18</SalesQt y> <SalesUnit>Pcs</SalesUnit> </SalesLine > </SalesTable > </SalesOrder > </MessagePart s> </Body > </Envelope>
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-23
alesOrderService/create</Acti on> <RequestMessageId>{944EBD24-50ED-41BF-B7792DC90F00F350}</RequestMessageId> </Header > <Body > <MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/docu ments/
6-24
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-25
Challenge Yourself!
Use the provided information to call the inventitemservice.read document service with a file adapter. NOTE: This lab depends on Lab 4.1: Set up Batch in Chapter 4: Administration.
Step by Step
NOTE: Demonstrations in this section need to be performed in order, and they depend on Lab 4.1 Set up Batch in Chapter 4: Administration. 1. Create a new folder called "C:\AIF" if it has not already been created. 2. Create a new folder called "C:\AIF\ItemReadFileIN". 3. Right-click ItemReadFileIN and then click Properties. 4. Click Security and then click Advanced. 5. Click Change Permissions and then click Add. 6. In Enter the object name to select, type "AX_AOS_Service" and then press Enter. 7. Select Allow full control and then click OK on all open dialogs. 8. Repeat steps 2- 7 for "C:\AIF\ItemReadFileOUT". 9. Open Microsoft Dynamics AX. 10. Open System Administration > Setup > Services and Application Integration Framework > Inbound Ports and then click New. 11. In Port name, type "ItemReadFile".
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-27
IMPORTANT: The XML code includes an element titled <MessageId>, which contains a GUID. This GUID uniquely identifies the message. You must provide a new, unique GUID for each message that you send to AIF. 30. Save the file. Name the file "ItemRequest.xml". 31. Save a copy of the file that you named ItemRequest.xml to the folder that you named "C:\AIF\ItemReadFileIN". NOTE: When you submit multiple documents to a port that uses the file system adapter, the documents are processed in order based on their file names. To control the order in which documents are processed, use file names that include a sequencing scheme, such as "SO_0001" and "SO_0002". 32. Wait for the batch job to retrieve the file from the folder. 33. Watch the folder that you named "C:\AIF\ItemReadFileOUT". After a few minutes, a response file will be saved to this folder by AIF. NOTE: You can monitor the progress of your message by reviewing System Administration > Periodic > Services and Application Integration Framework > Queue manager and System Administration > Periodic > Services and Application Integration Framework > Exceptions. 34. Open the response file to view the XML code. A valid XML response contains item information. The following is a partial example:
<?xml version="1.0" encoding="UTF-8"?> <Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/docume nts/Message"> <Header> <MessageId>{57DD6ABD-6EA1-4E54-9A88-975AF8491324} </MessageId> <Action>http://schemas.microsoft.com/dynamics/2008/01/servi ces/ItemService/read</Action> <RequestMessageId>{97387992-EE19-4980-9D3042EB0DB61D8A}</RequestMessageId> </Header> <Body> <MessageParts
xmlns="http://schemas.microsoft.com/dynamics/2011/01/docume
6-28
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-29
General Steps
To implement this scenario, follow these general steps: 1. Create the file system directories. 2. Create and configure an AIF enhanced integration port. 3. Create a new Visual Studio 2010 BizTalk project that references the service's published WSDL document and includes a map to create the service request document. 4. Configure the BizTalk Server Administration Console to add ports to the application that you deployed in the previous scenario. 5. Submit the XML document that contains a request to read the sales order. 6. View the XML document that contains the requested sales order.
6-30
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-31
6-32
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Bindings.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-33
6-34
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-35
6-36
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4. Select the Transactional check box. 5. Click OK to close the dialog box. 6. Wait for the queue to appear in Server Manager. The queue might not appear immediately. 7. Right-click the queue and then click Properties. 8. Select the Authenticated check box. 9. Click Security and then click Add. 10. In the Enter the object names to select field type "AX_AOS_Service" and then click OK. 11. Select the AX_AOS_Service account and then click Allow under Full Control. 12. Click OK to close the dialog box.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-37
6-38
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
> </SalesTable > </SalesOrder > </MessagePart s> </Body > </Envelope>
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-39
6-40
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
8. Build the project. 9. Press F5 to run the project. When the application has finished running, the message has been sent to the queue. The batch job retrieves the message from the queue and processes it through the inbound integration port that you created. Processing can require some time. To verify that the sales order was created, view the All sales orders form. To check for errors, view the Exceptions log.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-41
6-42
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
namespace CallMetadataService { class Program { static void Main(string[] args) { ServiceReference1.AxMetadataServiceClient client = new ServiceReference1.AxMetadataServiceClient(); try { // Gets the names of all queries in a string array. string[] queries = client.GetQueryNames(); // Loops through all the query names. foreach (string queryName in queries) { if (queryName =="AxdSalesOrder") { // Stores the name of the AxdSalesOrder query. string[] limitedNames = new string[1]; limitedNames[0] = queryName; // Writes the name of the query to the console. Console.WriteLine("Query named: {0}", queryName); // Gets the metadata for the AxdSalesOrder query. ServiceReference1.QueryMetadata[] queryMetadata = client.GetQueryMetadataByName(limitedNames); // Creates a query metadata object. ServiceReference1.QueryMetadata querySalesOrder = queryMetadata[0]; // Loops through the query data sources and writes them to the console. foreach
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-43
6-44
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
TIP: If you run the code and receive a message size exception, you might need to modify settings in the app.config file on the server and client. For more information, refer to the "Message Size Error in Troubleshooting System Services" topic in this chapter. The QueryMetadata class contains all the methods and properties for a single query. If you are working with other objects such as tables, you can access the data through the corresponding metadata object, for example, the QueryMetadata class. All of the metadata contracts are contained in the Microsoft.Dynamics.AX.Framework.Services.Metadata.Contracts namespace. TIP: A similar process is used when calling the query service or user session service. For more information and examples of calling these services, refer to the AIF System Services (http://go.microsoft.com/fwlink/?LinkID=247500&clcid=0x409 )page on MSDN.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-45
Challenge Yourself!
Use the provided information to call the user session service.
Step by Step
1. Open Visual Studio 2010 2. Click File > New > Project. 3. Select Visual C# and then select Console application. 4. In Name, type "CallUserSessionService" and then click OK. 5. In Solution Explorer, right-click References and select Add Service Reference . 6. In the Address field, enter the service's URL. For example, http://SEADEV:8101/DynamicsAx/Services/UserSessionService. 7. Click Go. In the Services tree, you should see the UserSessionService node. 8. Replace the main method in the Program.cs file with the following code.
static void Main(string[] args) { ServiceReference1.UserSessionServiceClient client = new ServiceReference1.UserSessionServiceClient(); ServiceReference1.UserSessionInfo userSessionInfo = client.GetUserSessionInfo(null); Console.WriteLine("User: " + userSessionInfo.UserId); Console.WriteLine("Language: " + userSessionInfo.AXLanguage); Console.WriteLine("Default Company: " + userSessionInfo.Company); Console.WriteLine("Company Time Zone: " + userSessionInfo.CompanyTimeZone);
6-46
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-47
6-48
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-49
3. Click Next. In the Select code generation parameters screen, the Class names default setting is based on the selected AxdLedgerJournal query. 4. Select the Read and Create service operations that the service will expose. The AxdLedgerJournal class must support reading a single journal and its entries and creating a single journal and its entries. 5. Click Next. In the Generate code screen, you can review the artifacts that will be generated and then click Generate. 6. The Completed screen displays the artifacts that the wizard created. Click Finish.
6-50
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
4. Press F5 to run the job. You will not see any message indicating that the job has completed. When you run this job, it creates a file that contains the schema for all of the fields in the document. The file location is c:\XSDSchema_AxdLedgerJournal.xml. Now that the service has been generated, your scenario might require that you add custom business logic code to the document service classes. For simplicity, consider this service implementation as complete.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-51
operation to the Selected service operations list. 8. Close the form. 9. On the Service contract customizations FastTab, select Customize documents and then click Data policies.
6-52
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-53
6-54
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Your use of
6-55
6-56
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6. Click the Ctrl+S keyboard shortcut to save changes. 7. Repeat steps 3 through 6 for the MenuItemButton:SendXMLDuplicate control.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-57
6-58
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
5. Watch the folder that you named "C:\AIF\LedgerJournalFileOUT". After a few minutes, a response file will be saved to this folder by AIF. NOTE: You can monitor the progress of your message by reviewing System Administration > Periodic > Services and Application Integration Framework > Queue manager and System Administration > Periodic > Services and Application Integration Framework > Exceptions. The selected ledger journal and its lines are serialized into XML with header information and sent to the gateway queue. When the AIF batch services run, the message will be selected from the gateway queue and sent to the "C:\AIF\LedgerJournalFileOUT" directory that you created earlier.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-59
Challenge Yourself!
Use the provided information to create a button on Fleet Management Rentals to send an XML document by using the file system adapter.
Step by Step
NOTE: Demonstrations in this section need to be performed in order, and they depend on Lab 4.1 Set up Batch in Chapter 4: Administration. 1. Open a new development workspace. 2. Open the AOT window, right-click the Queries node, and then click New Query. 3. Expand the node for the new query that is created. 4. Right-click Data Dictionary and then click Open New Window. 5. In the second AOT window, expand the Tables node and drag the FMRental table onto the Data Sources node under the new query in the first window. By default, all of the fields in the data source are included in the query. 6. Right-click the new data source and then click Properties. In the Properties sheet, rename the query data source name from FMRental_1 to FMRental. 7. Right-click Fields in the FMRental node and then click Properties.
Set the Dynamic property to Yes. This setting makes sure that all fields are returned and is required when a table participates in an inheritance relationship.
6-60
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
3. Right-click FMRentalOUT and then click Properties. 4. Click Security and then click Advanced.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-61
6-62
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
ceService), AifSendActionType::SendByKey);
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-63
10. Click the Ctrl+S keyboard shortcut to save changes. 11. In the AOT, in the FMRental table, right-click the Methods node and then click New method. 12. In the code editor, copy the following code into the new method.
void sendElectronically(XMLDocPurpose _xMLDocPurpose, AifSendMode _aifSendMode = AifSendMode::Async) { AxdSendContext axdSendContext = AxdSendContext::construct(); AifEntityKey aifEntityKey = AifEntityKey::construct(); Map keyData; AifConstraintList aifConstraintList = new AifConstraintList(); AifConstraint aifConstraint = new AifConstraint(); ; keyData = SysDictTable::getKeyData(this); aifEntityKey.parmTableId(this.TableId); aifEntityKey.parmRecId(this.RecId); aifEntityKey.parmKeyDataMap(keyData); axdSendContext.parmXMLDocPurpose(_xMLDocPurpose); axdSendContext.parmSecurity(false); ; aifConstraint.parmType(AifConstraintType::NoConstraint) aifConstraintList.addConstraint(aifConstraint) ; AifSendService::submitDefault( classn um(FMRentalServiceService), aifEntityKey, aifConstraintList, _aifSendMode, axdSendContext.pack()); }
6-64
M i c r o s o f t O f f i c i a l T r a i n i n g M a t e r i a l s f o r M i c r o s o f t D y n a m i c s
Y o u r u s e
8. In the clicked event of the Button:SendXMLDuplicate button control, change XMLDocPurpose::Original to XMLDocPurpose::Duplicate.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-65
6-66
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Summary
The hands-on labs, procedures, and demonstrations in this chapter provide additional practice and instruction to reinforce the content of previous chapters.
6-67
6-68
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
6-69
Solutions
Test Your Knowledge
1. Put the following steps in order for creating and deploying an outbound exchange: Step: 1 : Create a document query 2 : Create a service by using AIF document service wizard 5 : Add business logic to perform an outbound exchange 4 : Create an outbound port 6 : Test the exchange 3 : Create folders for the file adapter 2. What is the default URL for the user session service? () http://<Server>:8101/DynamicsAx/Services/UserSessionServic e ( ) http://<Server>/DynamicsAx/Services/UserSessionService () http://<Server>:2700/DynamicsAx/Services/UserSessionServic e 3. Which adapter uses the Use default owner for Administrators group parameter? ( ) NetTcp () File System Adapter () MSMQ ( ) HTTP 4. When you add a service reference, what field in the Inbound Port form should be reference? () WSDL URI ( ) Name ( ) Adapter ( ) URI
6-70
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Introduction
Troubleshooting and logging provides the following benefits: Developers can create more robust integrations Administrators can ensure that integrations function properly Resolving issues with integrations Services and AIF in Microsoft Dynamics AX 2012 introduces several capabilities to improve the troubleshooting and logging experience. Correlate exceptions ports and messages in the exception log Flexible error handling for large imports Support for batched messaging Troubleshooting options are moved to integration ports Debug services by using Microsoft Visual Studio 2010
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-1
Batched Messaging
When batched messages are processed, error handling is determined by the configuration of the integration port. The Processing options FastTab setting determines how errors are managed during batch processing. In the Upon error in batched requests: field, select one of the following values: Continue continue processing messages after an error is encountered. Messages that cause errors might not be processed correctly. These messages remain in the gateway queue. Messages that do not cause errors continue to be processed and then they generate responses, if responses are appropriate. Check the exceptions log for detailed information about the messages that caused errors. Halt stop processing the rest of the messages in the batch after an error is encountered. The rest of the messages, along with the message that caused the error, remain in the gateway queue in the appropriate state. Check the exceptions log for detailed information about the error that interrupted the message processing. No more messages from the batch are processed. Messages that have been processed will generate responses, if responses are appropriate, and any resulting changes are committed to the database. Rollback stop processing the batched messages and undo any previously processed messages from the batch that contain the message that caused the error. All messages remain in the gateway queue in the appropriate state. Note that conversation IDs are not related to the settings for error handling on the integration port.
7-2
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Respond after error in asynchronous request For inbound integration ports, select this check box to specify that the port automatically sends error messages as responses in asynchronous scenarios.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-3
7-4
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-5
7-6
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-7
Exceptions Log
The exceptions log contains a record of all errors that occur during document exchanges in Application Integration Framework (AIF). In the Exceptions form, you can view information about the module and subsystem where the error occurred and a description of the error. You can also view information about when the error was logged, the user who is associated with the error, and the form or business logic where the error occurred.
2. On the Overview tab, select an exception record. 3. Click the General tab to view additional details about the exception.
7-8
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-9
Troubleshooting
The primary methods of troubleshooting Services and AIF are debugging and reviewing exception logs. This lesson provides instructions on debugging by using error logs.
Debugging Services
In Microsoft Dynamics AX, an example of a service is an X++ class that you can expose as a service by adding attributes to the class and its methods. Services that you create in Microsoft Dynamics AX are compiled into CIL and run on the server. Therefore, you must use the Visual Studio debugger to debug them. While developing a service class in X++, you can use the Microsoft Dynamics AX debugger to debug the functionality. Use Visual Studio to debug the code that calls the service. The following is the high-level process for debugging a service in Visual Studio: 1. In Visual Studio, open the project that calls the Microsoft Dynamics AX service. 2. In Application Explorer, locate the service operation that you are calling and then open the source code. 3. Set a breakpoint in the service code. 4. Attach the Visual Studio debugger to the Microsoft Dynamics AX server process (Ax32Serv.exe). 5. Press F5 to run the project. When the debugger reaches a breakpoint in the service, it will stop and you can then go through the service code. TIP: When debugging a service in Visual Studio, you cannot change the source code in the Visual Studio IDE. You must make the changes in X+ + and then deploy the integration port to regenerate the service .xpp files.
4. Click Start > All Programs > Microsoft Visual Studio 2010 > Microsoft Visual Studio 2010. 5. In Microsoft Visual Studio 2010, click File > New Project. 6. Select the Visual C# template.
7-10
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
NOTE: Leave this project open for the "Debugging Services" demonstration.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-11
7-12
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Warning message: An error occurred while creating AifWebsites entry or Error message: Cannot create a record in Web sites (AifWebsites) Cannot access a web service
Your use of
7-13
Open error in batched requests setting does not work Cannot add a new transform in the Manage transforms Transforms do not work with synchronous adapters
7-14
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Service operation getChangedKeys returns no entity keys Error message: The open operation did not complete within the allotted timeout
Files that have filename extensions other than .xml do not work for outbound exchanges
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-15
Challenge Yourself!
Use the provided information to debug a service.
Step by Step
NOTE: Lab 7.1: Debugging services has the same instructions as the Lesson: Troubleshooting demonstrations. 1. Open Microsoft Dynamics AX 2012. 2. Go to System administration > Setup > Services and Application Integration Framework > Inbound ports. 3. Select "LedgerServices" and then click Activate. 4. Click Start > All Programs > Microsoft Visual Studio 2010 > Microsoft Visual Studio 2010. 5. In Microsoft Visual Studio 2010, click File > New Project. 6. Select Console Application, enter a name for the project, and then click OK. 7. In Solution Explorer right-click references and then click Add service reference.
7-16
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
11. In Visual Studio, click View > Application Explorer. 12. In Application Explorer double-click Default > Classes > AxInternalBase > Save. 13. In AxInternalBase.save.xpp right-click on the line public void save() and then click Breakpoint > Insert Breakpoint. 14. Click Tools > Attach to Process. 15. Select Show processes from all users and then select Show processes in all sessions.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-17
7-18
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
Summary
Troubleshooting Service and AIF in Microsoft Dynamics AX 2012 accommodates the refactor of services and enhanced capabilities. The troubleshooting capabilities in Services and AIF include: Correlating exceptions, ports, and messages in the exception log Providing error handling options for large imports Handling batched messaging Moving troubleshooting options to integration ports Providing a view into document history Providing a view to monitor documents in the queue Providing a way to view exceptions Debugging services by using Visual Studio 2010
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-19
2. How is Visual Studio connected to Microsoft Dynamics AX 2012 to debug services? ( ) Automatically ( ) Attaching to Ax32.exe ( ) Attaching to Ax32Serv.exe ( ) Services are debugged by using the Microsoft Dynamics AX 2012 debugger 3. Which exchanges are affected by batch jobs that do not run? ( ) Adapter-based exchanges ( ) Web service exchanges
7-20
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
2.
3.
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement
7-21
Solutions
Test Your Knowledge
1. Categorize the following items: d 1. Flexible error handling for large imports a 2. Correlate exceptions, ports, and messages in the exception log b 3. Document history e 4. Queue manager c 5. Exception log a. You can view information about the related port, message, and message set on the Exceptions form. b. Stores documents that are exchanged by using Application Integration Framework (AIF) and shows documents that are related to data in the Microsoft Dynamics AX database. c. A record of all errors that occur during document exchanges in Application Integration Framework (AIF). d. When large files are imported, error handling provides flexible options, such as continue, halt, and rollback. e. Displays information about messages in the Application Integration Framework (AIF) queues.
2. How is Visual Studio connected to Microsoft Dynamics AX 2012 to debug services? ( ) Automatically ( ) Attaching to Ax32.exe () Attaching to Ax32Serv.exe ( ) Services are debugged by using the Microsoft Dynamics AX 2012 debugger 3. Which exchanges are affected by batch jobs that do not run? () Adapter-based exchanges ( ) Web service exchanges
7-22
Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement