ColdFusion Web Services Tutorial

(By Eric Korson)

Topics Include

How to Create a ColdFusion Web Service

When creating a web service in ColdFusion, the CFC location is the endpoint for the web service, and its remote functions become operations that can be invoked on the web service. We can create a web service by creating a ColdFusion Component (CFC) and specifying access="remote" within the method (screen shot below).

access remote

To invoke this method; typically, you would create an instance of the component and than call a method on it, passing data in the form of arguments. In this case, the method above would require the department id as a numeric value and return the department name as string value.

Also see Seven Ways to Instantiate and Invoke a CFC (ColdFusion Component)

Back To Top

Differences of ColdFusion Web Services

The nice difference is that you don't have to manually create a WSDL file for each of your web services (although I could), the server does it automatically for you. The address of the "department" web service is

In many cases to consume a web service, you only need to know the URL of its WSDL file. A typical URL to a web service might look something like: In a ColdFusion web service, the URL references the CFC like this:; whereas, the ?wsdl parameter tells ColdFusion to invoke the CFC as a web service. If you leave off the ?wsdl parameter, ColdFusion thinks you are trying to call the CFC directly and will invoke the CFC Explorer to show the CFCs self-documentation through introspection.
Go ahead and try it, open up your browser; and, enter the URL to the CFC you would like to introspect. You should be presented with the CFC login screen.

The second difference between consuming a regular web service vs. one written in ColdFusion; has to do with data types of the input and output parameters. In ColdFusion, there is no need for data type mapping. This means that your web service can accept and return any valid ColdFusion data types without worrying about conversion issues.

Back To Top

Web Services Defined

The term web services describes a standardized way of integrating web-based applications using the XML, WSDL, SOAP and UDDI open standards over an Internet protocol backbone. To better understand what web services are and how they work, let's break down the four main components that make up a web service.

  • XML (Extensible Markup Language)
    • XML can be considered the foundation of the web services stack. It provides a standardized platform and neutral format for exchanging data among applications.
  • WSDL (Web Services Description Language)
    • WSDL is an XML format for describing a web service. It describes the purpose of the web service, where and how to access it; and, what functionality (methods) it exposes.
  • SOAP (Simple Object Access Protocol)
    • SOAP provides an XML based messaging framework for web services. A SOAP message is essentially an XML document made up of an envelope containing an optional header and required body.
    • In coldFusion, you don't need to know SOAP to make use of web services because the coldFusion server automatically handles this for you.
  • UDDI (Universal Description, Discovery; and, Integration)
    • UDDI is basically a directory service for web services. It provides a standardized interface for registering and querying web service metadata. In laymen’s terms, companies can list themselves (register their web services); and, search for web services on the Internet.

Back To Top