Quote Service not working on BlueDragon.NET


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;

"spock">

<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()#;

ColdFusion MX has a built in way to describe simple objects in the WSDL file. If you create another cfc using the cfproperty tag, you can return that type in the web service.

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;

"SpockQuoteModel">

<cfproperty name="quote" type="string" />
<cfproperty name="episode" type="string" />
<cfproperty name="stardate" type="string" />

Then I wrote a new web service code that uses this cfc;

"SpockWS">

<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") />




I tested this in BlueDragon.NET with the following client code;

"[http://www.fekke.com/com/SpockWS.cfc?wsdl](http://www.fekke.com/com/SpockWS.cfc?wsdl)" method="getQuote" returnvariable="aHashMap">


Quote: "#aHashMap.quote#"

Episode Name: #aHashMap.episode#

Stardate: #aHashMap.stardate#

It Worked!!! I will copy this sample code to my web site with instructions soon.

← Previous Page  Next Page →