ColdFusion / Java - “找不到构建方法”

时间:2012-08-06 03:39:08

标签: java coldfusion

我们正在使用一些org.apache类作为实现Web服务的WS Security的一部分。

variables.paths = arrayNew(1);
variables.paths[1] = getDirectoryFromPath(getCurrentTemplatePath()) & "lib\wss4j-1.5.8.jar";
variables.paths[2] = getDirectoryFromPath(getCurrentTemplatePath()) & "lib\xmlsec-1.4.2.jar";
variables.loader = createObject("component","lib.javaloader.JavaLoader").init(loadPaths=variables.paths,loadColdFusionClassPath=true);
variables.WSConstantsObj = loader.create("org.apache.ws.security.WSConstants");
variables.messageClass = loader.create("org.apache.ws.security.message.WSSecUsernameToken");
variables.secHeaderClass = loader.create("org.apache.ws.security.message.WSSecHeader");

以下代码:

<cfset var msg = getMessage()>  

产生

enter image description here

以下代码:

<cfset var secHeader = getSecHeader()>

产生

enter image description here

以下代码:

<cfset var env = soapEnv.getDocumentElement()>

产生

enter image description here

env.getOwnerDocument()

产生一个巨大的结构(太大而不能包含在这里),你可以view here

但是,以下代码:

<cfset e = msg.build(env.GetOwnerDocument(),secHeader)>

抛出错误:

 The build method was not found.
Either there are no methods with the specified method name and argument types or the build method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

然而,Build()方法肯定存在,根据第一个屏幕截图中的黄色突出显示。

错误消息谈到“...使用javacast函数来减少歧义”。如果这是问题,我将如何应用此解决方案?

1 个答案:

答案 0 :(得分:0)

并不是“build()”不存在,而是您的签名不正确。构建方法的两个参数是:

env.GetOwnerDocument(),secHeader

我们知道secHeader属于类

org.apache.ws.security.message.WSSecHeader

因为你的cfdump表明了这一点。

这可能意味着“env.GetOwnerDocument”没有返回该类的对象

org.w3c.dom.Document

它可能正在返回错误或原语或其他类。实例化envGetOwnerDocumet()并将其转储并检查该类。我认为它搞砸了方法签名。无论如何,这是我最好的猜测。

相关问题