Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

If one cfinvoke a SOAP web service with param type sets to tns:ArrayOfString, one will get:

Cannot perform web service invocation Hello. The fault returned when invoking the web service operation is: ''java.lang.IlligalArgumentException: argument type mismatch

How to invoke a web service with type tns:ArrayOfString?

According to http://forums.adobe.com/message/4337438

This works:

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

now the question is, why does this work?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

Like I mentioned in the thread you referenced, there is no direct mapping of ArrayOfString. So it is essentially treated as a structure, just like any other complex type. If you look at the wsdl, ArrayOfString contains a single key named string, whose value is an array of type="s:string":

<s:complexType name="ArrayOfString">
   <s:sequence>
     <s:element minOccurs="0" maxOccurs="unbounded" 
           name="string" nillable="true" type="s:string" /> 
   </s:sequence>
</s:complexType>

So the CF code works because it creates a structure with the correct key name (string) and value type (array of strings).

    root.string = [ arrayOfStrings ];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...