Copy link to clipboard
Copied
I am in the process of creating a .Net utility to help us with some ColdFusion functions and in the .Net utility I still need to call some ColdFusion functions. The function is expecting a Struct type.
After much internet searching I have been unable to determine what type of object I need to use in C#/CSharp that will convert to the type="Struct" argument.
I receive the following error in C#/CSharp when trying to call the InvokeMethod method.
"... cannot convert to type 'Map'"
I have tried to use HashTable, DataTable, etc...
Is there anyway I can invoke a ColdFusion function with a Struct type argument from C#/CSharp?
Copy link to clipboard
Copied
jmwolman wrote:
Is there anyway I can invoke a ColdFusion function with a Struct type argument from C#/CSharp?
Yes, write a web service in ColdFusion, and then invoke it from C# or, indeed, from wherever you like. Otherwise, you cannot expect C# to call ColdFusion or vice versa.
Copy link to clipboard
Copied
I have a ColdFusion web service I am dynamically connecting to the wsdl file from C# and trying to call one of the ColdFusion web service functions from with my C# utility
Part of my ColdFusion code:
cfcomponent displayname="componentName" output="false">
<cffunction name="ComponentFunction" returntype="struct">
<cfargument name="Argument1" type="Struct">
The problem I am having is when I invoke the "ComponentFunction" function from within my C# utilty I am having problems trying to determine what type of C# object I need to send for the Argument1 argument. This is where I have tried to use a HashTable and DataTable and an Array, but I get the cannot convert to 'Map' error.
Copy link to clipboard
Copied
C# doesn't know what a ColdFusion struct is, naturally. Experiment with: <cfargument name="Argument1" type="any">.
Copy link to clipboard
Copied
C# doesn't know what a ColdFusion struct is, naturally. Experiment with: <cfargument name="Argument1" type="any">.
That's not gonna help: the OP still needs to pass a struct in. It's not the type value on the argument tag that's the problem, it's that they don't know how to construct something in C# that CF will understand as being a struct.
--
Adam
Copy link to clipboard
Copied
Adam Cameron. wrote:
C# doesn't know what a ColdFusion struct is, naturally. Experiment with: <cfargument name="Argument1" type="any">.
That's not gonna help: the OP still needs to pass a struct in. It's not the type value on the argument tag that's the problem, it's that they don't know how to construct something in C# that CF will understand as being a struct.
My point is that native C# code cannot pass an argument of type struct (strictly speaking, of type coldfusion.runtime.Struct).
Copy link to clipboard
Copied
And you're calling componentFunction as a web service, yes?
The WDSL for the CFC will tell you how to construct the input values. That said, I suck at interpretting WSDL into something meaningful, so I can't help you with that side of thins. As an aside... at the end of the day web services are platform-agnostic: it's not like a web service call is actually passing a struct (which is an in-memory conceit); it's just passing a string in a previously-agreed-upon format which CF then converts to a struct. System interoeprability is the raison d'etre of web services, after all.
That said, I'm surprised a HashTable doesn't work. Does C# have the notion of a HashMap? [Googles...]
I found this:
http://stackoverflow.com/questions/1273139/c-sharp-java-hashmap-equivalent
Maybe try a Dictionary?
--
Adam
Copy link to clipboard
Copied
Thanks Adam. Yes I tried the following C# objects: Dictionary<String, String>, System.Collections.Hashtable, DataTable table, Class structure, and ArrayList arrayTable.
All of which gave me the cannot convert to 'Map' error when invoking the function from C#.
Because we have to dynamically determine the web service based on selected information we are using the System.Reflection MethodBase class to call MethodInfo.Invoke
Which could be causing the issue since I am not straightout referencing one WSDL file.
Copy link to clipboard
Copied
Which could be causing the issue since I am not straightout referencing one WSDL file.
Sure, but you could still look at the WSDL to work out what it is you need to pass it.
Dunno what else to suggest though, sorry.
--
Adam
Copy link to clipboard
Copied
The WSDL file is showing:
<wsdl:part name="ReturnValue" type="apachesoap:Map" />
Copy link to clipboard
Copied
I googled "c# apachesoap:Map".
One of the matches was this:
http://forums.asp.net/t/1445135.aspx/1?C+and+ColdFusion8+web+services
It might pay to do a bit more googling though, I'm sure you'll find something. Well: "sure" is overstating it. You might find something 😉
From this point though, all I'd be doing to help is googling stuff. And I figure you could probably do as good a job of that as I can, so will leave it to you.
Do report back if you work it out though: you might save someone else some time down the track...
Sorry to not be able to help further.
--
Adam
Copy link to clipboard
Copied
jmwolman wrote:
I tried the following C# objects: Dictionary<String, String>, System.Collections.Hashtable, DataTable table, Class structure, and ArrayList arrayTable.
And the type KeyValuePair?
Copy link to clipboard
Copied
Correct, the KeyValuePair gave me the same error, cannot convert to 'Map'. I am still looking and researching, but thanks for all the suggestions and help. Google is the word! I just hope The Great Google Machine can help.
Copy link to clipboard
Copied
According to the conversion rules for .NET and Java in the ColdFusion documentation, System.Collections.Hashtable is the closest .NET type to a CF struct.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more