Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

ColdFusion MX Overview – Web Services

Page 7 — Web Services

If you are a Web developer and you haven’t heard the buzz phrase “Web services” yet, you must be living in a hole somewhere. I have a feeling, though, that there are too many developers who don’t have a good handle on exactly what a Web service is. I’d even bet that there are developers out there who are spending time writing things by hand that can be done more easily with Web services.

I’ll cut to the chase — a Web service simply allows your stuff to talk to and work with other stuff that’s out there on the Internet. By stuff I mean Web applications, other programming languages, software — almost anything. For example, if your ColdFusion application needs to be able to provide functionality to somebody else’s .NET application, or vice versa, there won’t be any problems because both systems can communicate via Web services.

It’s interesting to know that you may have already created code that works like a Web service and not even have realized it. For example, have you ever built a custom routine that does a <CFHTTP> request to some other site, fetches some information, and returns it into your system for you to use? I’ve seen custom tags that will scrape stock quotes for you via <CFHTTP>. One of the problems with using <CFHTTP> in this way is that you typically have to write custom routines that parse through HTML to find data. Once the HTML design changes on the site you are scraping from, your code bombs.

A bigger issue that arose in ColdFusion 5 was the dilemma of how to exchange information with other backend systems. For example, how would you provide query results from your ColdFusion system to another system? Furthermore, how would you provide some of your application’s functionality with another application? Although this was technically possible before CFMX via other means, you would have had to jump through some pretty big hoops to get it done.

When dealing with Web services, the two related terms you’ll hear about are “expose” and “consume”. In a nutshell, Web services provide a language-independent way for you to share (expose) functionality or data on your system, or to use (consume) functionality and data in other systems. Sure you can keep scraping stock quotes from somebody’s HTML page, but if you start getting those quotes by consuming a stock quote Web service instead, you’ll rest assured knowing your quotes system will still be working tomorrow.

Maybe you’ve heard that web services use a combination of HTTP, XML, SOAP, WSDL, and UDDI technologies. Sounds like a lot of acronyms to master, right? Wrong. All of those funky technologies are wrapped into CFMX behind the scenes, so we can start exploring real Web services right now with the built-in tools of CFMX. We’ll start by exposing the “dateExample” ColdFusion component from my last segment as a Web service.