It's not the most intuitive feature but you can you the
<cfparam ...>
tag to set data types for variables.
<cfparam name="nCountries" value="0" type="int">
<cfparam name="isFlexible value="true" type="boolean">
...
<cfinvokeargument name="nCountries"
value="#nCountries#">
<cfinvokeargument name="isFlexible"
value="#isFlexible#">
I've posted a working test case I once created to get the
NOAA's weather
forecast data.
rachelcp wrote:
> I'm having some trouble with data type mismatches when
invoking a webservice.
> It seems ColdFusion sends in all parameters as strings,
when SOAP wants boolean
> or int and they aren't matching.
>
> The webservice has the following parameters (I've only
included the parts that
> are giving me problems):
>
> <wsdl:message name="doPassProductSearchRequest">
> <wsdl:part name="nCountries" type="xsd:int"/>
> <wsdl:part name="isFlexible" type="xsd:boolean"/>
> </wsdl:message>
>
> Here is my call to it:
>
> <cfinvoke webservice="#webservice#"
method="doPassProductSearch"
> returnvariable="getProduct" >
> <cfinvokeargument name="nCountries" value="0">
> <cfinvokeargument name="isFlexible" value="1">
> </cfinvoke>
>
> Here is the error I receive:
>
> Could not perform web service invocation
"doPassProductSearch".
> Here is the fault returned when invoking the web service
operation:
>
> java.lang.IllegalArgumentException: argument type
mismatch
>
> Does anyone know how I should code this so the cfinvoke
will definitely send
> in a boolean and an int? I assumed just sending a number
would do it, but the
> developer on the other end says no.
>
> Thanks!
>
<cfparam name="WAVEH" default = false type="boolean">
<cfparam name="maxt" default = true type="boolean">
<cfparam name="mint" default = true type="boolean">
<cfparam name="tempx" default = false type="boolean">
<cfparam name="dew" default = false type="boolean">
<cfparam name="pop12" default = false type="boolean">
<cfparam name="qpf" default = false type="boolean">
<cfparam name="snow" default = false type="boolean">
<cfparam name="sky" default = false type="boolean">
<cfparam name="wspd" default = false type="boolean">
<cfparam name="wdir" default = false type="boolean">
<cfparam name="wx" default = false type="boolean">
<cfparam name="icons" default = false type="boolean">
<cfparam name="waveh" default = false type="boolean">
<cfparam name="startDate" default="#now()#"
type="date">
<cfparam name="numDays" default="2" type="numeric">
<cfparam name="format" default="24 hourly"
type="string">
<cfset strWeatherParameters = STRUCTNEW() />
<cfset strWeatherParameters.WAVEH = WAVEH />
<cfset strWeatherParameters.maxt = maxt />
<cfset strWeatherParameters.mint = mint />
<cfset strWeatherParameters.temp = tempx />
<cfset strWeatherParameters.dew = dew />
<cfset strWeatherParameters.pop12 = pop12 />
<cfset strWeatherParameters.qpf = qpf />
<cfset strWeatherParameters.snow = snow />
<cfset strWeatherParameters.sky = sky />
<cfset strWeatherParameters.wspd = wspd />
<cfset strWeatherParameters.wdir = wdir />
<cfset strWeatherParameters.wx = wx />
<cfset strWeatherParameters.icons = icons />
<cfset strWeatherParameters.waveh = waveh />
<cfinvoke webservice =
"
http://weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
method = "NDFDgenByDay"
returnvariable = "xmlWeatherData">
<cfinvokeargument name="latitude" value="42.3485"/>
<cfinvokeargument name="longitude" value="-71.0733"/>
<cfinvokeargument name="startDate"
value="#startDate#"/>
<cfinvokeargument name="numDays" value="#numDays#"/>
<cfinvokeargument name="format" value="#format#"/>
</cfinvoke>
<cfset NDFDgenByDayData = XMLParse(xmlWeatherData) />
<cfinvoke webservice =
"
http://weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl"
method = "NDFDgen"
returnvariable = "xmlWeatherData">
<cfinvokeargument name="latitude" value="42.3485"/>
<cfinvokeargument name="longitude" value="-71.0733"/>
<cfinvokeargument name="product" value="time-series"/>
<cfinvokeargument name="startTime" value="#now()#"/>
<cfinvokeargument name="endTime"
value="#dateAdd('d',3,now())#"/>
<cfinvokeargument name="weatherParameters"
value="#strWeatherParameters#"/>
</cfinvoke>
<cfset NDFDgenData = XMLParse(xmlWeatherData) />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<cfdump var="#server#">
<cfdump var="#NDFDgenByDayData#">
<cfdump var="#NDFDgenData#">
</body>
</html>