|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Currency Conversion web service
Has anyone managed to consume a Currency Conversion web service under CFMXMichael Kear 03/29/04 06:06 A > Has anyone managed to consume a Currency Conversion webTim Blair 03/29/04 08:46 A Has anyone managed to consume a Currency Conversion web service under CFMX yet? Before you all send me listings of xmethods currency converters, I've looked at them all and none of them work under CF without a lot of stuffing about. Other people have apparently got a currency conversion working because of the number of people who told me there was nothing to it. Back in February this year, I spent nearly two days messing about trying to make it work and eventually gave up, putting the issue on the back of the queue until it came up to the top of the pile again. Now it's come back up. For those who missed it, back in February, Tom Jordahl from Team Macromedia said the following back then, which I never managed to make work. (I assume because I didn't follow his instructions or something but I decided there were easier things to do and gave up): [QUOTING Tom Jordahl] Mike, Yes, enumeration is the problem here. I have fixed this, and I am working to try and get this fix available to customers. I apologize for this bug. No test for a situation means it doesn't work. Now we have an enumeration test. :-) In the mean time, try this workaround: <cfscript> ws = CreateObject("webservice", http://www.webservicex.net/CurrencyConvertor.asmx?wsdl <http://www.webservicex.net/CurrencyConvertor.asmx?wsdl> ); enum = CreateObject("java", "NET.webserviceX.www.Currency"); argFrom = enum.fromString("GBP"); argTo = enum.fromString("USD"); result = ws.ConversionRate(argFrom, argTo); </cfscript> The above workaround has one tricky problem however; you will need to copy the class NET.webserviceX.www.Currency to a directory on the ColdFusion classpath. I suggest C:\CFusionMX\wwwroot\WEB-INF\classes (adjust to your installation directory). Here is how to do that: 1. Run this page at least once and get the Class Not Found error. 2. Go to the CFusionMX/stubs directory and find the WS-???????? directory that has the NET sub directory. 3. Copy the NET directory to wwwroot/WEB-INF/class. 4. Delete all the .class files in the NET/webserviceX.www directory EXCEPT Currency.class. Sean Cornfield originally brought the issue up tome because of a thread on CFGURU . Here is his web log posting on how to debug these issues: http://www.corfield.org/blog/past/2004_01.html#000252 <http://www.corfield.org/blog/past/2004_01.html#000252> [/END QUOTE] I tried that, and I have about a dozen NET directories, with references to currency conversion there, and moving one after the other still meant I got error messages. All I want to do is convert currency values on the fly when a user puts his preferred currency in the session vars, so all prices display on the page in his chosen currency. Cheers Mike Kear AFP Webworks Windsor, NSW, Australia http://afpwebworks.com > Has anyone managed to consume a Currency Conversion web > service under CFMX yet? Don't know if it'll help, but... We don't need totally up to date currency information so I have a scheduled task to run twice a day and, using an xMethods web service, update our local copy of the rates we use. Then when a conversion is required (all are "from" GBP) we do the calculation locally. Basic code below to call the webservice: <!--- set where we're starting from ---> <cfset local = "uk"> <!--- and the list of currencies to retrieve ---> <cfset countrykeys = structnew()> <cfset countrykeys["US"] = "us"> <cfset countrykeys["FR"] = "euro"> <cfset countrykeys["ES"] = "euro"> <cfset countrykeys["IE"] = "euro"> <cfset countrykeys["JP"] = "japan"> <cfset countrykeys["CA"] = "canada"> <cfset countrykeys["AU"] = "australia"> <!--- get the service stub ---> <cfset wsrate = createobject("webservice", "http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl")> <!--- loop through each country ---> <cfloop collection="#countrykeys#" item="key"> <!--- get the new ex rate ---> <cfset exrate = wsrate.getRate(local, countrykeys[key])> <!--- output the new values ---> <cfoutput>#key# (#countrykeys[key]#) = #exrate#<br></cfoutput> <!--- 1 by 1 ---> <cfflush> </cfloop> Tim. -- ------------------------------------------------------- <CF_CodingContest mode="judging" newentries="false"> Maze Solver - http://tech.badpen.com/cfcontest/ ------------------------------------------------------- RAWNET LTD - Internet, New Media and ebusiness Gurus. WE'VE MOVED - for our new address, please visit our website at http://www.rawnet.com/ or call us any time on 0800 294 24 24. ------------------------------------------------------- This message may contain information which is legally privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. -------------------------------------------------------
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||