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

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
  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

Creating a Web Service with ColdFusion: the Basics - Consuming the Service
(Page 4 of 4 )

We want to know whether this service is working. How are we going to test it? Easy, let us create a client who will consume this service. Writing client code is not different from writing a CFM page. Of course you use the special tags, like "cfinvoke" which calls up the service. Where does it call it from? This is where the WSDL we spoke of earlier comes in. The functions of the CFC function are similar to the ASMX in the dotNet environment. When you invoke the service, you invoke it with an argument, in this case "Mr.Bond". The return variable is a string which you display as you normally would, with the 'cfoutput' tags. Now you save this as ConsumejustFunction.cfm and store in the appropriate virtual directory.

<cfinvokeargument name="name" value="Mr. Bond"/>

It's show time! Browse to the 'ConsumejustFunction.cfm', and you will see the following.


It is pretty easy to create a web service in ColdFusion.  For those who already know how to write functions and components, it is a snap. When you make changes to the CFC make sure you browse to it and review it in the Control Viewer, otherwise the MX may return a "not found" message.

Coding a consumer is just as easy. All you need to do is provide a WSDL reference, a return variable, and the necessary arguments needed by the service. Although the function used is quite simple, more complex data types as well as data from the backend can be provided with the service. The keyword is interoperability. The consuming client could very well use another programming language, perhaps from a UNIX work station in Outer Mongolia.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- 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 

Developer Shed Affiliates


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