Creating Web Service Methods

You can create web service Jade methods only for web service classes.

Methods declared on the JadeWebService class and its subclasses that are marked as web service methods cannot have a return type of Any and cannot have parameters of type Any. (See also "webService Option" under "Method Options", in Chapter 1.)

For details about defining a Jade method for a non-web service class, see "Defining and Compiling Jade Methods and Conditions", in Chapter 4 of the Development Environment User's Guide.

To define a web services Jade method

  1. In the Class List of the Class Browser, click on the subclass of the JadeWebService class or one of its subclasses to which the method is to be added.

  2. Select the New Jade Method command from the Methods menu. The Jade Method Definition dialog is then displayed.

    The Web Services check box is enabled only when a subclass of the JadeWebService class or one of its subclasses is selected in the Class List.

  3. Uncheck the Web Services check box if you do not want the Jade method to be a web services method. This check box is checked by default for web services classes.

When you click the OK button on the Jade Method Definition dialog and the Web Services check box is checked, the signature of your method in the editor pane then includes the webService method option. For example, if you defined a getClients method, the method signature that is created initially is as follows.

getClients(): webService;

The following is an example of a getClient method defined in the ErewhonInvestmentsService subclass of the JadeWebServiceProvider class.

getClient(clientName: String): Client webService;
vars
    client: Client;
begin
    client := app.myCompany.allClients[clientName];
    if client = null then
        setError(23, clientName, 'Client does not exist');
    endif;
    return client;
end;

You can add or remove the webService method option, which toggles the type of method (that is, to change it from a web services method to a Jade method, or the reverse).

You can specify any type of parameter (that is, constant, input, io, or output) for a web services method. For details, see "Parameters", in Chapter 1.

The method does not require a return value because the web service uses the HTTP protocol (which always requires a response) and a reply is always sent to the web service consumer. Primitive parameters that are io or output are also sent back in the response as are object parameters that are not constant.

Jade timestamp values use the local time zone. External web service consumers often expect Coordinated Universal Time (UTC) values and external web service providers often return UTC values. You may need to convert between UTC and local timestamp values using the localToUTCTime and utcToLocalTime methods of the TimeStamp primitive type.