Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
Community interest groups have now moved from Yammer to Microsoft Viva Engage. To join a Viva Engage community and take part in the latest discussions, fill out the Request access to Finance and Operations Viva Engage Community form and choose the community you want to join.
Consume web services by adding new class libraries. In Microsoft Dynamics AX 2012, you could consume web services from X++ code by adding Microsoft Visual Studio projects as a reference and by using Aif::CreateServiceClient. This scenario is supported, but the steps changed. Application Integration Framework (AIF) is no longer supported.
The following steps show how to consume an external StockQuote service from X++.
The web service URL in this sample is fictional. No known web service exists at http://www.contoso.net/stockquote.asmx. To make this code work you need to adapt it to your specific web service.
Create a new Class Library project in Visual Studio, and name it ExternalServiceLibrary.csproj.
In the Visual Studio project, add a service reference to the external web service:
http://www.contoso.net/stockquote.asmx.Create a new static class, and wrap the StockQuote service operation as shown in the following example.
public static string GetQuote(string s) { var binding = new System.ServiceModel.BasicHttpBinding(); var endpointAddress = new EndpointAddress("http://www.contoso.net/stockquote.asmx"); ServiceLibrary.QuoteReference.StockQuoteSoapClient client = new ServiceLibrary.QuoteReference.StockQuoteSoapClient(binding, endpointAddress); //GetQuote is the operation on the StockQuote service return client.GetQuote("MSFT"); }Build the project. The binary ExternalServiceLibrary.dll is created.
Create a new Dynamics project in Visual Studio.
Add ExternalServiceLibrary.dll as a reference.
In the X++ class, use the external web services that are referenced in ExternalServiceLibrary.dll.
public static void main(Args _args) { info(ServiceLibrary.StockQuoteClass::GetQuote("MSFT")); }