This content has been marked as final. Show 6 replies
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()>
<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>
The above is just an example, and It might work with only some types of complextype responses. But it's a start. :)
http://firstname.lastname@example.org/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.
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 = StructNew();
struct.item3.item1 = [integer];
struct.item3.item2 = ArrayNew(1);
struct.item3.item2 = 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?
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?
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.
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.
Refer this thread
If your input parameter is somewhat similar, then I might be able to provide you some help....
Good luck :)