Solved

Error outputting form data deserialized with wddx2cfml

Posted on 2013-01-17
9
295 Views
Last Modified: 2013-02-05
I have the following code:
<cfsilent>
	<cfquery datasource="#application.configBean.getDatasource()#" name="qFormDataRaw">
		SELECT data FROM tformresponsepackets
		WHERE responseid = <cfqueryparam value="#URL.responseID#" cfsqltype="cf_sql_varchar">
	</cfquery>
	<cfwddx 
		action = "wddx2cfml" 
		input = "#qFormDataRaw.data#" 
		output = "qFormData" 
		validate = "yes" >
</cfsilent>

Open in new window


When I try to output the results with <cfoutput query="qFormData"> I get the error that "The value of the attribute query, which is currently qFormData, is invalid." If I do a cfdump of qFormData it looks like I'd expect, with the "column names" on the left and the corresponding data on the right.

According to the LiveDocs for cfwddx (at least for 8, which is what we're running) it appears that you can use the wddx2cfml results as a query. What am I doing wrong here? Thanks!
0
Comment
Question by:SiobhanElara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 38789187
- What does qFormData.Data contain: a wddx string ?  
- Does qFormData contain multiple rows?
0
 

Author Comment

by:SiobhanElara
ID: 38789230
- What does qFormData.Data contain: a wddx string ?
Yes. It looks like this:
<wddxPacket version='1.0'>
   <header/>
      <data>
         <struct>
            <var name='HOMEPHONE'><string>555-555-5555</string></var>
            [more variables]
         </struct>
      </data>
</wddxPacket>

Open in new window

Does qFormData contain multiple rows?
Yes. It looks something like the following:
HOMEPHONE     |     555-555-5555
ADDRESS            |     123 Main Street
CITY                    |     Anytown
etc.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38789259
>  Does qFormData contain multiple rows?c

I meant your query.  ie

Row | Data
1     | <wddxPacket version='1.0'> ....
2     | <wddxPacket version='1.0'> ....
3     | <wddxPacket version='1.0'> ....

If each row contains a *separate* WDDXPacket, I don't think you can do it in a single line. You must loop through the query and call cfwddx on the packet in each row. Something like

ie
<cfloop query="qFormDataRaw">
        <cfwddx
            action = "wddx2cfml"
            input = "#qFormDataRaw.data[currentRow]#"
            output = "qFormData"
            validate = "yes" >
</cfloop>
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:SiobhanElara
ID: 38789297
Oh, I'm sorry... I misunderstood your question. qFormDataRaw.Data (the input for the cfwddx tag) contains the packet. There is no qFormData.data variable; each row is a var name/string pair from the packet (and "data" is not one of the variables. Or am I misunderstanding the question still?)
0
 

Author Comment

by:SiobhanElara
ID: 38789369
As a bit of additional information, I can dump a variable like qFormData.HOMEPHONE and it outputs the proper string.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38789379
(Edit)  Sorry, I see it was a typo of mine that confused things! But I misread the problem anyway.  Let me see if I can track down a CF8 machine to test something.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 38789483
Maybe I'm still misunderstanding.  Here's a standalone example. I tried to simulate what you described. But no errors under CF8.

Can you look it over and see if we're on the same page about what your input looks like?

<!--- create a sample query --->
<cfset qSample = queryNew("")>
<cfset queryAddColumn(qSample, "Name", listToArray("Bob,Joe"))>
<cfset queryAddColumn(qSample, "HomePhone", listToArray("555-555-5555,111-111-1111"))>

<!--- convert it into wddx --->
<cfwddx action="cfml2wddx" input="#qSample#" output="qWDDXString">

<cfoutput>
Converted query: <pre>#HTMLEditFormat(qWDDXString)#</pre>
</cfoutput>

<!--- now simulate your "input" query --->
<cfset qFormDataRaw = queryNew("Data")>
<cfset queryAddRow(qFormDataRaw, 1)>
<cfset qFormDataRaw.Data[1] = qWDDXString>

<!--- try and convert it back into a CFML query object --->
<cfwddx action="wddx2cfml" input="#qFormDataRaw.Data#" output="qOutputQuery">

<!--- dump it --->
<cfdump var="#qOutputQuery#">

<!--- verify we can output it --->
<cfoutput query="qOutputQuery">
   #Name# #HomePhone#<br>
</cfoutput>
0
 

Author Comment

by:SiobhanElara
ID: 38789528
I'm away from my machine at the moment, but I'll try to do this when I get home. Thank you for your help!
0
 

Author Closing Comment

by:SiobhanElara
ID: 38855115
It turned out that the result could be accessed only as a structure, not a query. I have no idea why, but I'm giving you the points for all your help. :)
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question