Copy link to clipboard
Copied
Hi
I am trying to invoke a .net webservice method that receives an array of strings an i noticed that if i do this:
<cfscript>
text = arraynew(1);
text[1] = "Hello";
text[2] = "world";
</cfscript>
<cfinvoke method="Hello"
webservice="http://localhost/Service1.asmx?wsdl"
returnvariable="response">
<cfinvokeargument name="array" value=#text#/>
</cfinvoke>
I get this error
Cannot perform web service invocation Hello.
The fault returned when invoking the web service operation is:
''java.lang.IlligalArgumentException: argument type mismatch
however if i do this it works well:
<cfscript>
root = structnew();
text = arraynew(1);
text[1] = "Hello";
text[2] = "world";
root.string=text;
</cfscript>
<cfinvoke method="Hello"
webservice="http://localhost/Service1.asmx?wsdl"
returnvariable="response">
<cfinvokeargument name="array" value=#root#/>
</cfinvoke>
I know this has to do with the generated java proxy because he generated a structure called ArrayOfString with a property called string (what i am replicating in the "root" variable).... Is there any way around this, or this is the right way to do it? It is a bit painfull to do it like this...
Thanks.
Copy link to clipboard
Copied
Makes sense...my wsdl is enforcing the ArrayOf<type_name>...
Guess i'll have to live with that
Thanks for the replys.
Copy link to clipboard
Copied
so the only difference between what you are using and what i am using is the webservice technology...you are using coldfusion, i am using .net.
True, but that is the key. Since there is no direct mapping of the .NET ArrayOfString class in Axis, it is treated as a structure in CF. Just like any other custom/complex type.
Makes sense...my wsdl is enforcing the ArrayOf<type_name>...
So did you ultimately change anything .. or just leave it as ArrayOfString? (Though that is a bit of a misnomer imo, since it is a class not an array.)
Copy link to clipboard
Copied
In the .net webservice the method still receives a string[] but i think there is nothing i can do to change the wsdl generation...and i do not want to do that since i'll be consuming other webservice done in some other technology.
In the coldfusion side its still expecting the ArrayOfString...
As said before, the transformation of a CF array to the ArrayOf<Type_name> can be one dynamically so i think i'll take that aproach.
Copy link to clipboard
Copied
As said before, the transformation of a CF array to the ArrayOf<Type_name> can be one dynamically so i think i'll take that aproach.
Okay, so ultimately you just went with the original code. Simple enough.
Copy link to clipboard
Copied
What is the signature of the hello method? Could you show us the WSDL?
Copy link to clipboard
Copied
Cool, how did you come up with root.string? Trial and error?? I would love to know why root.string works.
Copy link to clipboard
Copied
henrylearn2rock wrote:
Cool, how did you come up with root.string? Trial and error?? I would love to know why root.string works.
Your question seems irrelevant to this thread. Create your own thread, and you will surely get suggestions.
Copy link to clipboard
Copied
Hi,
The 'root' is just the name of the structure that will contain the array, doesn't matter what name you give to that variable, now the 'string' part is the important part. The 'string' is basically the name of the parameter in the webmethod...the method was something like:
void myFunc(String[] string);
You can know the correct name by looking at the wsdl. In this case since i was creating both the service and the client it was a easier.
If you don't want to look at the WSDL you can use the wsdl2java to generate a proxy and see what's the structure of the objects. what you create in coldfusion has to match what wsdl2java is expecting.
Hope it helps.