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

Web Services and Nested Complex Types

New Here ,
Jan 15, 2007 Jan 15, 2007

Copy link to clipboard

Copied

I am having troubles trying to get coldfusion to use a web service function.

I know that the web service works as I am sending another function in a simple variable and receiving a simple variable. I know the function exists as I when I dump the object the function is there and I have been told by who supplies it that it works in other languages.

The problem I am having is that when I call the function I get the following error: Web service operation "[function name]" with parameters [parameters] could not be found. I am lead to believe that it may have to do with the fact that one of the parameters is a complex type with nested complex types, because of the amount of trouble it took to get nested complex types to (apparently) work.

Has anyone had this problem before and/or know how to fix it?
TOPICS
Advanced techniques

Views

574

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
Enthusiast ,
Jan 16, 2007 Jan 16, 2007

Copy link to clipboard

Copied

You can invoke methods which take complextypes as parameters. The idea is to create first a structure which represents the complextype. For example; crit = structNew(), crit.paramname1 = value1, ctir.paramname2 = value2. After this, you just pass the structure crit as a parameter value, for example with <cfinvokeargument>.

Always check the wsdl and the possible documentation carefully. You'll get always an error if the types of the parameters passed didn't match exactly to what was expected.

Handling complextype responses is also possible, but not very elegant with ColdFusion.

For example, you have <cfinvoke returnvariable="wsResult"... >, and you get a java object as a response which you can really do nothing about with CF functions, you must use Java Reflection API to extract the values.

<cfset oFields = wsresult.getClass().getDeclaredFields()>
<cfoutput>
<cfloop from="1" to="#arraylen(oFields)#" index="fi">
<cfset field = oFields[fi].getName()>
<cfif isdefined("wsresult." & field) AND field NEQ "typedesc">
#field# = #wsResult[field]#<br>
</cfif>
</cfloop>
</cfoutput>

The above is just an example, and It might work with only some types of complextype responses. But it's a start. :)

http://www.mail-archive.com/cf-xml@torchboxlists.com/msg00553.html is also another example about handling complextype responses. It plays "safer", not relying that CF can extract values without "getters" automatically, and is more of a complete solution.

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
New Here ,
Jan 16, 2007 Jan 16, 2007

Copy link to clipboard

Copied

How would I go about this with a complex struct that has 2 levels of nested complex structs?

After some research on this I had found an article saying that nested complex types have to be assembled with an array as the value that holds the nested struct ie:

struct.item1 = [string];
struct.item2 = [boolean];
struct.item3 = ArrayNew(1);
struct.item3[1] = StructNew();
struct.item3[1].item1 = [integer];
struct.item3[1].item2 = ArrayNew(1);
struct.item3[1].item2[1] = StructNew();

and so on. This method helped with the multiple levels of complex structs, however I got the previous error. Is it possible to embed java into coldfusion code?

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
Enthusiast ,
Jan 18, 2007 Jan 18, 2007

Copy link to clipboard

Copied

I haven't had to deal with nested complextypes yet, but I remember seeing that article too about using arrays, although it feels unlogical unless you want to pass an _array_ of complextype objects. Can you post the url?

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
New Here ,
Jan 18, 2007 Jan 18, 2007

Copy link to clipboard

Copied

http://hcc.musc.edu/research/shared_resources/xml_complex_types_to_cf_structure_notes.cfm

I have tried this, however it doesn't want to work. I have a web service that requires a value that has nested complex types for 3 levels down. I am thinking about writing some functions in java and then getting coldfusion to pass in the simple types that will fill the complex types.

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
New Here ,
Feb 08, 2007 Feb 08, 2007

Copy link to clipboard

Copied

LATEST
HI,

Refer this thread
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1118331&high...

If your input parameter is somewhat similar, then I might be able to provide you some help....
Good luck :)
Prash

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
Enthusiast ,
Jan 18, 2007 Jan 18, 2007

Copy link to clipboard

Copied

Unfortunately that article is as good as my brain gets, so let's hope someone else can help you on this, for I have no personal experience with the same problem.

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