Skip to main content
Inspiring
December 29, 2009
Answered

Currency Converter

  • December 29, 2009
  • 2 replies
  • 3981 views

Does anyone know of a service for this compatible with CF? I need to display an amount for Korean Won and USD on a checkout form and the service at http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl doesn't exist anymore. I searched Google for a while but didn't find much.

Thanks!

David

    This topic has been closed for replies.
    Correct answer AdamPresley

    According to the WSDL, if I'm reading it correctly, there is one method exposed, called ConversionRate. It takes two arguments, both strings. The first is the currency code to convert FROM, and the second is the currenct code to convert TO. The result is a numeric value of the conversion rate. Here's a sample of how to use it.

    <cfset service = createObject("webservice", "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL") />

    <cfset fromCurrency = "AUD" />
    <cfset toCurrency = "USD" />
       
    <cfset result = service.ConversionRate(fromCurrency, toCurrency) />
    <cfdump var="#result#" />

    2 replies

    AdamPresley
    Participating Frequently
    December 30, 2009

    I did find a thread on House of Fusion that has a few links and discussion about this. http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32098

    InkfastAuthor
    Inspiring
    December 30, 2009

    That's the one I got the example from that Dan questioned. It points to the xmethod service that no longer exists. My problem is I have to show these guys what they're paying in Won which I have but for the payment through Authorize.Net I have to convert it to US$ first. This should be easy but unfortunately I'm not that good at understanding the WSDL file.

    AdamPresley
    AdamPresleyCorrect answer
    Participating Frequently
    December 30, 2009

    According to the WSDL, if I'm reading it correctly, there is one method exposed, called ConversionRate. It takes two arguments, both strings. The first is the currency code to convert FROM, and the second is the currenct code to convert TO. The result is a numeric value of the conversion rate. Here's a sample of how to use it.

    <cfset service = createObject("webservice", "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL") />

    <cfset fromCurrency = "AUD" />
    <cfset toCurrency = "USD" />
       
    <cfset result = service.ConversionRate(fromCurrency, toCurrency) />
    <cfdump var="#result#" />

    ilssac
    Inspiring
    December 29, 2009

    The first result I got from a Google search for "Currency Converter Web Service" was:

    http://www.webservicex.net/CurrencyConvertor.asmx?WSDL

    http://www.webservicex.net/WS/WSDetails.aspx?WSID=10

    Any webservice you find should be compitable with ColdFusion.

    InkfastAuthor
    Inspiring
    December 30, 2009

    I tried this from an example I found but all I'm getting is java errors. May be the server itself.

    <CFINVOKE WEBSERVICE="http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"
    METHOD="getRate"
    RETURNVARIABLE="myRate">
    <CFINVOKEARGUMENT NAME="country1" VALUE="EUR"/>
    <CFINVOKEARGUMENT NAME="country2" VALUE="USD"/>
    </CFINVOKE>
    <cfoutput>DollarsPerEuro Rate: #myRate#</cfoutput>

    Error:

    coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler:  Found 2 system errors:  *** Error: Could not find package "java/util" in:                 /web/coldfusion/runtime/jre/lib/ext/sunpkcs11.jar                 /web/coldfusion/runtime/jre/lib/ext/sunjce_provider.jar                 /web/coldfusion/runtime/jre/lib/ext/localedata.jar                 /web/coldfusion/runtime/jre/lib/ext/dnsns.jar                 /web/coldfusion/wwwroot/WEB-INF/classes                 /web/coldfusion/wwwroot/WEB-INF/lib/cfmx_bootstrap.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/cfx.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/commons-beanutils.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/commons-collections.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/js.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/mysql-connector-java-3.1.14-bin.jar                 /web/coldfusion/wwwroot/WEB-INF/lib/mysql-connector-java-5.0.4-bin.jar                 /web/conf/cluster/coldfusion/lib/updates/hf702-1875.jar                 /web/conf/cluster/coldf....

    Inspiring
    December 30, 2009

    How did you come up with

    METHOD="getRate"
    and
    <CFINVOKEARGUMENT NAME="country1" VALUE="EUR"/>
    <CFINVOKEARGUMENT NAME="country2" VALUE="USD"/>

    ?

    I didn't see any of that stuff in the wsdl file.