Creating and Consuming Web Services in Dynamics AX 2012
-
Upload
murray-fife -
Category
Documents
-
view
7.327 -
download
19
description
Transcript of Creating and Consuming Web Services in Dynamics AX 2012
© 2012. All rights reserved.
CREATING & CONSUMING WEB SERVICES
WITH EXCEL
Dynamics AX 2012 | Web Services | Excel | Office Interoperability
There are a whole slew of web services available in Dynamics AX 2012, but how do you use them?
In this example we will show how you can publish the web services so that you can use them in an application, and also show an example of the web services in action by using them to create a simple sales order import routine from Excel.
© 2012. All rights reserved.
Introduction
Services and
Application
Integration
Framework
With Dynamics AX 2012, the creation and management of the web services have been greatly simplified.
In the System Administration area page, you will find a section for the “Services and Application Integration Framework” which allows you to create web services on the fly from the service templates that are delivered with the standard product.
© 2012. All rights reserved.
Introduction
to Services and
Application
Integration
Framework
In here you will see all of the default web services that are published with the system.
All we need to do is define our own services.
© 2012. All rights reserved.
Creating a new
Service Group
All of the services are set up in AOT. If you browse through the application, you will see all of the services that were in the IAF section of the System Configuration.
© 2012. All rights reserved.
Creating a new
Service Group
Just create a new Service Group…
© 2012. All rights reserved.
Creating a new
Service Group
Give it a name…
© 2012. All rights reserved.
Add Your Service
Now drag the service that you want to publish from the Services section into your Services Group.
In this case we will use the SalesSalesOrderService, which will allow us to access all of the properties and methods for Sales Order Management.
© 2012. All rights reserved.
Deploy Your Service
Now deploy the service. This will create the web service for you and allow you to access the service and WSDL information.
© 2012. All rights reserved.
Deploy Your Service
Done.
© 2012. All rights reserved.
Your New Service
Now if you look in the Application Integration section again, you will find that your service is available.
If you look at the properties of the service, then you will find the location of the service WSDL as well.
© 2012. All rights reserved.
Your New Service
Browsing to the WSDL will show you all of the interfaces for the service.
© 2012. All rights reserved.
Consuming the
Service
Now that you have the service we will be able to create an application that consumes the service and does something with it.
To do this we will use Visual Studio and create an app.
© 2012. All rights reserved.
Consuming the
Service
For this example, the application will be an Excel Add In for importing sales orders.
© 2012. All rights reserved.
Consuming the
Service
Before we create the application, we will add the web service into the application as a Service Reference.
© 2012. All rights reserved.
Consuming the
Service
All you need to do to add the service is to give the Service Discovery form the location of the WSDL that Dynamics created for us in the prior section, and it will discover the published services.
© 2012. All rights reserved.
Consuming the
Service
Once discovered, the project will grow a little…
© 2012. All rights reserved.
Consuming the
Service
To make the interface a little nicer, we will add the buttons for the application as a Ribbon Bar add-in, so just add one of those to the project.
© 2012. All rights reserved.
Consuming the
Service
And we will add two buttons to the add in for setting up and importing the data.
© 2012. All rights reserved.
Consuming the
Service
The setup option is pretty simple. It will just add the field headings so that we know the different fields that are required.
© 2012. All rights reserved.
Consuming the
Service
To use the web service in the code, make sure that you add the reference to the service in the header so that we are able to access all of the intellisense and objects for the service.
© 2012. All rights reserved.
Consuming the
Service
And then with a little bit of code, we are able to step through the rows, and create the sales orders through the standard API’s in Dynamics.
© 2012. All rights reserved.
Running The Excel
Import Add-In
Now when you run Excel, a new tab shows up in the ribbon bar for setting up your spreadsheet and also importing the data into Dynamics.
© 2012. All rights reserved.
Running The Excel
Import Add-In
Just click on the Setup button, and it will tell you the format and the fields that you need to fill in.
© 2012. All rights reserved.
Running The Excel
Import Add-In
Add some data to the spreadsheet, and then press the Import button.
© 2012. All rights reserved.
Running The Excel
Import Add-In
Now all of the orders are in Dynamics.
That was easy.
About
Murray Fife