我有一個CFC,我將使用?wsdl作爲SOAP Web服務訪問。Coldfusion Web服務無法看到組件
如果我直接在瀏覽器中調用CFC,我的結果呈現罰款:
http://server/webservice/calc.cfc?method=doStuff&foo=bar
如果我嘗試訪問它作爲一個Web服務:
ws = CreateObject("webservice", 'http://server/webservice/calc.cfc?wsdl');
result = ws.doStuff('bar');
我得到一個錯誤:
Cannot perform web service invocation doStuff.
The fault returned when invoking the web service operation is:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.xml.rpc.CFCInvocationException : [java.lang.ClassNotFoundException :
com.calculations.calc][java.lang.NullPointerException : null]]
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationException: [coldfusion.xml.rpc.CFCInvocationException : [java.lang.ClassNotFoundException :
com.calculations.calc][java.lang.NullPointerException : null]]
at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:733)
at coldfusion.xml.rpc.CFComponentSkeleton.__convertOut(CFComponentSkeleton.java:359)
at webservice.calc.doStuff(/var/www/vhosts/server/httpdocs/webservice/calc.cfc)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.r... ''
問題是因爲doStuff函數正在聲明其中的一個CFC實例:
remote struct function doStuff(foo) {
var objReturn = {};
objReturn.msg = 'A message';
// do a calculation
var objCalc = new com.calculations.calc(foo);
objReturn.calc = objCalc;
return objReturn;
}
所以我的CFC,我使用的Web服務得到了被聲明的函數內的另一個CFC。直接瀏覽我的web服務CFC工作正常,但嘗試使用CreateObject/webservice路由調用它失敗,因爲它不能創建組件的實例。
UPDATE:
如果我刷新頁面幾次,有時是錯誤的更改:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.xml.rpc.CFCInvocationException : [java.lang.ClassNotFoundException :
com.calculations.calc][coldfusion.xml.rpc.CFCInvocationException :
returnType must be defined for remote CFC functions.]]
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:coldfusion.xml.rpc.CFCInvocationException:
[coldfusion.xml.rpc.CFCInvocationException : [java.lang.ClassNotFoundException :
com.calculations.calc][coldfusion.xml.rpc.CFCInvocationException :
returnType must be defined for remote CFC functions.]]
at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:733)
at coldfusion.xml.rpc.CFComponentSkeleton.__convertOut(CFComponentSkeleton.java:359)
at webservices.TaxCalc.feed.getTaxCalc(/var/www/vhosts/server/httpdocs/webservice/calc.cfc)
at sun.reflect.Nat... ''
這是要求返回類型,但com.calculations的初始化FUNC .calc有返回這個;
錯誤消失,如果我註釋掉線** objReturnl.calc = objCalc **。它將聲明計算對象,但不允許我返回它。 – 2012-04-10 15:26:38