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

Invoke webservice with complex types

Guest
Apr 13, 2012 Apr 13, 2012

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.

10.4K
Translate
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
Guest
Apr 17, 2012 Apr 17, 2012

Makes sense...my wsdl is enforcing the ArrayOf<type_name>...

Guess i'll have to live with that

Thanks for the replys.

Translate
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
Valorous Hero ,
Apr 17, 2012 Apr 17, 2012

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.)

Translate
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
Guest
Apr 18, 2012 Apr 18, 2012

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.

Translate
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
Valorous Hero ,
Apr 18, 2012 Apr 18, 2012

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.

Translate
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 ,
Apr 16, 2012 Apr 16, 2012

What is the signature of the hello method? Could you show us the WSDL?

Translate
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 ,
Dec 17, 2012 Dec 17, 2012

Cool, how did you come up with root.string?  Trial and error??  I would love to know why root.string works.

Translate
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 ,
Dec 17, 2012 Dec 17, 2012

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.

Translate
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
Guest
Feb 10, 2013 Feb 10, 2013
LATEST

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.

Translate
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