Skip to main content
Kristian Wright
Known Participant
June 3, 2008
Question

Sending objects from FMS to ColdFusion

  • June 3, 2008
  • 3 replies
  • 546 views
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.
    This topic has been closed for replies.

    3 replies

    Kristian Wright
    Known Participant
    June 11, 2008
    Thanks for the try Steve, but alas no...

    The name 'objMyObject' is on the FMS side, and the 'objObject' is on the cfc side - they don't need to have the same name, just be of the same type.

    Just as a test, I named them both the same (gotta try everything, and admittedly I didn't try this before), but it still gives me the same error.

    But thanks for trying!! Appreciate it!

    Anyone else?? ;-)
    Kristian Wright
    Known Participant
    June 11, 2008
    * bump* ;-)

    Anyone?? I refuse to believe that something as simple as sending on object from FMS to coldfusion is impossible!
    June 11, 2008
    First, let me say I am pretty much a "begginer" at CFCs, and have never done any sort of remoting so my answer is almost going to be assured of being incorrect. However, the one thing that I see is this:

    myCFCService.sendObjectTest(objMyObject);

    <cfargument name="objObject" required="yes" type="any" hint="An Object to send">

    shouldn't it be <cfargument name="objMyObject" required="yes" type="any" hint="An Object to send">?

    Kristian Wright
    Known Participant
    June 6, 2008
    Anyone have any idea? I'm in a real bind here!!

    Surely this can be done...

    Cheers,
    K.