使用ArrayOfint参数消耗wcf webservice [英] Consuming a wcf webservice with ArrayOfint paramenter

查看:789
本文介绍了使用ArrayOfint参数消耗wcf webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用WCF Web服务。

I am trying to consume a WCF webservice.

< cfdump> p>

<cfdump> shows the function as

getVwEmpByLocs(com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfint)

UPDATE:

<cfset wsUser = createobject("webservice", "http://xxxxxxx/cardService.svc?wsdl")>
<cfdump var="#wsUser#">

<cfset locationID = []>
<cfset locationID[1] = 2092>
<cfset stResult = wsUser.GetVwEmpByLocs(javacast('int[]', locationID))>

错误

消息参数类型不匹配

推荐答案

@Leigh和一些Google我发现了以下有关调试ColdFusion Web服务的文章。这个问题(和@Leigh指的是)特别感兴趣的是第2号(朝向页面底部)的项目符号项。如果引用的页面被删除,我将在这里包括该信息。

After reading the comments from @Leigh and a little Google'ing I found the following article about Debugging ColdFusion Webservices. Of particular interest for this question (and what @Leigh was referring too) is the bullet item under number 2 (towards the bottom of the page). I will include that information here in case the referenced page is ever removed.


如果你得到一个 java。 len.IllegalArgumentException:参数类型不匹配同时调用.Net webservice与 ArrayOfInt ArrayOfString 作为参数类型,那么很可能你没有正确地定义数据类型。 ArrayOfInt ArrayOfString 将使您相信.Net正在等待一个数组。但是记住ColdFusion数组和.Net数组不一样。如果仔细观察wsdl,你会注意到 ArrayOfInt 被定义为一个complexType名称。

If you are getting a java.lang.IllegalArgumentException: argument type mismatch while calling a .Net webservice with ArrayOfInt or ArrayOfString as the argument type, then most probably you are not defining the datatypes correctly. The ArrayOfInt and ArrayOfString will lead you to believe that .Net is expecting an Array. But remember ColdFusion arrays are not the same as .Net arrays. If you look at the wsdl carefully, you will notice that the ArrayOfInt is defined as a complexType name.



<s:complexType name="ArrayOfInt">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="int" type="s:int" />
</s:sequence>
</s:complexType>




CF中的复杂类型映射到结构。此外,你会注意到这个复杂类型有一个name =int的元素。现在,当java查看wsdl并创建存根类文件时,它将此元素重命名为_int。我的猜测是,它这样做,因为int是Java中的保留字,也是本机数据类型。所以这意味着要成功调用.Net webservice,您需要:

And complex types in CF are mapped to Structures. Further, you will notice that this complex type has an element with name="int". Now when java looks at the wsdl and creates the stub class files, its renaming this element to "_int". My guess is that its doing this because "int" is a reserved word in Java and also a native data type. So what this means is to successfully call the .Net webservice, you need:



<cfset objGroupIds = StructNew()>
<cfset objGroupIds._int = ListToArray("627303")>
<cfset callResult = myObj.getUser(objGroupIds)>

这篇关于使用ArrayOfint参数消耗wcf webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆