web services - How to return 2 values in webservices using java? -


i learning web services netbeans , did program stock price calculation. need return 2 values display price , profit/loss.

but cant able return 2 values. need return c variable. please help!!.

package test;  import javax.jws.webservice; import javax.jws.webmethod; import javax.jws.webparam; import javax.ejb.stateless;   @webservice(servicename = "gold") @stateless() public class gold { int a,c;   @webmethod(operationname = "hello") public string hello(@webparam(name = "name") string txt) {     return "hello " + txt + " !"; }   @webmethod(operationname = "calc") public int calc(@webparam(name = "grams") int grams, @webparam(name = "time") int time) {     //todo write implementation code here:     if(time>11){     a=grams*100;     c=(grams*100-grams*80);     }     else if(time<11)     {     a=grams*80;     c=(grams*80-grams*100);     }      return a; } } 

could implement this:

public class priceinfo {   public int price;   public int profitorloss; }  @webmethod(operationname = "calc") public priceinfo calc(@webparam(name = "grams") int grams, @webparam(name = "time") int time) {     //todo write implementation code here:     if(time>11){     a=grams*100;     c=(grams*100-grams*80);     }     else if(time<11)     {     a=grams*80;     c=(grams*80-grams*100);     }      priceinfo result = new priceinfo();     result.price = a;     result.profitloss = c;               return result; } 

please double check code not java-programmer


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -