Web服务 – ColdFusion 2016中的Web服务不再运行

我从ColdFusion 9升级到ColdFusion 2016,我的Web服务突然不再工作.我相信这是因为Axis 2在Cold Fusion 10中引入,并且它使我现有的Web服务不起作用.

即使我在ColdFusion管理员中将Web Service版本设置为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不能为空. 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文件中的哪个第三个消息与操作相关联?

ColdFusion 2016中的LanguageHeader参数似乎是绝对必需的,所以为什么在ColdFusion 9(Axis 1)中工作?

编辑1

为了回答我上面的第一个问题(striked out),我发现绑定中的以下代码与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

在玩了一段代码之后,我通过向Web服务调用添加一个变量来管理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,发送结构作为参数.
// Create struct
stLanguageHeader = structNew();
stLanguageHeader.locale = "en-CA";

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

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些