Reader small image

You're reading from  Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition

Product typeBook
Published inMar 2020
PublisherPackt
ISBN-139781838643812
Edition2nd Edition
Right arrow
Author (1)
Simon Buxton
Simon Buxton
author image
Simon Buxton

Simon Buxton has worked with Dynamics 365 Finance and Supply Chain Management since its earliest incarnations, starting with the product in early 1999 when Dynamics 365 Finance and Supply Chain Management was known as Damgaard Axapta 1.5. Simon has been the technical lead on many highly challenging technical projects in countries all around the world. These projects included complex integrations with on-premises and external systems, ISV solutions, and many technically challenging customer solutions. Now working with Binary, he was part of a team that implemented the first Dynamics 365 Finance and Supply Chain Management implementation as part of the Community Technical Preview (CTP) program, which led to the close working relationship with Microsoft that made this book possible
Read more about Simon Buxton

Right arrow

Consuming and Exposing Services

This chapter focuses on how to create services in SCM and how to consume them in external applications. This does not include OData services, which were covered in Chapter 10, Data Management, OData, and Office.

The creation of services within SCM is relatively straightforward and intuitive. This is a benefit of the patterns we used when writing code; for example, the code that was written to use the SysOpearation framework has a controller that constructs a data contract and a class to process that data contract. The decoupled nature of the development patterns that are used in SCM lends itself very well to the creation of services.

SCM is a cloud-first solution, which means we need to consider security. When accessing an SCM service, we also need to ensure that the consumer has access to SCM and has permission to access that web service. Even...

Creating a service

There are three parts to creating a new service:

  • Creating a class that contains the business logic
  • Creating a service that has operations that reference operations to the class's methods
  • Creating a service group

The service group is a collection of one or more services and acts as the service reference, should we consume it within Visual Studio. We will see how this translates to a Uniform Resource Identifier (URI) in the next recipe.

In this example, we will have two service operations: one to get a list of vehicles, and one to update a vehicle's group. The XML documentation has been omitted to save space.

Getting ready

We will just need a Dynamics 365 for Finance & Operations Visual Studio...

Consuming a SOAP service in an external application

In this recipe, we will create a new C# project to consume the service we created in the previous recipe.

Before we start, we should understand the Azure AD authentication concepts we explained in the Reading, writing, and updating data through OData recipe in Chapter 10, Data Management, Odata, and Office. Many of the concepts in the following recipes extend the concepts we covered in this chapter. In this example, we will create a SOAP service reference.

Getting ready

This is a continuation of the Creating a service recipe, so it must be completed before we can continue.

How...

Consuming a JSON service in an external application

In this recipe, we will extend the previous C# project to consume the service using JSON.

The primary difference is that JSON will not create the contract and client classes for us; we will need to write them ourselves. We will use a NuGet package to help with the serialization and deserialization of C# classes to JSON.

Getting ready

This recipe is a continuation of the Consuming a SOAP service in an external application recipe, which must be completed before we can continue. This recipe builds on the existing ConServiceTest C# project that we created in the previous recipe.

How...

Consuming an external service within F&O

This technique hasn't changed substantially since Dynamics AX 2012. The key difference is that we will need to manually craft the binding. We still need to create a C# project to consume the web service, and then use it as a reference within our F&O project.

The example service is a weather service provided by Open Weather (https://openweathermap.org/). There is no recommendation here. It was simply the first one I found when I searched for weather web services. The aim is to create a recipe that you can use for your web services. The chosen service, in this case, isn't relevant.

When selecting a service to use, we must check the license terms and conditions since not all of them are free to use. Just because the license terms aren't enforced doesn't mean that the service is free to use.
...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition
Published in: Mar 2020Publisher: PacktISBN-13: 9781838643812
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Simon Buxton

Simon Buxton has worked with Dynamics 365 Finance and Supply Chain Management since its earliest incarnations, starting with the product in early 1999 when Dynamics 365 Finance and Supply Chain Management was known as Damgaard Axapta 1.5. Simon has been the technical lead on many highly challenging technical projects in countries all around the world. These projects included complex integrations with on-premises and external systems, ISV solutions, and many technically challenging customer solutions. Now working with Binary, he was part of a team that implemented the first Dynamics 365 Finance and Supply Chain Management implementation as part of the Community Technical Preview (CTP) program, which led to the close working relationship with Microsoft that made this book possible
Read more about Simon Buxton