Skip to main content
Kristian Wright
Known Participant
April 15, 2008
Question

Sending objects from FMS to ColdFusion

  • April 15, 2008
  • 9 replies
  • 983 views
Hi All.

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) 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.

Can anyone help me out here?

Thanks in advance,
K.
    This topic is closed to new replies. Start a new post to keep the conversation going.

    9 replies

    Kristian Wright
    Known Participant
    June 3, 2008
    Thanks for your time Stoem. I wish you had one too! ;-)

    I'll try the CF forums as well.

    But if anyone else has any ideas, please feel free to fire away!

    Thanks
    K.
    Kristian Wright
    Known Participant
    June 3, 2008
    I changed the FMS code to:

    myString = "test string!";
    myCFCService.sendObjectTest(myString);

    and left the cfc side the same (with the objObject type set to 'any')

    I get the email that should be sent in the try part of the block. So this works!

    But yeah - I can send a string (and any other datatype) to the cfc without problem. It's only objects that do not seem to work.

    stoem
    Known Participant
    June 3, 2008
    I wish I had an answer for you...
    All I can say is that there have been problems in the past when it comes to casting of variables between CF and Flash, but that has improved with Flex. I'm not sure if I ever used objects to send from FMS to CF but for now I can only offer one suggestion and that is trying an Array. I know it's not an object but it may work...

    Sorry, I think you may better post this on the CF forum or on a CF list.
    Kristian Wright
    Known Participant
    April 22, 2008
    I tried changing the code creating the object to:

    objMyObject = new Object();

    But this failed also.

    Running out of ideas, and thinking it can't be done! But it's such a simple thing... Anyone have an idea?

    K
    stoem
    Known Participant
    May 12, 2008
    hi,
    could you post your CFC code please?

    Kristian Wright
    Known Participant
    June 3, 2008
    Hi Stoem.

    Sorry for the delay - I've been on leave for a while!

    Here is the CFC 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), as indicated in the previous postings.

    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.

    Thanks for looking into this! Hope you can help me out...

    Cheers,
    K.
    Kristian Wright
    Known Participant
    April 21, 2008
    * Bump * ;-)

    No one has done this? Surely it's possible...? No?
    Kristian Wright
    Known Participant
    April 16, 2008
    Does anyone have any tips? ANY help greatly appreciated here!! ;-)

    Thanks,
    K.