使用ColdFusion的.net Web服务问题 [英] Issue using .net web service from ColdFusion

查看:134
本文介绍了使用ColdFusion的.net Web服务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ColdFusion的Web服务遇到一些挑战。服务(AccountsService)有一个方法,GetAccountLinksByUser返回与给定用户相关联的帐户。此方法接受两个参数:

I've been running into some challenges with a web service I'm trying to use of from ColdFusion. The service (AccountsService), has a method, GetAccountLinksByUser that returns accounts associated with a given user. This method accepts two arguments:


  • UPN,它只是用于标识用户的唯一字符串。这是没有问题,就我所知。

  • UPN, which is just a unique string to identify the user. This is no problem, as far as I can tell.

sourceType。这最终是一个字符串,但在WSDL中定义为具有三个可能值之一的简单类型。下面是来自WSDL的XML的相关部分:

sourceType. This is ultimately a string, but is defined in the WSDL as simple type with one of three possible values. Here's a relevant sections of XML from the WSDL:

<xsd:simpleType name="SourceType">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="All"/>
        <xsd:enumeration value="Manual"/>
        <xsd:enumeration value="System"/>
    </xsd:restriction>
</xsd:simpleType>

问题是我似乎不能传递字符串All ,手动或系统导入Web服务。 CF生成的存根具有此方法的以下签名:

The problem is that I can't seem to just pass the string "All", "Manual", or "System" into the web service. The stub that CF generates has the following signature for this method:

getAccountLinksByUser(java.lang.String, org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType)

这似乎暗示我需要传入一个实例of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType。但是,我不能创建该类型的实例(容易),因为它看起来不是在CF搜索的类路径。我尝试将CF生成的类包装到/ stubs目录中,并放入一个类路径中。这做了,我现在可以创建一个org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType的实例,但我仍然无法将其传递到getAccountLinksByUser方法。

This appears to suggest that I need to pass in an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType. However, I can't create an instance of that type (easily) as it doesn't appear to be in a class path that CF searches. I tried wrapping the classes that CF generates into the /stubs directory into a jar and putting them in a class path. This did work, in that I could now create an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType, but I was still unable to pass that into the getAccountLinksByUser method.

根据请求,这里是我用来调用Web服务的代码:

As requested, here is the code I'm using to call the web service:

<cfset accountsService = CreateObject("WebService", "http://local.hostname/libraries/com/foo/bar/staging/AccountsService.wsdl") />
<cfset SourceType = CreateObject("java", "org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType") />
<cfset accounts = accountsService.getAccountLinksByUser("username@domain", SourceType.All) />

详细信息。 Web服务的发布者不会公开发布其WSDL。这是通过电子邮件发送给我,我从我的本地开发网站加载WSDL。

More information. The publisher of the web service does not publish their WSDL publicly. This was emailed to me and I'm loading the WSDL from my my local development site.

我得到的具体错误是:

无法执行Web服务调用getAccountLinksByUser。
调用Web服务操作时返回的错误是:

Cannot perform web service invocation getAccountLinksByUser. The fault returned when invoking the web service operation is:


无法执行Web服务调用getAccountLinksByUser。调用Web服务操作时返回的错误
是:'
java.lang.IllegalArgumentException:参数类型不匹配

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

我真的不知道在这一点上哪里。有任何建议吗?

I'm not really sure where to head at this point. Any suggestions?

该服务是用.NET编写的。

The service is written in .NET.

推荐答案

我跑了几个测试,它似乎与切换到Axis2在CF10相关。我真的不知道确切的什么枚举的1和2之间的变化。但是,版本级别设置回Axis1应该做的诀窍:

I ran a few tests and it seems related to the switch to Axis2 in CF10. I am honestly not sure exactly what about enumeration's changed between 1 and 2. However, setting the version level back to Axis1 should do the trick:

<cfscript>
     args = { refreshWSDL=true, wsversion=1 };
     ws = createObject("webservice", "http://mysite/test.asmx?wsdl", args);
     result = ws.getAccountLinksByUser("test@somewhere.com", "All");
     writeDump(result);
</cfscript>

这篇关于使用ColdFusion的.net Web服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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