Skip to main content

xSuite Interface Windows Prism 5.x – Online Help

Mockup Web Service

Notice

The Mockup Web Service is not designed for productive use. This web service should only be used for temporary tests.

The Mockup Web Service is a dummy service with a limited ability to simulate the behavior of a third-party web service. This web service can be used if a third-party web service is not available but a corresponding client component is to be tested.

Depending on configuration, the Mockup Web Service can accept requests via any URL path. Based on rules that must be defined, the Mockup Web Service responds to these requests with predefined content.

Property

Description

MockupService.Activate

Boolean value enabling or disabling the Mockup Web Service

Default value: TRUE

MockupService.UrlBasePath

URL base path that precedes all requests sent to the Mockup Web Service (optional)

Since the service accepts requests under all URL paths, a measure which we recommend taking is that of limiting requests to those that begin with a specific path (e.g., /Mockup). Limiting requests helps avoid conflicts between xSuite Interface and other applications during path resolution, especially if other web services are to be used in parallel in the same program instance.

The MockupService.UrlBasePath property should be viewed as a supplement to the higher-level WebService.UrlBasePath property. If both properties are set (e.g., as /xSuite/Interface and /Mockup), all requests to the Mockup Web Service will start with /xSuite/Interface/Mockup.

MockupService.Rule[].Method

MockupService.Rule[].Path*

HTTP method(s) and URL path as filter criteria for a rule

Use these methods to select rules that are applied to an incoming request. The other properties of a given rule are used to form the response. The configured rules are evaluated in the order in which they have been defined. The first rule that matches the request will be used.

The .Method property serves as a filter for the HTTP method (GET, POST, etc.). If multiple HTTP methods are required, separate them by a comma. If the filter is to apply to all methods, use an asterisk (*) (default value).

The .Path property serves as a filter for the URL path. Always include the base path (MockupService.UrlBasePath) in the URL path, if you use it. Do not include a base path at a higher level (WebService.UrlBasePath) here.

If, for example, a base path Mockup is used, write a filter in the sub-path /Tests/Test1 as /Mockup/Tests/Test1. Wildcard and regular expressions in the syntax of a name filter are also permitted in the filter. Identify regular expressions by enclosing them in / characters. The /Mockup/* filter would then apply, for example, to all paths below the base path, regardless of the length or the depth.

MockupService.Rule[].Content

MockupService.Rule[].ContentFile

If the response is to include body content, define it as a string in .Content or have it load from an external file. Specify the path of the external file in .ContentFile. If the file is of file type TXT, JSON, or XML, it will be treated as a text file. If the file is of a different file type, it will be treated as a binary file.

MockupService.Rule[].Header[]

Definition of specific HTTP headers that are set in the response

Each entry is composed of the following individual parameters:

  • Name*: name of header value (e.g., Content-Type)

  • Value*: header value (e.g., application/json)

MockupService.Rule[].StatusCode

Numerical HTTP status value that is returned

Enter the numerical value here as text (as the value can also be defined dynamically using variables).

Default value: 200

MockupService.Rule[].Delay

Delay value in milliseconds.

This value is used to artificially slow down the response in order to simulate long-running requests.

Default value: 0

MockupService.Rule[].ErrorRate

Error rate as an integer percentage (between 0 and 100)

The error rate can be used to simulate a processing error. A request is answered with an error, with the specified probability. Configure the status value and the body content for the error case using the following .***OnError properties.

Default value: 0

MockupService.Rule[].ContentOnError

MockupService.Rule[].ContentFileOnError

MockupService.Rule[].StatusCodeOnError

Properties analogous to .Content, .ContentFile, and .StatusCode

These properties are used in the event that an error response is artificially generated via .ErrorRate.

The values of the .Content, .ContentFile, .Header[], and .StatusCode properties can be generated dynamically for each request by including variables. For the .ContentFile property, both the file path and the content of the file can be generated dynamically if the file in question is a text file. For the .Header[] property, only the second sub-parameter Value can be generated dynamically.

The only variables available are those which are extracted from the content of the incoming request (described below). They are inserted into the property values by means of pure text replacement. For this, use the syntax %VariableName% for text variables.

  • URL path: the variable %Path[n]% can be used for accessing the sub-elements of the URL path, starting with the base path MockupService.UrlBasePath. n stands for the sequential number of the element. For example, for a path /Mockup/Tests/Test1, %Path[2]% would result in Tests.

  • URL parameters: these are available as variables under the name specified in the URL. For example, for a parameter list ? param1=value1, the variable would be called %Param1%.

  • Header value: the names of the values in the HTTP header of the request can also be used as variables.

  • Body content: the entire content of the HTTP body is available as a contiguous string in the %Body% variable. This can only be used for textual content and not for binary content.

Notice

The following special feature should be noted for URL parameters and header values: As, within the program, variable names are limited to certain permitted characters (letters, numbers and underscore), the original name can be adapted automatically. For example, the header value ContentType will become the variable name %ContentType%.