Chapter 3. Service Layer Recipes

Table of Contents

1. Creating a Service or Business Facade
2. Creating an Operation
3. Implementing an Operation using Actions and Steps
4. Creating a Contract-First JAX-WS Web service (SOAP)
5. Publishing a JAX-WS Web service (SOAP)
6. Publishing a AJAX service using DWR
7. Consuming a SOAP Web service
8. Consuming a REST Web Service
9. Using Java Code, Spring Beans and Groovy with Services
10. Using Groovy in Actions
11. Accessing Data using Groovy

The service layer, also referred to as the business layer, encapsulates the course-grained functionality of the application being built. The web layer is the primary consumer of the service layer, and the artifacts for defining the service layer in Skyway Builder are the Services, Operations, Actions, and Steps.

1. Creating a Service or Business Facade

PROBLEM

The logic found in a typical web application is associated with either (a) the behaviour of the application or (b) the business logic. While a Controller and associated Actions can be used to implement the both the behavior and business logic, the MVC pattern prescribes that the controller layer should be focussed on implementing the behaviour of the application, and the service layer focusses on implementing the business logic.

SOLUTION

The Service layer represents the core functionality of the application being built, and the functionality represented by this layer is accessed in an API type manner using structured inputs and outputs. A Skyway Service is an artifact that defines a set of functions. Functions are application logic that use structured inputs and outputs for exchanging data. In Skyway development the functions are defined as Operations, and the logic is implemented using Actions.

HOW IT WORKS

Skyway Builder has adopted the SOAP lexicon (services and operations) for describing and implementing the Service layer of an application. This doesn't mean that web services are being used for invocation. Skyway will use java invocation by default. However Skyway Services can also be exposed as web services by configuration, in which case the Skyway Service concepts map exactly to the equivalent web service concepts.

Steps for creating a Service:

  1. Right click on a Model Package, and select New-->Service.

  2. From the New Skyway Service Wizard, enter a common name for the service. The common name is used to reference the service from other artifacts.

  3. When done, click Finish to open the Service Editor.

RELATED RECIPES