Can (Should) I call a WebService from a Spring MVC app? -


i don't know details webservice. assume (due authentication layer , response format) code below web service in spring mvc

@requestmapping(value = "/rest/member/account",produces={"application/json"}, method=requestmethod.get) public  @responsebody string getaccountinfo() {     jsonobject account = new jsonobject();     // queries local db     account = restaccountservice.accountjson();     return account.tostring(); } 

now need modify above code webservice different application. webservice not exist yet, thinking of creating spring mvc earlier function.

maybe below

... // called webservice different application somewebservice webservice = new somewebservice(); boolean valid = webservice.checkifuservalid(username,password); .... //this queries local db if (valid)   account = restaccountservice.accountjson(); ... 

my questions are

  1. is above common way ?
  2. how handled authentication access other webservice ? because need ensure call must come originating app.