Page History
Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
|
Stereotype Attributes
REST Alias
Multiexcerpt | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||
|
...
|
...
|
...
|
...
|
...
|
REST Adapter
Multiexcerpt | ||||||
---|---|---|---|---|---|---|
| ||||||
|
...
|
REST API
This stereotype defines a package as a REST port. It has no additional attributes.
REST
...
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
...
Operation
Multiexcerpt | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||
|
...
|
...
|
...
|
...
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
REST Parameter
Multiexcerpt include | ||||
---|---|---|---|---|
|
REST Error
...
(Class)
Anchor | ||||
---|---|---|---|---|
|
The stereotype REST Error is used on a class to mark it as REST error class. Each REST port has a error class assigned that, in case of error, contains additional information. You can get this information using something like
Code Block |
---|
create error;
set error = adapterResponse.responseObject; |
if error is an object of the type indicated by this stereotype.
REST
...
MultiExcerptName | RESTAdapterParameters |
---|
...
REST Content Types
With the REST Adapter, the xUML Runtime can handle JSON or XML as content types. The Runtime will parse either response content (JSON or XML) to a response object automatically.
You do not need to set any headers. If no headers are set, the Runtime will use JSON as a default format and set Accept header to application/json,text/json,application/xml;q=0.9,text/xml;q=0.9,*/*;q=0.8
.
Regarding response parsing, the xUML Runtime will process REST responses as follows:
- If the Content-Type header of the response is JSON or XML, respective format will be used (regardless what is specified in the Accept header).
- If the Content-Type header of the response is not set, the Runtime will assume that the content matches the Accept header of the request. If no Accept header has been specified, JSON is the fallback.
- In case of unsupported Content-Type, JSON is the fallback.
REST Parameter Types
Request
...
Header information as a map. The map contains arrays of header value strings whereas the header name is the key of the map.
- Header names are lowercase and treated case insensitive.
- Multiple headers with the same name are treated as arrays.
Refer to HTTP Header Support for more information on the standard xUML HTTP headers.
Port (Class)
Attribute | Description | Allowed Values / Examples | |
---|---|---|---|
path | Defines the path to this rest interface. If empty, the path is derived from the package structure. | none | path of the package structure will be used, e.g. /Services/SupportCase/SupportAPI |
any valid path string | path string starting with "/", e.g. /support | ||
errorClass | Assigns a user-defined REST Error class to the REST interface. This class should be set in case of error and given back via the REST response. | any complex type describing the structure of the error | |
apiVersion | Defines the API version this port type provides (for documentation purposes only). | any string, default is 1.0.0 |
REST Resource (Class)
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
REST Error Code (Property)
REST Error Code and REST Error Message are applied to one property of the REST Error class each to define that the corresponding properties contain the error code and the error message of the REST error. You cannot set REST Error Code on two properties of the same error class.
REST Error Message (Property)
REST Error Code and REST Error Message are applied to one property of the REST Error class each to define that the corresponding properties contain the error code and the error message of the REST error. You cannot set REST Error Message on two properties of the same error class.
REST Adapter Parameters
Multiexcerpt | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
|
REST Utility Functions
Access to HTTP request and response objects is provided through global methods: getRestHttpRequest()
and getRestHttpResponse()
.
Function | Parameter | Return Value | Description | Example |
---|---|---|---|---|
getRestHttpRequest() | none | object of type Request | Returns the request details as provided by the HTTP call. Changing the request object will not have any effects. For details see getRestHttpRequest(). | local request = getRestHttpRequest(); |
getRestHttpResponse() | none | object of type Response | Set the response details to return them to the caller. For details see getRestHttpResponse(). | local response = getRestHttpResponse(); |
REST Content Types
With the REST Adapter, the xUML Runtime can handle JSON or XML as content types. The Runtime will parse either response content (JSON or XML) to a response object automatically.
You do not need to set any headers. If no headers are set, the Runtime will use JSON as a default format and set Accept header to application/json,text/json,application/xml;q=0.9,text/xml;q=0.9,*/*;q=0.8
.
Regarding response parsing, the xUML Runtime will process REST responses as follows:
- If the Content-Type header of the response is JSON or XML, respective format will be used (regardless what is specified in the Accept header).
- If the Content-Type header of the response is not set, the Runtime will assume that the content matches the Accept header of the request. If no Accept header has been specified, JSON is the fallback.
- In case of unsupported Content-Type, JSON is the fallback.
REST Parameter Types
AdapterResponse
Multiexcerpt | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||
|
Request
Attribute | Type | Description | Allowed Values / Examples |
---|---|---|---|
queryString | String | Query string, if provided with the call. | status=in%20progress |
queryParameters | Array of Parameter | All query parameters as an array of Parameter classes containing name/value pairs. | |
body | Blob | Body of the HTTP request. | |
path | String | Path to the REST resource. | /support/supportcases/ |
pathParameters | Map | All REST parameters as a map. | |
httpHeaderMap | Map of Entry | Header information as a map. The map contains arrays of header value strings whereas the header name is the key of the map.
Refer to HTTP Header Support for more information on the standard xUML HTTP headers |
Response
...
. |
RequestOptions
Multiexcerpt | |||||
---|---|---|---|---|---|
| |||||
|
...
|
...
a valid host, e.g. scheer-acme.com
...
|
...
|
...
AdapterResponse
...
Response Object of the REST adapter call.
- If the adapter had an error, the responseObject is an <<RESTError>> class. It could be the default error class or a specific error class dependent on the <<RESTResponseDefinition>> dependencies and the HTTP status code.
- If the adapter call had no error, the responseObject is the same as the response output parameter.
...
- Header names are lowercase and treated case insensitive.
- Multiple headers with the same name are treated as arrays.
|
Response
Attribute | Type | Description | Allowed Values / Examples |
---|---|---|---|
headers | Array of HeaderField | All HTTP response header fields as an array of HeaderField classes containing name/value pairs. | |
httpCode | Integer | The resulting HTTP status code. If not set explicitly using this object, the service returns 200 if no exception occurred, or 500 otherwise. | 404 |
responseObject | Any | Response Object of the REST adapter call if the endpoint returns one (response output parameter) |
...
. |
Request and Response Types
Multiexcerpt | ||||||
---|---|---|---|---|---|---|
| ||||||
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
...
|
Panel | ||
---|---|---|
| ||
|
Multiexcerpt include | ||||||||
---|---|---|---|---|---|---|---|---|
|
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
Multiexcerpt include | ||||||
---|---|---|---|---|---|---|
|
Panel | ||
---|---|---|
| ||
...