Producing (or publishing, as it’s sometimes referred to) web services in ColdFusion MX is a very simple proposition. In fact, many people have made the claim that it is the easiest way to create and publish web services. While I won’t go that far, I can say that claim is not far from the mark. In essence, you already know everything necessary to publish a simple web service: you learned it back in Chapter 22, ColdFusion Components.
To convert a CFC into a web service, all you
need to do is set to
access attribute of any component methods
cffunction) you want to expose as web services.
That’s all there is to it. To show you just how easy
it is to produce a web service in ColdFusion MX, consider the code
shown in Example 24-5. After you’ve
entered the code, save it under
Example 24-5. Producing a simple web service in ColdFusion MX
<cfcomponent> <cffunction name="getMessage" access="remote" returntype="string" output="no"> <cfargument name="name" type="string" required="yes"> <cfreturn "Hello " & arguments.name &"! " & "I've been invoked as a web service."> </cffunction> </cfcomponent>
After looking at this code, your first reaction was probably that it
looks just like a regular CFC. That’s because it
is a regular CFC. All that really separates a
CFC from a web service is setting the
attribute of whatever method(s) you want to expose to
remote. There are a few additional rules for creating ...