Simple SOAP Example

I was recently asked to help some developers that are new to CFML to try to learn a bit more about how ColdFusion and Web Services work, so I put together a little sample app (it's just two files) that shows how web services are published and consumed using CFML. The zip file can be found at http://www.horwith.com/downloads/soapexample.zip. Simply unzip the file to a coldfusion server somewhere off it's root and then browse to the "soapexample" directory that was created by the unzip process. The index.cfm file you browse to explains everything else (it assumes you're using CF for J2EE but if you're not, the code won't require tweaking any more than it might for anybody else who is running the J2EE version).
It's nothing very complicated - that's the point. I was trying to show how simple it is to do these things as well as teach the syntax.

Comments
Your SOAP example is just what I've been looking for -- thanks!

There's one bit that I can't seem to get right. You mention in the comments that "This file assumes the path to the current directory (from your cfusion_war directory) is "soapexample"".

I don't have a cfusion_war directory... do you know what I should look for? The error I'm getting is as follows, and I think it's because of that variable:

==============
coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler: Found 1 semantic error compiling "C:/CFusionMX7/stubs/WS-1878490784/soapexample_pkg/SOAPExampleLocator.java": 10. public class SOAPExampleLocator extends org.apache.axis.client.Service implements soapexample_pkg.SOAPExample { <---------> *** Error: Type soapexample_pkg/SOAPExample was not found.
======================

Thanks for your help!
# Posted By Kay | 4/15/05 10:04 AM
If you don't have a cfusion_war directory, then it's whatever directory your server uses as root (probabably "wwwroot" under wherever you've installed CF). A hint - your CFIDE directory will also be a subdirectory of the root - you want "soapexample" to be at that same directory level.
# Posted By Simon Horwith | 4/15/05 10:41 AM
I am trying something like your example. Just want to get back a list of firstnames cfc webservice, then I try and invoke this in the cfm, what am I doing wrong?

<cfcomponent>
<cffunction name="echoQuery" access="remote" returntype="query">
<cfquery name="result" datasource="#request.dsn#">
SELECT Firstname
FROM Loger
      </cfquery>
<cfreturn result>
</cffunction>
</cfcomponent>
_________________________
<cfinvoke
webservice="http://www.wrighter.com/cfca/xmlserv/users-works3....
method="echoQuery"
returnvariable="result">
</cfinvoke>

<cfdump var="#result#">
# Posted By Bruce Wrighter | 4/10/07 11:41 AM
Bruce,
I just looked at your WSDL and then I ran your code, and it works fine for me!
# Posted By Simon Horwith | 4/10/07 11:47 AM
When I run the cfinvoke to pull the info it blows up. at

http://www.wrighter.com/cfca/testwebservices-works...

Web service operation "echoQuery" with parameters {} could not be found.

The error occurred in D:\Inetpub\wrighter\cfca\TestWebServices-Works3.cfm: line 6

4 : webservice="http://www.wrighter.com/cfca/xmlserv/users-works3....
5 : method="echoQuery"
6 : returnvariable="result">
7 : </cfinvoke>
# Posted By Bruce Wrighter | 4/10/07 12:24 PM
This site is hosted by HostMySite and runs off of BlogCFC - thanks, Ray.