Web Services: Creating SOAP endpoints
SOAP differs from the easier RESTlet based webservices in that they advertise and manage remote objects. SOAP allows for the most complex of webservices to be designed and built, by offering more than simple remote function calls. A SOAP transaction permits the creation of remote objects, that can be passed around like local objects, but when methods are called, they are executed on the remote server, not the local server.
SOAP objects are advertised to consumers using a WSDL (Web Services Description Language) definition file. This WSDL file is an XML document that describes all the properties of the remote object, including how to call it and what object types are further returned. The WSDL file is the key to successful SOAP operation. It is this XML document, that can be used locally, or loaded remotely via a URL on demand lets the client know how to interact with the remote object.
As you know, CFML makes the creation of objects very easy using the CFC model. Turning these objects into SOAP objects is done automatically, by simply calling their URL's by adding in the ?WSDL param. Take for example the following CFML CFC. It has 3 methods, but yet we only expose 2 of them as remote methods.
<cfcomponent> <!--- assume this is saved @ /rpc/mycfc.cfc ---> <cffunction name="run" access="remote" returntype="string"> <cfreturn "from a remote"> </cffunction> <cffunction name="getTime" access="remote" returntype="string"> <cfreturn now()> </cffunction> <cffunction name="internalMethod" access="private" returntype="string"> <cfreturn "from a internal method"> </cffunction> </cfcomponent>
This method is now available for use by any SOAP client using the following WSDL:
You can access this URL using any browser. This will return the WSDL XML document that describes this CFC as a remote accessible SOAP object. You can then use this WSDL with any SOAP client for remote execution.
That is all you have to do - simply add ?WSDL to any CFC endpoint and the SOAP container will automatically be created for you, ready for use. Contrast this to the complexity that is required by other languages, then you discover how quickly and powerful you can make your CFML applications work with webservices.
Next discover how to consume remote SOAP endpoints.