如果将参数类型设置为 tns:ArrayOfString
的 cfinvoke
SOAP Web 服务,将得到:
Cannot perform web service invocation Hello. The fault returned when invoking the web service operation is: ''java.lang.IlligalArgumentException: argument type mismatch
如何调用 tns:ArrayOfString
类型的 Web 服务?
根据http://forums.adobe.com/message/4337438
这有效:
<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>
现在的问题是,为什么这会起作用?
最佳答案
就像我在您引用的线程中提到的那样,有 no direct mapping ArrayOfString
。因此,它本质上被视为一种结构,就像任何其他复杂类型一样。如果您查看 wsdl,ArrayOfString
包含一个名为 string
的键,其值是 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>
所以 CF 代码可以工作,因为它创建了一个具有正确键名(string
)和值类型(字符串数组)的结构。
root.string = [ arrayOfStrings ];
关于web-services - ColdFusion 中应该使用什么来映射到 SOAP 类型 tns :ArrayOfString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13941422/