Monday, September 11, 2017

Consuming External Web services(WSDL link) in Dynamics 365 for finance and operations

//Consuming External Web services in Dynamics 365 for finance and operations

//Sample WSDL URL
http://currencyconverter.kowabunga.net/converter.asmx

//Create new project
//Create new class libarary and names as SSLExternalWebservices

//Add a service reference under the References in newly created project.
/Use above sample WSDL service

Named as SSLCurrencyConverterServices

//Write in class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SSLExternalWebServices.SSLCurrencyConverterService;
using System.ServiceModel;
//class name currencyConverter
public string getCurrencyRate(String cur1, string cur2)
{
BasicHttpBinding httpBinding = new BasicHttpBinding();
EndpointAddress endPoint = new EndpointAddress(@"http://currencyconverter.kowabunga.net/converter.asmx");
var soapClient = new ConverterSoapClient(httpBinding,endPoint);
var usdToinr = soapClient.GetConversionRate(cur1.ToString(), cur2.ToString(),DateTime.Now);
return usdToinr.ToString();
}

//Add a new Operation Project in your solution Name it SSLExternalWebServiceDAX.
//In the Reference node, right-click and add a new reference. You can choose the
  project and it will add the dll file automatically in the reference node.(SSLExternalWebservices)

//Add a runnable class in your Operation Project, name it SSLConsumeServiceInDAX, and add a namespace of
using SSLExternalWebServices;


Public static void Main(Args _args)
SSLExternalWebServices.currencyConverter currencyCoverter = new SSLExternalWebServices.currencyConverter();
var convRate = str2Num(currencyCoverter.getCurrencyRate("USD","INR"));
info(strFmt("%1", convRate));
}

//Save all your code and build the solution. Set this project SSLExternalWebServiceInDAX
//As a startup project and class SSLConsumeServiceInDAX

//Run a solution and Test it now

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...