You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

soapUI可调用Oracle Cloud SOAP接口,ColdFusion调用失败求助

修复ColdFusion调用Oracle Cloud SOAP服务的问题

问题背景

SOAP服务对应的WSDL地址为:

https://hiddenurl.oraclecloud.com/foundationParties/PersonService?wsdl

在soapUI中可正常调用processPerson方法获取结果,但ColdFusion代码调用时无法得到预期结果,且尝试其他代码时出现Stub编译错误。

当前ColdFusion代码问题

你当前的代码存在逻辑错误:用GET请求获取WSDL内容,而非调用SOAP服务;且getSOAPRequest并非ColdFusion标准函数,服务端点地址也与WSDL不符。代码如下:

<cftry>
    <cfscript>
        httpService = new http();
        httpService.setUrl("https://hiddenurl.oraclecloud.com/foundationParties/PersonService?wsdl");
        httpService.setMethod("GET");
        httpService.addParam(type="header", name="Authorization", value="Basic skhdgfkfsdfhskdfh");
        httpService.addParam(type="header",name="Content-Type",value="application/xml");
        httpService.addParam(type="header", name="SOAPAction", value="");
        result = httpService.send().getPrefix();
        writeDump(xmlparse(result.FileContent));
        ws = getSOAPRequest('https://hiddenurl.oraclecloud.com:443/crmService/FoundationPartiesPersonService');
        writedump(ws);
    </cfscript>
    <cfcatch>
        <cfif cfcatch.message contains "Could not perform web service invocation">
            No records found.
            <Cfdump var="#cfcatch#">
        <cfelse>
            Unexpected error in invocation of web service.<cfdump var="#cfcatch#">
        </cfif>
        <cfabort>
    </cfcatch>
</cftry>

Stub编译错误详情

尝试第三方代码时出现Axis2生成Stub的编译错误:

C:\ColdFusion2021\cfusion\stubs\WS_-1374943156_2\src\org\w3\www\_2001\xmlschema\AnySimpleType.java:81: error: cannot find symbol
 if (local==null){
 ^
symbol: variable local
location: class AnySimpleType
C:\ColdFusion2021\cfusion\stubs\WS_-1374943156_2\src\org\w3\www\_2001\xmlschema\AnySimpleType.java:87: error: cannot find symbol
xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(local));
^
symbol: variable local
location: class AnySimpleType
C:\ColdFusion2021\cfusion\stubs\WS_-1374943156_2\src\org\w3\www\_2001\xmlschema\AnySimpleType.java:277: error: cannot find symbol
org.apache.axis2.databinding.utils.ConverterUtil.convertToString(local)
^
symbol: variable local
location: class AnySimpleType
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\ColdFusion2021\cfusion\stubs\WS_-1374943156_2\src\com\oracle\xmlns\apps\cdm\foundation\parties\personservice\applicationmodule\PersonServiceStub.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors

解决方案

方案1:手动构造SOAP请求(推荐,避免Stub生成问题)

直接模拟soapUI的请求逻辑,用cfhttp发送POST请求:

<cftry>
    <cfscript>
        // 从soapUI复制完整的SOAP请求体(替换为你的实际参数)
        soapBody = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:per="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/applicationModule/">
   <soapenv:Header/>
   <soapenv:Body>
      <per:processPerson>
         <!--- 此处添加与soapUI一致的请求参数 --->
         <per:person>
             <!--- 示例参数,根据实际需求修改 --->
             <per:PersonNumber>12345</per:PersonNumber>
         </per:person>
      </per:processPerson>
   </soapenv:Body>
</soapenv:Envelope>';

        httpService = new http();
        // 使用服务端点地址(非WSDL地址)
        httpService.setUrl("https://hiddenurl.oraclecloud.com/foundationParties/PersonService");
        httpService.setMethod("POST");
        // Basic认证头(确保编码正确)
        httpService.addParam(type="header", name="Authorization", value="Basic skhdgfkfsdfhskdfh");
        // SOAP请求的Content-Type
        httpService.addParam(type="header", name="Content-Type", value="text/xml;charset=UTF-8");
        // 从soapUI获取正确的SOAPAction值(不要留空)
        httpService.addParam(type="header", name="SOAPAction", value="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/applicationModule/processPerson");
        // 添加SOAP请求体
        httpService.addParam(type="body", value=soapBody);
        
        result = httpService.send();
        writeDump(xmlparse(result.FileContent));
    </cfscript>
    <cfcatch>
        <cfdump var="#cfcatch#">
        <cfabort>
    </cfcatch>
</cftry>

方案2:修复Stub编译错误

如果必须使用WebService代理对象,解决步骤如下:

  1. 手动生成Stub:使用最新版Axis2工具(避免ColdFusion内置Axis2的bug)重新生成Java Stub,针对WSDL中的AnySimpleType定义调整生成参数。
  2. 打包部署:将生成的Java类打包为JAR文件,放入ColdFusion的cfusion/lib目录,重启ColdFusion。
  3. 调用Stub:通过createObject("java")调用生成的Stub类,而非ColdFusion自动生成的Stub。

关键注意事项

  • 确保服务端点地址与soapUI中使用的一致(不要混淆WSDL地址和服务地址)。
  • SOAPAction头必须与soapUI中的值完全匹配,不可留空。
  • Basic认证的Authorization值需确保是用户名:密码的Base64编码结果。

内容的提问来源于stack exchange,提问作者cf-uuser

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 01:03:12