Webservice WSDL Document Consumption in ColdFusion
This question was posted on the Adobe ColdFusion forums (found here at http://forums.adobe.com/thread/546708?tstart=0).
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!
The issue was in understanding how to read a raw WSDL (Web Service Description Language) document. I’ll be the first to admit that these can be a bit daunting, but after you know a little about how they are typically structured, you can surmise what methods and their arguments are available to you.
The WSDL in question can be found here at http://www.webservicex.net/CurrencyConvertor.asmx?WSDL. Go ahead and open that and take a look. The first thing we can see about this document is at the top with the
To be certain you want to find
The reason for three methods with the same operation name becomes more apparent when we go down and examine the
Ok, that’s cool. So we know what methods are available, but how do we know what arguments to pass to these methods? Let’s take a look at the SOAP method version of “ConversionRate”. At the bottom of that definition you will see
In this method the
The “ConversionRate” element is a complex type, which is a sequence of arguments. There are two actually: FromCurrency, and ToCurrency. Sweet, there are our arguments. Notice also that their type is “tns:Currency”. That is actually just below this element and looks like “
Great, so that’s a lot of work. Welcome to the world of Web Services! Now let’s look at a small snippet of ColdFusion code that actually uses this service!
1 2 3 4 5 6 7 | <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#" /> |
Woah, that was easy! Just create the object as a type of “webservice”, give it the URL to the WSDL, and call the method “ConversionRate” and pass in two strings. Here we are getting the conversion rate from Australia currency to American USD.
I hope this sheds a LITTLE light on the loveliness that is WSDL documents. Happy coding!





Nope. Still extremely confused, perhaps more-so now.