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). 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) 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 http://example.com/cfcs/department.cfc?wsdl. 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: http://example.com/cfcs/myWebService.wsdl.
In a ColdFusion web service, the URL references the CFC like this: http://example.com/cfcs/user.cfc?wsdl; 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. 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. 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.
|