Copy link to clipboard
Copied
This question is also up on stack overflow: http://stackoverflow.com/questions/10089962/coldfusion-web-service-failing-to-see-component
I've got a CFC that I'm going to access with ?wsdl as a SOAP webservice.
If I call the CFC directly in a browser, my results render fine:
http://server/webservice/calc.cfc?method=doStuff&foo=bar
If I try to access it as a web service:
ws = CreateObject("webservice", 'http://server/webservice/calc.cfc?wsdl');
result = ws.doStuff('bar');
I get an error:
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... ''
The problem is because the doStuff function is declaring an instance of a CFC inside it:
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;
}
So my CFC that I'm using as a webservice has got another CFC being declared inside a function. Browsing directly to my webservice CFC works fine, but trying to call it using the CreateObject/webservice route fails, as it can't create an instance of the **com.calculations.calc** component.
It doesn't error, wierdly, if I comment out the objReturn.calc = objCalc line. So it seems I can create the instance, but the error isn't thrown till I assign it to my return struct.
Also I've found, If I refresh the page a few times, sometimes the error changes to:
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... ''
Message was edited by: PeteComcar - impvoed code formatting and added returntype update
Copy link to clipboard
Copied
Ok this doesn't really answer the question as to why the error was being thrown, but I've found a workaround. Instead of using this code:
objReturn.calc = objCalc;
I've used this instead:
objReturn.calc.arrOne = objCalc.getArrOne();
objReturn.calc.arrTwo = objCalc.getArrTwo();
And it's working fine. I guess the problem is something to do with the fact that the component can't be translated into data for the WSDL. I was thinking of the CFC as a struct, which it isn't as it has loads of methods attached to it.
So I shouldn't be trying to assign the CFC, I should be using the accessors to access the data inside the CFC.
Answer also on Stack Overflow: http://stackoverflow.com/questions/10089962/coldfusion-web-service-failing-to-see-component/
Copy link to clipboard
Copied
PeteComcar wrote:
Instead of using this code:
objReturn.calc = objCalc;
I've used this instead:
objReturn.calc.arrOne = objCalc.getArrOne();
objReturn.calc.arrTwo = objCalc.getArrTwo();
And it's working fine.
I think ColdFusion is trying to tell you something. The first alternative suggests objCalc is a simple value, array or struct, which you attempt to store in a struct. The second suggests objCalc is an instance of a component.
Copy link to clipboard
Copied
objCalc is an instance of a component. I've solved it by using accessors to get the data I need instead of returning the instance, whcih just seems wrong now I think about it anyway.
Copy link to clipboard
Copied
objCalc is an instance of a component. I've solved it by using accessors to get the data I need instead of returning the instance, whcih just seems wrong now I think about it anyway.
Which version of CF are you running?
--
Adam
Copy link to clipboard
Copied
CF9, on a Red Hat LAMP stack.
Copy link to clipboard
Copied
Dear All Technology Expert's,
I have a query related to Coldfusion SOAP services, that is most commonly asked in all the forum's but NONE of them has got answer.
If there is NO solution so I think Adobe has to come up with some patches so developer can able to do some customization.
I like to share with you all, in all other language ( PHP, JAVA, .NET etc) this option is available and you can customize the error.
Ok let me again explain the very basic error:
SOAP Request:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.Exception: Body not found.</faultstring>
<detail>
<ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.lang.Exception: Body not found.
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:121)...</ns1:stackTrace>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">Coldfusion Error</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
HOW we can customize the error, in all other languages you can simple customize the error like
Other languages SOAP response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>BODY_NOT_FOUND</faultcode>
<faultstring>Body is missing in your request</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
But the same is NOT possible in Coldfusion, right?
AS you know it is vulnerability to display exception messages in the response.
We are developing this web service to access from other language website (PHP, .NET).
We are also planning to upgrade server the Coldfusion 11, but do you think there is any solution with latest Coldfusion version.
Please response only if you know about these issue's or solution.
Thanks
Niyaz
Copy link to clipboard
Copied
@Niyaz
This thread started in 2012, and is therefore old. Please start a new thread for your discussion.