Issue using .net web service from ColdFusion

独自空忆成欢 提交于 2019-12-12 13:28:06

问题


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, which is just a unique string to identify the user. This is no problem, as far as I can tell.

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

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)

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.

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

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.

The specific error I'm getting is:

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

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?

The service is written in .NET.


回答1:


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>


来源:https://stackoverflow.com/questions/15385642/issue-using-net-web-service-from-coldfusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!