Consume an external web service (exchange rates) in AX 2009


During my career I have never had the opportunity to write X++ code that consumes an external web services…

I am trying to get exchange rates from the Swedish Riksbank (the central bank of Sweden) through their web service API (…/index.htm ).

I add a service reference in AX and enters the URL to the wsdl location (…/sweaWS.wsdl ). Then I create a class with a method which looks something like this:

public static server Exchrate getRate()
netCurrencyService.SweaWebServicePortTypeClient soapClient;
ExchRate conversionrate;
str rates[2];


new InteropPermission(InteropKind::ClrInterop).assert();

soapClient = new netCurrencyService.SweaWebServicePortTypeClient();

rates[1] = “SEKUSDPMI”;
rates[2] = “SEKGBPPMI”;

conversionrate = soapClient.getLatestInterestAndExchangeRates(“en”, rates);

return conversionrate;

throw error(AifUtil::getClrErrorMessage());


My problem is that the code does not compile. The call “soapClient.getLatestInterestAndExchangeRates(“en”, rates)” indicates that argument 2 (“rates”) is incorrect. If I enter a string instead the compiler says that the class netCurrencyService.SweaWebServicePortTypeClient doesn’t include this function (“getLatestInterestAndExchangeRates”?).

Any suggestions?