Using Service to return more than one value?

Hi, it’s possible to use a Service to return more than one value?

I’ve maked in my app, a service that returns the totallineamount. But i need too the totallineamountwithVat (includes taxes) .

It’s possible, or i need to create 1 Service with more Instances?

Ivan,
I suggest to create a class Price with all the fields you need (Net,Gross,VAT, discount, etc)
And make the service return the instance of the class.

Thanks Alex, have you any example?

I don’t know to call a service and get results of the class with all Values.

Hi Ivan,

here’s an example of the above described.

In Java it’s not possible to return multiple values from a function. Nevertheless, as Alex said, you can either use a Class or a Map / List to return different values. Classes make most sense.

If you really want to return multiple values, you can use groovy for that: https://rosettacode.org/wiki/Return_multiple_values#Groovy

Bye,
Mario

Hi Mario, the link to example goes to website: http://www.tutorialspoint.com/codingground.htm

Right, it shows three files: “Service.groovy”, “TotalAmount.groovy” and “main.groovy”. The main executes the service to get back an instance of TotalAmount. The example is in groovy but you can use the exact same code to implement it in java.

Thanks!