Home arrow ColdFusion arrow Page 3 - Creating a Web Service with ColdFusion: the Basics
COLDFUSION

Creating a Web Service with ColdFusion: the Basics


A web service is a software related technology that facilitates machine-to-machine interaction over a network. Web services are used by clients who access the service, and could be written in any programming language. This article will show you how to create a web service using ColdFusion.

Author Info:
By: Jayaram Krishnaswamy
Rating: 5 stars5 stars5 stars5 stars5 stars / 36
February 21, 2006
TABLE OF CONTENTS:
  1. · Creating a Web Service with ColdFusion: the Basics
  2. · Create a Function
  3. · Turn the function into a Web Service
  4. · Consuming the Service

print this article
SEARCH DEVARTICLES

Creating a Web Service with ColdFusion: the Basics - Turn the function into a Web Service
(Page 3 of 4 )

In this step you will turn this function into a web service by using the CFC tags. This is the easy part. The web service we create using this function will be called justFunction.cfc. CFCs have this extension, and this is important to note. Here is the code for this CFC.

<cfcomponent>
<cffunction name="WelcomeMsg" access="remote" returntype="string"
output="no">
<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> </cfcomponent>

First of all, you notice that the function code is nested in the cfcomponent tags. You also notice that a couple more attributes are added to the function. The web service is accessed remotely and therefore the access is set to 'remote'. Since it is a service you cannot access it directly for an output, so we have set it for 'no' output. Actually, when your consumer calls, this service gets it for you, after massaging what he gets from the server. The tag cfreturn is also needed, because this is what the service returns.

Now you save it in the other directory mentioned earlier, CF_WebSvc. Now, let us see what happens if we access this file with your browser. This is a component, so it should be viewed with a component browser. This is what you will see.

Now if you have permission to log on to this screen (go back to the installation at the very beginning; I could because I am the admin, and in fact the only user), you enter and click on Login. This is what you will see. It's the description of the service and the methods therein. You will see that WelcomeMsg() is a method that takes a string argument. Well, folks, this is all there is to it. When this service is called by the consumer, he or she should provide a string.


blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials