Copy link to clipboard
Copied
Hi all!
We have created a web service with ColdFusion8. One of the functions (GetDeviceAlarms) returns an array of cfobjects.
The result from the function might be an empty result, therefore I need to set minOccurs="0" for the element "GetDeviceAlarmsReturn".
If this attribute is not set the validation against the schema fails on empty results.
Is there any way to tell ColdFusion to set minOccurs="0" for the element GetDeviceAlarmsReturn?
# Code
<cffunction name="GetDeviceAlarms" access="remote" returntype="alarmstatus_type[]"
description="desc"
hint="hint">
<cfobject component="alarmstatus_type" name="alarmStruct">
# WSDL
<wsdl:operation name="GetDeviceAlarms">
<wsdl:input message="impl:GetDeviceAlarmsRequest" name="GetDeviceAlarmsRequest"/>
<wsdl:output message="impl:GetDeviceAlarmsResponse" name="GetDeviceAlarmsResponse"/>
<wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>
</wsdl:operation>
// Generated wsdl
<element name="GetDeviceAlarmsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="GetDeviceAlarmsReturn" type="impl:Alarmstatus_type"/>
</sequence>
</complexType>
</element>
// What I would like to accomplish
<element name="GetDeviceAlarmsResponse">
<complexType>
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="GetDeviceAlarmsReturn" type="impl:Alarmstatus_type"/>
</sequence>
</complexType>
</element>
// Best Regards Kalle
Copy link to clipboard
Copied
In thiscase you may need to add it manually. To do this you could use
the cfcomponent tag's wsdlfile attribute. Basically, copy the
dynamically generated WSDL, add the minOccurs as needed, then point
the wsdlfile attribute of the component to the saved, static WSDL.
--Nathan
Copy link to clipboard
Copied
Ok, thanks for your reply!
Copy link to clipboard
Copied
WARNING: if Coldfusion 8, and have OnRequest() in application.cfc, this will not work --it is a known cf8 bug. For a workaround, see
http://www.coldfusionjedi.com/index.cfm/2008/3/19/Ask-a-Jedi-Ajaxbound-requests-and-onRequest