Consuming CurrencyConverter web service through JavaScript

Hi,

For getting the currency conversion rate we could use the following web service provided by Generic Objects Technologies Ltd.

Check out the web services provided by them

http://www.webservicex.net/WCF/webServices.aspx

To consume their currency converter web service

http://www.webservicex.net/CurrencyConvertor.asmx we could use the following JavaScript code

var xmlHttp;
function SoapCall() {
// creatng the xmlHttp object
xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
// Calling the web service using post and true means asynchronous call
xmlHttp.open(“post”, “http://www.webservicex.net/CurrencyConvertor.asmx”, false);
// Setting the request header to let the web service identify the soap request we would be sending

xmlHttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);

xmlHttp.setRequestHeader(“SOAPAction”, “http://www.webserviceX.NET/ConversionRate”);

var soapRequest = “<?xml version=’1.0′ encoding=’utf-8′?> ” +
“<soap12:Envelope xmlns:xsi=’http://www.w3.org/2001/XMLSchema-instance&#8217; xmlns:xsd=’http://www.w3.org/2001/XMLSchema&#8217; xmlns:soap12=’http://www.w3.org/2003/05/soap-envelope’>&#8221; +
” <soap12:Body>” +
”   <ConversionRate xmlns=’http://www.webserviceX.NET/’>&#8221; +
”     <FromCurrency>USD</FromCurrency>” +
”    <ToCurrency>INR</ToCurrency>” +
”  </ConversionRate>” +
“</soap12:Body>” +
“</soap12:Envelope>”;

xmlHttp.send(soapRequest);
alert(xmlHttp.responseText);

}


Bye..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

3 thoughts on “Consuming CurrencyConverter web service through JavaScript”

  1. Hello Rana,

    Nice tuto, by the way, could you post your source code (I mean .zip) because I found some problems of copying/paste from the web page (due to the simple quotes ”, etc…. ).

    Thank you!

    Like

  2. hi nishant,

    How would i use that currency converter in mscrm 4.0 as i need to know. can u guide please…where to , how to start……

    Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s