• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I pass the entire FORM to a webservice?

Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

What is the proper way to pass an entire form to a webservice? I can make a my CFC work with 1 param, which is the FORM, but when I try to use the CFC as a webservice I get a type mismatch error. The has to be a way to pass the entire form to a webservice rather than me, creating a bunch of params for each form element, I just can not find an example anywhere. I know I can not be the only person ever to ask this question.
TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jun 26, 2007 Jun 26, 2007
..

Votes

Translate

Translate
LEGEND ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

How are you invoking the webservice?
Did you set a data type for the expected argument in the cfc? If so, what
type did you use?

Using cfinvoke you can use the argumentscollection attribute. If using
createObject you can pass the form as a structure.

--
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
-------------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Yes, I wrote the service, and was passing it to a STRUCT type. I never use the argumentscollection, I always just pass the FORM thru a cfinvokeargument.

One way I know I can do it, is to use CFWDDX and serialize the FORM, then pass it in as a STRING, then once in the webservice, i use CFWDDX again an deserialize it back into a struct.

I am just wondering if this is the only way. I'd think there'd be a better way.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Hmm. I've never had a problem passing the form struct into a webservice.
What is the exact error message you are getting?

--
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
-------------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

I get a Java error ... something to the effect ... a Type Mismatch.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

And you're positive it is the invocation causing the error and not something
else in the cfc or calling page?

--
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
-------------------------------------------------------------------------


Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
"programmer_neo" <webforumsuser@macromedia.com> wrote in message
news:f5rf22$bhq$1@forums.macromedia.com...
>I get a Java error ... something to the effect ... a Type Mismatch.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Yes I am positive.
Have you successfully passed a FORM to a webservice through cfinvoke as a cfinvokeargument parameter?
(And before anyone askes, no it is not a caching problem, I run a script to destroy the stub. To me, CF is not handling the FORM scope as expected. Rather than treating it as a STRUCT, it thinks it is something else.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Technically I think FORM is not the same type of structure as StructNew(). I don't know if that's the problem, as Bash said he's had no problem with it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

I'm sure that is the problem. I'd bet FORM is an OBJECT.
In short, then how do I pass it in?

Can someone please provide a working example, of how to invoke, and how the method accepts the FORM

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Yes, they're both objects, just different types

FORM is: coldfusion.filter.FormScope
StructNew() produces: coldfusion.runtime.Struct

I think you're right. I tried a simple webservice and it threw
"java.lang.IllegalArgumentException: argument type mismatch"

It works if I use Duplicate(form). That function must return a regular structure.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Wow, cool, I'll have to try that. I never really used Duplicate(). I just thought it was used to un-associate a pointer from the original object. I never had a need for that.
That will work better for me than to use WDDX

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Yep, I use it for that purpose frequently. Figured it was worth a shot. Seems to do the trick.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2007 Jun 26, 2007

Copy link to clipboard

Copied

Thanks cf_dev2 !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2007 Jun 27, 2007

Copy link to clipboard

Copied

Why not go all the way and harvest the whole form with:

<!--- TestWebService --->
<cfcomponent >
<cffunction name="testStructure" access="remote" returntype="struct" output="no">
<cfargument name="formStructure" type="struct" required="yes">
<cfset var outStructure = StructNew()>
<cfset outStructure = duplicate(arguments.formStructure)>
<cfreturn outStructure/>
</cffunction>
</cfcomponent>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 27, 2007 Jun 27, 2007

Copy link to clipboard

Copied

No reason other than personal preference. I wanted a quick test that proved the function was able to read the argument structure but did something different than just echoing the form structure.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2007 Jun 29, 2007

Copy link to clipboard

Copied

LATEST
Cf_dev2 wrote:
No reason other than personal preference.

Fair enough. Yeh pays yer money, yeh makes yer choice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation