uCosminexus Service Platform, Overview

[Contents][Glossary][Index][Back][Next]

2.13.5 HTTP reception response process

This section describes how to process the response message from a business process returned to HTTP reception as HTTP response.

HTTP response returning the response to HTTP client is partitioned in the following manner and it is processed in HTTP reception:

Status line
HTTP version, status code, and reason phrase are stored.

HTTP response header
Information such as Content-Length header, Content-Type header of HTTP response is stored.

HTTP response body
Text data or binary data returning response to HTTP client is stored.
Organization of this subsection
(1) Status line process
(2) HTTP response header process
(3) HTTP response body process
(4) Status codes

(1) Status line process

HTTP response status line is output in the following format:

 
[HTTP version#1][Blank][Status code#2][Blank][Reason phrase]
 

Note#1
HTTP version is fixed in "HTTP/1.1".

Note#2
Value of status-code element of the response message (header) is set in the status code. For details on the status code, see "(4) Status codes".

(2) HTTP response header process

All header information specified in HTTP reception is set in HTTP response header.

HTTP response header process is described here.

(a) Content-Type and charset

Content-Type header and charset attribute used in HTTP response header differ according to the following conditions:

If text data is returned
You can set Content-Type header and charset attribute used in HTTP response header in content-type element, http-header element, HTTP response header definition file of the response message (header).
If the response message format (for header variable) is set in the business process and multiple Content-Type headers and charset attributes are specified, specification of response message format (for header variable) is prioritized in the following manner:

Table 2-19 Content-Type and charset used in HTTP response header (if response message format (for header variable) is set)

Setting item If content-type element exists in response message#1 If content-type element exists in http-header element of the response message If content-type element and charset attribute do not exist in response message
If charset attribute exists in content-type element If charset attribute does not exist in content-type element If charset attribute exists in http-header element If charset attribute does not exist in http-header element
Content-Type header Value of content-type element of response message is valid. Value of content-type element of response message is valid. Value of content-type element of http-header element of response message is valid.#3 Value of content-type element of http-header element of response message is valid.#3 "text/xml" is set.
charset attribute Value of charset attribute of content-type element of response message is valid.#2 Specified value of HTTP reception definition file is valid. Value of charset attribute of http-header element of response message is valid.#3 Specified value of HTTP reception definition file is valid. Specified value of HTTP reception definition file is valid.

Note#1
If the element exists and the value is blank, the element is considered as not existing.

Note#2
If the attribute exists and the value is blank, the attribute is considered as not existing.

Note#3
If multiple content-type elements are specified in http-header element of the response message (header), any 1 of the specified values is valid. However, there is no guarantee as to which value is set.

   
If you do not set the response message format (for header variable) in the business process, the value of HTTP response header definition file is valid as described in the following table:

Table 2-20 Content-Type header and charset attribute used in HTTP response header (if response message format (for header variable) is not set)

Setting item If HTTP response header definition file exists If HTTP response header definition file does not exist
If content-type key exists in HTTP response header definition file If content-type key does not exist in HTTP response header definition file
charset attribute exists in specified value of content-type key charset attribute does not exist in the specified value of content-type key charset key does not exist in HTTP response header definition file
Content-Type header Specified value of content-type key is valid.# Specified value of content-type key is valid.# "text/xml" is set. "text/xml" is set.
charset attribute Value of charset attribute existing in the specified value of content-type key is valid.# Specified value of HTTP reception definition file is valid. Specified value of HTTP reception definition file is valid. Specified value of HTTP reception definition file is valid.

Note#
If you specify multiple content-type key and value pairs in HTTP response header definition file, any 1 of the specified values is valid. However, there is no guarantee as to which value is set.

   
HTTP response header definition file is any file invoked from HTTP reception definition file. For details on HTTP response header definition file, see "HTTP response header definition file" in "Service Platform Reference Guide" .

If file data is returned
You can set Content-Type header and charset attribute used in HTTP response header in content-type element under file element of the response message (header) as described in the following table:

Table 2-21 Content-Type header and charset attribute used in HTTP response header

Setting item If content-type element exists under file element of response message If content-type element does not exist under file element of response message
If charset attribute exists in content-type element under file element If charset attribute does not exist in content-type element under file element
Content-Type header Value of content-type element under file element of response message is valid. Value of content-type element under file element of response message is valid. Not set.
charset attribute Value of charset attribute of content-type element under file element of response message is valid. Not set. Not set.

Note
If the element exists and the value is blank, the element is considered as not existing.
If the attribute exists and the value is blank, the attribute is considered as not existing.

   

If multiple data items are returned (multi-part type)
If the data returned to HTTP client contains multiple items such as text data and data of 1 file or data of 2 files, regardless of specification of response message (header) and HTTP response header definition file, multipart/form-data is set in media type of Content-Type header. Content-Type header of each data is specified in the header of each part of multi-part type response body. Value specified in each data is as described in "If text data is returned" and "If file data is returned".
(b) Content-Disposition

For Content-Disposition header of HTTP response, the following values are set according to HTTP response part classification and the number of data items. If files are not downloaded, Content-Disposition header is not set in HTTP response.

Table 2-22 Value of Content-Disposition header set by HTTP reception

Part classification Number of data items Setting location Value of Content-Disposition header name attribute filename attribute
Single part type 1 file HTTP response header attachment# Not set. Value of filename element of response message (header)
Multi-part type 1 file + text data Header of each part of HTTP response form-data Value of part ID element of response message (header)
Multiple files

Note#
You can change this by httprecp.response.download.disposition-type property of HTTP reception definition file.

If http-header element of response message (header) contains content-disposition element, the value is ignored. If Content-Disposition header is specified in HTTP response header definition file, the value is valid.

(c) Content-Length

If only text data returns in HTTP response, you can specify whether to generate Content-Length header showing contents length in HTTP reception by using httprecp.response.generate.content-length property of HTTP reception definition file. You can specify the character code to be used while calculating contents length in httprecp.http.charset property of HTTP reception definition file.

For details on HTTP reception definition file, see "HTTP reception definition file" in "Service Platform Reference Guide" .

The following table describes the value of Content-Length header passed to HTTP client when specification exists and does not exist in HTTP reception definition file:

Table 2-23 Content-Length header passed to HTTP client

Value of httprecp.response.generate.content-length property Existence of specification of content-length element of http-header element in content-length key or response message (header) of HTTP response header definition file Value of Content-Length header passed to HTTP client
true Y Value specified in HTTP response definition file or response message (header) is overwritten by data length calculated by HTTP reception.
N
false Y Data length specified in HTTP response header definition file or response message (header) is set in Content-Length header.#
N Content-Length header is not passed to HTTP client.

Legend:
Y: If specified.
N: If not specified.

Note#
If httprecp.response.generate.content-length property of HTTP reception definition file is "false" and multiple content-length elements are specified in http-header element of the response message (header), or if multiple content-length key and value pairs are specified in HTTP response header definition file, 1 of the specified values is set. However, there is no guarantee as to which value is set.

Downloading of more than 1 file is invalid even option of sending Content-Length header to the client is set. Even if the file is not downloaded, Content-Length header is not set even if the setting is performed to ignore the response message (body) in ignore-bodymsg element of the response message (header) or httprecp.response.ignore-bodymsg property of HTTP reception definition file.

(3) HTTP response body process

This section describes HTTP response body process for each data format sent to HTTP client.

(a) In text data only

After processing of the business process is completed, the response message (body) variable returns to HTTP reception as XML type character string and is set in HTTP response body as text data. While setting, encoding occurs according to the specified character code.

If a system exception occurs, error message ID and message contents are set in the response message (body) element.

Text data returns only data that is the response message (body) part specified in the reply activity. Due to this, if multi-part type response is returned, text data exists in only 1 part.

Note
It is necessary to encode each character code specified in HTTP reception definition file for text data set in XML element.

You can set whether HTTP reception is to ignore (not set in HTTP response) the response message (body) received from the business process by ignore-bodymsg element of response message (header) or httprecp.response.ignore-bodymsg property of HTTP reception definition file. If both response message (header) and HTTP reception definition file are specified, specification of response message (header) is prioritized. If this element (or property) is specified and there is no file data to be downloaded, blank HTTP response body is returned to HTTP client.

(b) In file data

To download file data, specify the name of the file to be downloaded in file element of the response message (header). The following table describes the elements specified in the response message (header) and the corresponding HTTP response header:

Table 2-24 Element specified in response message (header)

Element name specified in response message (header) Description Corresponding HTTP response header
(header corresponding to each part in multi-part type)
Value if omitted
partID Part identifier name showing each part of multi-part type. name attribute of Content-Disposition header Intermediate file name specified in local-file-name element is set. Ignored even if specified if it is not multi-part type and name attribute is not provided.
file-name Download file name during download in HTTP client. filename attribute of Content-Disposition header None (filename attribute is not set).
local-file-name Intermediate file name to be downloaded in the working folder. If file with the specified name does not exist, error occurs. None Cannot be omitted.
content-type# Specify download file media type. Content-Type header None (Content-Type header is not set).
charset Specify download file character code. charset attribute None.

Note#
If specification of content-type element is omitted, Content-Type header of the file to be downloaded is not set in HTTP reception. If multiple files are to be downloaded or if file and text data are multi-part type, Content-Type header of HTTP response header is multipart/form-data and Content-Type header of each file data is specified in the header of each part.

Reference note
To download only 1 file without returning text data during HTTP response, you can set whether HTTP reception is to ignore text data specified in the response message (body). You can change this setting by ignore-bodymsg element of response message (header) or httprecp.response.ignore-bodymsg property of HTTP reception definition file. Set by the response message (header) to dynamically change the setting in each HTTP response.
If both response message (header) and HTTP reception definition file are specified, specification of response message (header) is prioritized.
However, even if the setting is to ignore the response message (body), it is necessary to set any variable in advance in the body allocation variable of the business process reply activity. For this, use of the dummy format (urecp_http_dummy_body_response.xsd) of the response message format (for body variable) provided by the service platform as the dummy for the body variable is recommended.
(c) In binary data

You can set binary data in HTTP response body and return the response to the client by specifying binary format or optional format (any format) in the message format of HTTP reception response message.

Binary data is set in HTTP response body only if all the following conditions are met:

(4) Status codes

This section describes status codes of HTTP request and HTTP response.

(a) Status code during response

The value set for status code during response differs according to response timing and type. The following table describes the status code setting value and response timing:

Table 2-25 Set status codes

Timing Response type Specification of status-code element in response message (header)
Exists Does not exist
Before invoking business process If error occurs in HTTP reception verification - HTTP reception sets status code according to error status.
After invoking business process In normal termination Status code set in status-code element of response message (header) is used.#1 200#2
In fault Status code set in status-code element of response message (header) is used.#1 200#3
In system exception - Value of httprecp.system-exception.status-code property in HTTP reception definition file is valid.#4

Legend:
-: Not applicable.

Note#1
It is not verified whether status code has terminated normally or is in error. Due to this, if status code is set in error range (example: 400-599) in the response message (header), status code is returned as is in HTTP client.

Note#2
Default value if status code is not set.

Note#3
If status code is not set in fault, it is considered as normal termination and default value is set.

Note#4
If there is no specification in HTTP reception definition file, default value 500 is set.

(b) Status code during error occurrence

The following table describes the correspondence between message ID and status code when error occurs in HTTP request and HTTP response processing:

Table 2-26 List of status codes when error occurs in request processing

Message ID Status when error occurs Status code
KDEC80424 If an internal error occurs (error occurs during XML format transformation of HTTP header or HTTP body) 500
KDEC80438 If HTTP method is other than GET or POST 405
KDEC80439 If the operation name specified in URL does not match with the operation name specified in HTTP reception 404
KDEC80440 If an invalid character is specified in the query character string, HTTP body or HTTP header 400
KDEC80441 If msg key is not specified in the request parameter or if an upper case character is specified in pass-through mode 400
KDEC80442 If an error occurs in URL decoding according to the encoding specified in HTTP request header or HTTP reception definition file 500
KDEC80451 If a unique request ID cannot be generated due to one of the following factors:
  • Acquisition failed of parameters such as time, date, HTTP client IP address, etc. to generate request ID
  • A large number of requests are received from same IP addresses at same time and there is no ID that can be used
500
KDEC80452 If the root directory of the working folder specified in HCSC server runtime definition file does not exist 500
KDEC80453 If failure occurs while creating a working folder 500
KDEC80454 If multi-part type HTTP request data reception or analysis fails 400
KDEC80457 If an error occurs during output of an intermediate file 500

Table 2-27 List of status codes when an error occurs in response process

Message ID Status when an error occurs Status code
KDEC80424 If an internal error occurs (acquisition of HTTP response body stream fails or an exception occurs in writing value in HTTP response body) 500
KDEC80443 If an error occurs in HTTP header or HTTP body analysis during reception 500
KDEC80444 If an error occurs during response message encoding 500
KDEC80445 If the status code returned from the business process is more than 3 digits or less 500
KDEC80458 If reading of an intermediate file fails 500
KDEC80459 If failure occurs while deleting a working folder 200