ColdFusion 2016 中的 Web 服务不再起作用

Web Services in ColdFusion 2016 no longer functional

我正在从 ColdFusion 9 升级到 ColdFusion 2016,我的 Web 服务突然不再工作。我相信这是因为 Axis 2 是在 Cold Fusion 10 中引入的,它使我现有的 Web 服务无法正常工作。

即使我在 ColdFusion Administrator 中将 Web 服务版本设置回 1,它仍然不起作用。

我调用这些 Web 服务的方式是使用 createObject 函数:

<cfscript>
    objSoapHeader = XmlParse("<wsse:Security mustUnderstand=""true"" xmlns:wsse=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""><wsse:UsernameToken><wsse:Username>USERNAME</wsse:Username><wsse:Password>PASSWORD</wsse:Password></wsse:UsernameToken></wsse:Security>");

    Application.UserWebService = CreateObject("webservice", PATH & "Requests/UserService.asmx?WSDL");
    addSOAPRequestHeader(Application.UserWebService,"","",objSoapHeader,true);

    // Get the .Net resources
    Application.NetResources = Application.UserWebService.GetNetResources(); 

</cfscript>

我收到的错误是:

Cannot perform web service invocation GetNetResources.

The fault returned when invoking the web service operation is:java.lang.RuntimeException: Error obtaining parser from data source:LanguageHeader cannot be null!

说明LangaugeHeader不能是null。 WSDL 显示与 GetNetResources 操作关联的两条消息:

<wsdl:portType name="UserServiceSoap">
    <wsdl:operation name="GetNetResources">
        <wsdl:input message="tns:GetNetResourcesSoapIn"/>
        <wsdl:output message="tns:GetNetResourcesSoapOut"/>
    </wsdl:operation>
</wsdl:portType >

但是,在查看消息列表时,我可以看到三个与 GetNetResources 关联的消息:

<wsdl:message name="GetNetResourcesSoapIn">
    <wsdl:part name="parameters" element=tns:GetNetResources"/>
</wsdl:message>
<wsdl:message name="GetNetResourcesSoapOut">
    <wsdl:part name="parameters" element=tns:GetNetResourcesResponse"/>
</wsdl:message>
<wsdl:message name="GetNetResourcesLanguageHeader">
    <wsdl:part name="parameters" element=tns:LanguageHeader"/>
</wsdl:message>

如果操作仅指定两条消息,那么第三条消息在 WSDL 文件中的哪个位置与操作关联?

LanguageHeader 参数似乎在 ColdFusion 2016 中是绝对必需和强制执行的,那么为什么它在 ColdFusion 9 (Axis 1) 中起作用?

编辑 1

为了回答我上面的第一个问题(划线),我在 binding 中找到了以下代码,而不是 portType:

<wsdl:binding name="UserServiceSoap" type="tns:UserServiceSoap">
    <wsdl:operation name="GetNetResources">
        <soap:operation style="document" soapAction="http://tempuri.org/GetNetResources"/>
        <wsdl:input>
            <soap:body use="literal"/>
            <soap:header message="tns:GetNetResourcesLanguageHeader" use="literal" part="LanguageHeader"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

然而,这仍然没有回答我的第二个问题。

编辑 2

稍微修改一下代码后,我设法通过向网络服务调用添加变量来解决 RuntimeException

args = {TEST="<locale>en-CA</locale>"};
Application.NetResources = Application.UserWebService.GetNetResources(argumentCollection=args);

现在导致以下错误:

Web service parameter name languageHeader cannot be found in the provided parameters {TEST}.

由于 TEST 不是 WSDL 中指定的实际参数,我将其修改为 languageHeader,并收到此新错误:

Web service operation GetNetResources with parameters {LANGUAGEHEADER={<locale>en-CA</locale>}} cannot be found.

这说明languageHeader确实是正确的参数名,但是仍然找不到web服务操作,所以我认为参数的'type'是不同的。

也许我不应该发送一个字符串作为值,但是回顾我的 WSDL,它指出 Locale 的类型是一个字符串:

<wsdl:types>
    <s:schema targetNamespace="http://tempuri.org/" elementFormDefault="qualified">
        <s:element name="LanguageHeader" type="tns:LanguageHeader"/>
        <s:complexType name="LanguageHeader">
            <s:sequence>
                <s:element name="Locale" type="s:string" maxOccurs="1" minOccurs="0"/>
            </s:sequence>
            <s:anyAttribute/>
        </s:complexType>
    </s:schema>
</wsdl:types>

据我所知,我想发送一个 complexType 对象作为参数,其中包含一个 Locale 作为字符串。

如果是这样的话,我将从 CFML 发送什么样的对象?

consuming a web service with a parameter of a complex data type时,发送一个structure作为参数。

// Create struct
stLanguageHeader = structNew();
stLanguageHeader.locale = "en-CA";

Application.NetResources = Application.UserWebService.GetNetResources(stLanguageHeader);