27
© 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.

Creating and Consuming Web Services in Dynamics AX 2012

Embed Size (px)

DESCRIPTION

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.

Citation preview

Page 1: 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.

Page 2: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 3: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 4: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 5: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Creating a new

Service Group

Just create a new Service Group…

Page 6: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Creating a new

Service Group

Give it a name…

Page 7: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 8: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 9: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Deploy Your Service

Done.

Page 10: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 11: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Your New Service

Browsing to the WSDL will show you all of the interfaces for the service.

Page 12: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 13: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Consuming the

Service

For this example, the application will be an Excel Add In for importing sales orders.

Page 14: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 15: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 16: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Consuming the

Service

Once discovered, the project will grow a little…

Page 17: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 18: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Consuming the

Service

And we will add two buttons to the add in for setting up and importing the data.

Page 19: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 20: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 21: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 22: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 23: Creating and Consuming Web Services in Dynamics AX 2012

© 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.

Page 24: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Running The Excel

Import Add-In

Add some data to the spreadsheet, and then press the Import button.

Page 25: Creating and Consuming Web Services in Dynamics AX 2012

© 2012. All rights reserved.

Running The Excel

Import Add-In

Now all of the orders are in Dynamics.

That was easy.

Page 26: Creating and Consuming Web Services in Dynamics AX 2012

About

Murray Fife

Page 27: Creating and Consuming Web Services in Dynamics AX 2012