ColdFusion
  Home arrow ColdFusion arrow Page 3 - Creating a Web Service with ColdFusion: th...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

Creating a Web Service with ColdFusion: the Basics
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 17
    2006-02-21

    Table of Contents:
  • Creating a Web Service with ColdFusion: the Basics
  • Create a Function
  • Turn the function into a Web Service
  • Consuming the Service

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    More ColdFusion Articles
    More By Jayaram Krishnaswamy


       · If you follow the basic steps in the tutorial it is real easy to create a web...
     

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







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT