Mar 1
Using CFINVOKE to fetch data from a webservice isn’t so difficult, though the free services can be a bit laggy or suffer downtime. For this example, I pull the currency exchange rate from the webservice on a schedule so I can store it in a database. I pull it from the database as needed, so it’s always fast and reliable.
Here’s an example of consuming the service. In this example, I’m using the Currency Convertor over at webservicex.net.
<cfinvoke webservice = "http://www.webservicex.net/CurrencyConvertor.asmx?wsdl" method = "ConversionRate" FromCurrency = "USD" ToCurrency = "EUR" returnVariable = "USD2EUR" />
I always like to wrap my webservices in a CFTRY so I can log any failures in the CFCATCH.
Pretty easy, eh? Do you have a favorite webservice that you like to consume? I should probably give another example at a later date for the weather, as I’m always having to look that one up again.
Jun 28, 2010 at 11:26 AM Hello, I'm writing from Montreal. Can I ask you how to implement this code? Let's say I provide pricing in Canadian Dollars and the client wants to be able to change the currency the pricing is displayed. Can I apply this? Thank you!
Jul 13, 2010 at 1:33 PM Thanks for the code. I was able to understand how a web service work and how to implement it. Thanks for this.