Consuming Web Services
When a client makes a request to a web
service, it is said to be a consumer of that service. ColdFusion MX
makes consuming web services simple. There are three ways to consume
a web service in ColdFusion MX. You can use the
cfinvoke
tag, the cfobject
tag,
or the createObject( )
function.
It’s also possible to use the
cfhttp
tag to manually consume a web service.
Because of the complexity involved with that method,
I’m going to limit my coverage to the first three
methods.
In many cases, you don’t need to know anything about the web service you want to consume other than the URL of its WSDL file. This is especially true if you use Dreamweaver MX to develop your ColdFusion MX applications. Generating the necessary CFML code to consume a web service using Dreamweaver MX is literally a point and click process:
Open the Components tab under the Application panel.
Choose Web Services from the dropdown box in the Components tab.
Click the plus (+) button next to the dropdown box where you selected Web Services. This opens the Add Using WSDL dialog box.
Enter the URL to the desired WSDL file and click OK.
Dreamweaver MX automatically generates a proxy for the web service and makes it available in the Components tab. From here, you can expand the proxy to show the web service’s fields, methods, and properties as defined by the WSDL file.
If you don’t use Dreamweaver MX, that’s okay too. You can visually inspect a WSDL file by entering its URL into your web browser. ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.