简体   繁体   中英

Grails groovy application for websevices

I have an employee services hosted, the client jar is availabe in my lib and I need to hit the employee service methods.

I need to develop a web app using grails and groovy.

I have done some web apps in grails but I'm not able to figure out on how to go with web serices call.

Where should I place this service call related code: In controller, service?

After I get the response I need to show them in UI and some inserts to db via hiberante.

Please suggets me.

As a general rule you should to try to keep your controllers as slim as possible. You should probably put that code in a service class.

Simple Service class example:

class WebServiceService {
    def getEmployeeData(id) {
        // Read record and/or update domain objects
    }
}

Simple Controller example:

class EmployeeController {
    def webServiceService

    def view = {
        def employee = webServiceService.getEmployeeData(params.id)
        [employee: employee]
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM