Creating a Web Service with ColdFusion: the Basics - Create a Function
(Page 2 of 4 )
Create function justFunction.cfm
I will show how to create a function. Of course you need to know all those tags. But this next code shows a very simple function which outputs a string after accepting a different string. This file is called justFunction.cfm. The function is called by its name. The argument is sent through the vehicle "arguments. name" which is "Jay" in this case.
<cffunction name="WelcomeMsg" returntype="string">
<cfargument name="name" type="string" required="yes">
<cfreturn "<h3><font color='blue'>Welcome to my Web Service Site</font>
</h3> " & arguments. name &"! " & "What would you like to do?">
</cffunction>
<cfoutput>
#WelcomeMsg("Jay")#
</cfoutput>
justFunction.cfm display
You need to place this file into the TestingCF virtual directory (which means in the physical directory shown earlier). Now if you browse this file in your favorite browser, this is what you will see.

Next: Turn the function into a Web Service >>
More ColdFusion Articles
More By Jayaram Krishnaswamy