Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This page describes the steps for calling a web service using the REST protocol. This page also gives you background information on how web services work within the Blueriq architecture. There are two possibilities in Blueriq to define the data that is send to and from REST services. The first possibility is by using an XSD, and this works similar as in Chapter 4 - Calling a SOAP service. The second possibility is to define a domain schema.

The following steps are requiredpossible:

Table of Contents
maxLevel2
minLevel2

Using an XSD

This method can only be used for communicating with web services that send XML responses. If a different format such as JSON is required, you should use a domain schema.

Importing

In order to interpret an XML response from a REST web service, Blueriq needs to import an XSD. In contrast to SOAP, there may not be an explicit contract available for REST. You can use the API of the REST service to get XSD files.

Tip

If the REST service only gives example answers, you can generate an XSD file from the examples (see for instance http://www.freeformatter.com/xsd-generator.html).

Go to File → Import → Import XSD and provide the location of the XSD file. If you have multiple files (for example: your XSD is importing/including an XSD schema), provide a zip file with all needed files. This is essentially the same as importing a WSDL (Chapter 4 - Calling a SOAP service). Select the project for the import and you can choose whether to create a new module, or overwrite an existing one. The option 'Generate Domain' will automatically generate a domain model for you, based on the XSD schema. When this button is checked, entities, attributes and relations are created based on the type definitions in the XSD. When using an existing module, there may already be a domain model present, that uses identical names as in the XSD. When overwriting, conflicting elements are not created. Obviously, these problems do not occur if you use a new module. When 'Generate Domain' is unchecked, no domain model is generated for you. In that case, you can later match the elements from the XSD to you own domain (explained later). In general, it is advised to use a separate module in order not to mix the domain model for the web service with the domain of your business.

You should get the message that the import was successful.

Mapping with Domain Model

Open your project and go the module which contains the web service. The module now has a Schema Set. This item can be found in the bar on the left side of the screen, as can be seen below.

The Schema Set defines which entities, attributes and relations are used by the web service (they map the XSD to the domain model). This works exactly the same for REST and SOAP, and the description can be found here: Chapter 4 - Calling a SOAP service.

Using a domain schema

In version 9.2.6 we added a new element, the domain schema. This domain schema lets you define a representation of your domain that is used for the communication with a web service. An important point to notice is that the domain schema is independent of the representation, and projects can add implementations of any representation not covered out of the box (JSON, XML).

Image Added

Defining the REST service

...