You need to sign in to do that
Don't have an account?
Bernard Farrell
What does 'Non-void method might not return a value' mean?
I'm trying to call an external web service from Apex.
The web service call returns an array of objects. So the generated Apex definition for the call is something like:
public class testWsdl {
public class CalculationPort {
public testWsdl.ComputedType[] calculate(DateTime start,DateTime end_x,DateTime now)
...
When I invoke it, I use the following code (declarations omitted for clarity):
testWsdl.CalculationPort stub = new testWsdl.CalculationPort();
testWsdl.ComputedType[] results = stub.calculate( start, end_x, now);
I get the following error on the second line:
Non-void method might not return a value
I have no idea what this means. I've also tried the following code:
testWsdl.ComputedType[] results = testWsdl.ComputedType[0];
results = stub.calculate( start, end_x, now);
And I get exactly the same error.
I think I understand what the error means, that the variable results may be null after the call has completed.
My question is, how do I get rid of the error?
The web service call returns an array of objects. So the generated Apex definition for the call is something like:
public class testWsdl {
public class CalculationPort {
public testWsdl.ComputedType[] calculate(DateTime start,DateTime end_x,DateTime now)
...
When I invoke it, I use the following code (declarations omitted for clarity):
testWsdl.CalculationPort stub = new testWsdl.CalculationPort();
testWsdl.ComputedType[] results = stub.calculate( start, end_x, now);
I get the following error on the second line:
Non-void method might not return a value
I have no idea what this means. I've also tried the following code:
testWsdl.ComputedType[] results = testWsdl.ComputedType[0];
results = stub.calculate( start, end_x, now);
And I get exactly the same error.
I think I understand what the error means, that the variable results may be null after the call has completed.
My question is, how do I get rid of the error?
The method that I was invoking was the last executable statement in a String function that I had defined.
I'd forgotten to put a return statement in the method. The error that was reported should have said something like "String function xxx does not contain a return value".
Because it didn't give the name of the method causing the error I was looking in the wrong place.
I got the same error, and it was badly worded for me to.
I thought there was an issue with a function that got called in the code block, but it was actually the function defined in the code block.
In any case it should point to the beginning or end of the method.