I've noticed the following *pattern* in a SOAP WS which I'd like to share with you and have ur input please :)
Assume the signature of a method of a WS being the following:
public boolean getSum(int x, int y, int sum)
As you can see the given method calculates the sum of x and y but it does not return the result to the client but instead the client access the value of sum via reference.
The return type of boolean is used so that the client can know if calculation of the sum was succesful or not.
I'd like to ask under which circumstances is the above approach suitable as well as the pros/cons.
public boolean getSum(int x, int y, javax.xml.rpc.holders.IntHolder sum)
sum.value = x+y;
IntHolder sum = new IntHolder();
boolean suc = xxx.getSum(1,2,sum);
int result = sum.vlaue;
sigates ouyang, thanks for ur comment.
What you wrote is exactly right, but I'm more concern (as I said in my first post) on whether or not it's common practise, plus its pros/cons :)
I think it's common practise.
In fact, use hodler will be more efficient then use exception
Just my point.
You should throw an exception for very exceptional case like be unable to do a summation.