简体   繁体   English

使用ColdFusion中的.net Web服务发布问题

[英]Issue using .net web service from ColdFusion

I've been running into some challenges with a web service I'm trying to use of from ColdFusion. 我一直在尝试使用ColdFusion中使用的Web服务遇到一些挑战。 The service (AccountsService), has a method, GetAccountLinksByUser that returns accounts associated with a given user. 服务(AccountsService)有一个方法GetAccountLinksByUser,它返回与给定用户关联的帐户。 This method accepts two arguments: 此方法接受两个参数:

  • UPN, which is just a unique string to identify the user. UPN,它只是识别用户的唯一字符串。 This is no problem, as far as I can tell. 据我所知,这没问题。

  • sourceType. sourceType的。 This is ultimately a string, but is defined in the WSDL as simple type with one of three possible values. 这最终是一个字符串,但在WSDL中定义为具有三个可能值之一的简单类型。 Here's a relevant sections of XML from the WSDL: 这是来自WSDL的XML的相关部分:

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

The problem is that I can't seem to just pass the string "All", "Manual", or "System" into the web service. 问题是我似乎无法将字符串“All”,“Manual”或“System”传递到Web服务中。 The stub that CF generates has the following signature for this method: CF生成的存根具有以下此方法的签名:

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

This appears to suggest that I need to pass in an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType. 这似乎表明我需要传入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. 但是,我无法创建该类型的实例(很容易),因为它似乎不在CF搜索的类路径中。 I tried wrapping the classes that CF generates into the /stubs directory into a jar and putting them in a class path. 我尝试将CF生成的类包装到/ stubs目录中,并将它们放入类路径中。 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. 这确实有效,因为我现在可以创建一个org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType的实例,但我仍然无法将其传递给getAccountLinksByUser方法。

As requested, here is the code I'm using to call the web service: 根据要求,这是我用来调用Web服务的代码:

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

More information. 更多信息。 The publisher of the web service does not publish their WSDL publicly. Web服务的发布者不公开发布其WSDL。 This was emailed to me and I'm loading the WSDL from my my local development site. 这是通过电子邮件发送给我的,我正在从我的本地开发站点加载WSDL。

The specific error I'm getting is: 我得到的具体错误是:

Cannot perform web service invocation getAccountLinksByUser. 无法执行Web服务调用getAccountLinksByUser。 The fault returned when invoking the web service operation is: 调用Web服务操作时返回的错误是:

Cannot perform web service invocation getAccountLinksByUser. 无法执行Web服务调用getAccountLinksByUser。 The fault returned when invoking the web service operation is: '' java.lang.IllegalArgumentException: argument type mismatch 调用Web服务操作时返回的错误是:''java.lang.IllegalArgumentException:参数类型不匹配

I'm not really sure where to head at this point. 我不确定在这一点上要去哪里。 Any suggestions? 有什么建议么?

The service is written in .NET. 该服务是用.NET编写的。

I ran a few tests and it seems related to the switch to Axis2 in CF10. 我运行了一些测试,这似乎与CF10中的Axis2切换有关。 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: 我真的不知道1和2之间到底是什么约枚举的改变。然而,设置版本级别回轴1应该做的伎俩:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM