Question
Sending objects from FMS to ColdFusion
Hi!
I've posted this in the FMS forums with no success so I thought I'd try here...
I need the ability to send an object of variable properties to a ColdFusion CFC for processing. I can send a call to a CFC with specific arguments (not of type object - ie string, int etc) all fine, but sending an object fails all of the time.
I define my object on the FMs side as the following:
objMyObject= {};
objMyObject.message = "INFO - This is an object test!";
objMyObject.type = "info";
objMyObject.reason = "Testing sending an object to a coldfucion CFC";
After setting the NetServices gateway and appropriate responder with result and status methods, I call the CFC method with the following line:
myCFCService.sendObjectTest(objMyObject);
In my gateway onStatus responder I get the following:
Level: error
Code: SERVER.PROCESSING
String too long to display
Description: Service threw an exception during method invocation: The parameter OBJOBJECT to function sendObjectTest is required but was not passed in.
The 'String too long to display" line is trying to print out the info.details portion of the info object.
So the CFC recognises that SOMETHING needs to be passed to it (I currently have it set as type="any"), but the server side simply fails to send anything! I have a cfmail as the first line inside my CFC, and this never gets hit, and this is also wrapped inside a try/catch block, and this never fires either - it simply dies on the call to the CFC.
The cfc has the following code:
<cffunction name="sendObjectTest" access="remote" returntype="cfcResponse" displayname="sendObjectTest" hint="Test to see if we can receive an object from FMS">
<cfargument name="objObject" required="yes" type="any" hint="An Object to send">
<cftry>
<cfmail to="me@email.com" from="me@email.com" subject="sendObjectTest" type="html">
<cfdump var="#objObject#" label="objObject">
</cfmail>
<cfset return = CreateObject("component","cfcResponse")>
<cfset return.status = "OK">
<cfcatch>
<cfmail to="me@email.com" from="me@email.com" subject="Error in sendObjectTest!" type="html">
<cfdump var="#cfcatch#" label="cfcatch">
</cfmail>
<cfset return = CreateObject("component","cfcResponse")>
<cfset return.status = "BAD">
<cfset return.error = cfcatch.detail>
<cfreturn return>
</cfcatch>
</cftry>
</cffunction>
I know that the returntype of cfcResponse is working correctly, as I use it in a number of other functions in the cfc without a problem. The try/catch block never fires, as I never get any email sent to me at all. But I know it's reaching the cfc, as it knows there is a variable required (objObject).
I've also tried setting the objObject type to a struct, as well as ommiting this parameter entirely, but I get the same error on the FMS side, with no email from the CFC side. When I send a string instead of on object, the cfc works and the emails gets sent. So it's 100% the object that is the issue here.
Does anyone know what's going on here, or a possible solution? Any help would be greatly appreciated!
Thanks,
K.
I've posted this in the FMS forums with no success so I thought I'd try here...
I need the ability to send an object of variable properties to a ColdFusion CFC for processing. I can send a call to a CFC with specific arguments (not of type object - ie string, int etc) all fine, but sending an object fails all of the time.
I define my object on the FMs side as the following:
objMyObject= {};
objMyObject.message = "INFO - This is an object test!";
objMyObject.type = "info";
objMyObject.reason = "Testing sending an object to a coldfucion CFC";
After setting the NetServices gateway and appropriate responder with result and status methods, I call the CFC method with the following line:
myCFCService.sendObjectTest(objMyObject);
In my gateway onStatus responder I get the following:
Level: error
Code: SERVER.PROCESSING
String too long to display
Description: Service threw an exception during method invocation: The parameter OBJOBJECT to function sendObjectTest is required but was not passed in.
The 'String too long to display" line is trying to print out the info.details portion of the info object.
So the CFC recognises that SOMETHING needs to be passed to it (I currently have it set as type="any"), but the server side simply fails to send anything! I have a cfmail as the first line inside my CFC, and this never gets hit, and this is also wrapped inside a try/catch block, and this never fires either - it simply dies on the call to the CFC.
The cfc has the following code:
<cffunction name="sendObjectTest" access="remote" returntype="cfcResponse" displayname="sendObjectTest" hint="Test to see if we can receive an object from FMS">
<cfargument name="objObject" required="yes" type="any" hint="An Object to send">
<cftry>
<cfmail to="me@email.com" from="me@email.com" subject="sendObjectTest" type="html">
<cfdump var="#objObject#" label="objObject">
</cfmail>
<cfset return = CreateObject("component","cfcResponse")>
<cfset return.status = "OK">
<cfcatch>
<cfmail to="me@email.com" from="me@email.com" subject="Error in sendObjectTest!" type="html">
<cfdump var="#cfcatch#" label="cfcatch">
</cfmail>
<cfset return = CreateObject("component","cfcResponse")>
<cfset return.status = "BAD">
<cfset return.error = cfcatch.detail>
<cfreturn return>
</cfcatch>
</cftry>
</cffunction>
I know that the returntype of cfcResponse is working correctly, as I use it in a number of other functions in the cfc without a problem. The try/catch block never fires, as I never get any email sent to me at all. But I know it's reaching the cfc, as it knows there is a variable required (objObject).
I've also tried setting the objObject type to a struct, as well as ommiting this parameter entirely, but I get the same error on the FMS side, with no email from the CFC side. When I send a string instead of on object, the cfc works and the emails gets sent. So it's 100% the object that is the issue here.
Does anyone know what's going on here, or a possible solution? Any help would be greatly appreciated!
Thanks,
K.