Click or drag to resize
Custom webservices

[This is preliminary documentation and is subject to change.]

In TOPICA it is possible to create configuration specific custom web services.

This topic contains the following sections.

Purpose of custom web services

Use this in order to implement custom processing that cannot easily be implemented using build-in web services or auto generated web services

That is: consider using a web service that comes "out of the box" before writing your own.

Configuration

Remember that one instance of TOPICA (i.e. one "web home") may contain mulitiple configuration. Each configuration points to its own database. In ther words: one configuration defines an environment (application + database).

Almost all web methods should work on one specific configuration. Therfore, it is a convention in TOPICA, that the first parameter to all web methods is config (type string).

Context

When building a custom web service in a TOPICA application, you have access to all classes, properties, methods, etc. inside TOPICA. To use this functionality, some context must be set up - in TOPICA terms, you must create a ContextWrapper object.

Log in

Most operations inside TOPICA require, that a user is logged in (e.g. a valid session must exist). Regardless whether the user is an employee user or a patient user, the session is identified by a token called "session guid". There are 2 ways to create a session (and thus obtain a valid session guid):

  • The "standard" way is to use the built-in LoginService to log in. The methods in this service return a session guid, that may be used in subsequent web service calls. It is a convention in TOPICA, that the second parameter to each web method is sessionGuid. This is the only way a session may be used for more than one web service call. The methods in the built-in web services are designed this way, It is recommended that custom web services are built the same way.

  • As an alternative, it is possible to let a custom web service method log in by it self. In this scenario, domain, user name and password must be passed as parameters. Because each call to the web method logs in, it should automatically log out before exiting. Otherwise, calling this web method N times will result in N "open" sessions.

Using the correct layer

When building a custom web service in a TOPICA application, you have access to all classes, properties, methods, etc. inside TOPICA. To use this functionality, some context must be set up - in TOPICA terms, you must create a ContextWrapper object.

When browsing trough the TOPICA code, you will notice, that many operations can be done in 2 ways:

  • Using classes in the CSC.SC.TOPICA4.Controllers namespace. (the "controller layer").

  • Using classes in the CSC.SC.TOPICA4.Library namespace (the "business object layer").

Using the "controller layer" handles transaction logging, caching etc. - using the "business object layer" does not. Therefore: always use the "controller layer" (unless you know exactly what you are doing, e.g. you do not want transaction logging!).

Example

TODO: