By David Fekke
January 17th, 2011
I have a SOAP based web service that I wrote when ColdFusion MX 6 first came out, and it does not work in BlueDragon.NET.
The web service is called a quote from Mr. Spock. (Yes, I am a GEEK.) It has a one method called getQuote which returns a coldFusion structure or a HashMap object if you are using Java. When I test my client for the web service in BlueDragon, it retuned an empty object. So I decided to rewrite my web service code to return a simple object instead. My current cfc for the web service looks like this;
<cffunction access="private" name="getRand" returntype="numeric">
<cfset randNum = randrange(1,85)>
<cffunction access="Remote" name="getQuote" returntype="struct" hint="Get Quote from Mr. Spock">
<cfquery name="myQuoteQuery" datasource="#application.davidsDSN#">
Select * From SpockQuotes
WHere QuoteNum = #getRand()#;
My structure has three name/value pairs for the quote, stardate and episode. The values are all of type string. So the following cfc that describes the simple object looks like this;
<cfproperty name="quote" type="string" />
<cfproperty name="episode" type="string" />
<cfproperty name="stardate" type="string" />
<cffunction access="private" name="getRand" returntype="numeric">
<cfset randNum = randrange(1,85)>
<cffunction access="Remote" name="getQuote" returntype="SpockQuoteModel" hint="Get Quote from Mr. Spock">
<cfquery name="myQuoteQuery" datasource="#application.davidsDSN#">
SELECT quote, episode, stardate
FROM SpockQuotes
WHERE QuoteNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#getRand()#" />;
<cfset spock = createObject("component","SpockQuoteModel") />
Quote: "#aHashMap.quote#"
Episode Name: #aHashMap.episode#
Stardate: #aHashMap.stardate#