Cart 0

Creating & Consuming Web Services with Excel

Posted by Author, Curator, Visually Impared Squirrel Literacy Advocate & Dynamics AX Technical Solution Professional (TSP) at Microsoft on

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.
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.
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
Just create a new Service Group…
Give it a name…
Adding 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.
Deploying Your Service
Now deploy the service. This will create the web service for you and allow you to access the service and WSDL information.
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.
Browsing to the WSDL will show you all of the interfaces for the service.
Consuming the Service In Excel
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.
For this example, the application will be an Excel Add In for importing sales orders.
Before we create the application, we will add the web service into the application as a Service Reference.
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.
Once discovered, the project will grow a little…
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.
And we will add two buttons to the add-in for setting up and importing the data.
The setup option is pretty simple. It will just add the field headings so that we know the different fields that are required.
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.
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.
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.
Just click on the Setup button, and it will tell you the format and the fields that you need to fill in.
Add some data to the spreadsheet, and then press the Import button.
Now all of the orders are in Dynamics.
That was easy.
Link to Original:

Share this post

← Older Post Newer Post →

Leave a comment

Please note, comments must be approved before they are published.