Start of change

WEB CONVERSE

Send an HTTP request by CICS® as an HTTP client, and receive a response from the server, using a single command. An alternative to the WEB SEND and WEB RECEIVE commands for CICS as an HTTP client.

Read syntax diagramSkip visual syntax diagram
WEB CONVERSE

>>-WEB--CONVERSE--SESSTOKEN(data-value)------------------------->

>--+-----------------------------------------+--METHOD(cvda)---->
   +-PATH(data-area)--PATHLENGTH(data-value)-+                 
   '-URIMAP(data-value)----------------------'                 

>--+----------------------+------------------------------------->
   '-MEDIATYPE(data-area)-'   

>--+-------------------------------------------------+---------->
   '-QUERYSTRING(data-area)--QUERYSTRLEN(data-value)-'   

>--+-----------------------------------------+------------------>
   +-DOCTOKEN(data-value)--------------------+   
   '-FROM(data-area)--FROMLENGTH(data-value)-'   

>--+--------------+--+-------------------+---------------------->
   '-ACTION(cvda)-'  '-CLOSESTATUS(cvda)-'   

>--+-INTO(data-area)-+--TOLENGTH(data-area)--------------------->
   '-SET(ptr-ref)----'                        

>--+-----------------------+--+------------+-------------------->
   '-MAXLENGTH(data-value)-'  '-NOTRUNCATE-'   

>--+-----------------------+------------------------------------>
   '-STATUSCODE(data-area)-'   

>--+----------------------------------------------+------------->
   '-STATUSTEXT(data-area)--STATUSLEN(data-value)-'   

>--+--------------------------+--+------------------+----------><
   '-CHARACTERSET(data-value)-'  '-CLIENTCONV(cvda)-'   

Conditions: IOERR, INVREQ, LENGERR, NOTAUTH, NOTFND, NOTOPEN, TIMEDOUT, TOKENERR

This command is threadsafe.

Description

WEB CONVERSE enables an application program to compose and send an HTTP client request, and receive a response from the server. A session token must be included on this command. For guidance on the correct use of the WEB CONVERSE command, see the CICS Internet Guide.
  • The HTTP client request is made using a connection that has been opened using the WEB OPEN command. The WEB CONVERSE command can be used in place of the WEB SEND command to compose and send the request.
  • The response from the server is received by CICS Web support and passed to the application. The WEB CONVERSE command can be used in place of the WEB RECEIVE command to make the application program wait for and receive the HTTP response. The headers for the HTTP response can be examined separately using the WEB READ HTTPHEADER command or the HTTP header browsing commands.
    Note: The RTIMOUT value specified for the transaction that starts the user application indicates the time that the application is prepared to wait to receive the incoming message. (RTIMOUT is specified on the transaction profile definition). When the period specified by RTIMOUT expires, CICS returns a TIMEDOUT response to the application. An RTIMOUT value of zero means that the application is prepared to wait indefinitely. The default setting for RTIMOUT on transaction profile definitions is zero, so it is important to check and change that setting for applications that are making HTTP client requests.

The WEB CONVERSE command does not support chunked transfer-coding for the request, because this requires a sequence of send actions, and the WEB CONVERSE command provides a single send action. If you want to send a chunked message, use the WEB SEND command to send it, and the WEB RECEIVE command to receive it. If the server sends a chunked response, this can be received using the WEB CONVERSE command.

The WEB CONVERSE command cannot be used after the connection to the server has been closed. If you need to test whether the server has requested termination of the connection, use the WEB READ HTTPHEADER command to look for the Connection: close header in the last message from the server.

The WEB CONVERSE command performs a single send action and a single receive action, and it is designed to be used in place of a WEB SEND command and a WEB RECEIVE command. You may use WEB SEND and WEB RECEIVE commands, and WEB CONVERSE commands, in relation to the same connection (that is, with the same SESSTOKEN). However, if you are pipelining requests (that is, sending a sequence of requests without waiting for a response), you must not follow a WEB SEND command with a WEB CONVERSE command. CICS checks at program run time that each WEB SEND command has a subsequent WEB RECEIVE command before any WEB CONVERSE command is issued. For example, if you use the WEB SEND command three times to issue a pipelined sequence of requests, you must use the WEB RECEIVE command three times to receive the responses for those requests, before you may use the WEB CONVERSE command.

Options for sending the HTTP client request

ACTION(cvda)
This option is used to specify how the message should be sent out. The CVDA value that applies for CICS as an HTTP client is:
EXPECT
makes CICS send an Expect header along with the request line and headers for the request, and await a 100-Continue response before sending the message body to the server. If a response other than 100-Continue is received, CICS informs the application program and cancels the send. If no response is received after a period of waiting, CICS sends the message body anyway.

This option must only be used if your request has a message body.

CLOSESTATUS(cvda)
specifies whether or not a Connection header with the "close" connection option (Connection: close) should be included on the request. The default is that the header is not included. The CVDA values are:
CLOSE
makes CICS write a Connection: close header for this request. The header notifies the server that the connection should be closed after the server has sent its response to the request. (For a server at HTTP/1.0 level, CICS achieves the same effect by omitting the Connection: Keep-Alive header.)
NOCLOSE
means that the Connection: close header is not used for this request. If the server is identified as HTTP/1.0, CICS sends a Connection header with the "Keep-Alive" connection option (Connection: Keep-Alive), to notify that a persistent connection is desired.
DOCTOKEN(data-value)
specifies the 16-byte binary token of a document to be sent as the message body. The document must be created using the CICS Document interface (EXEC CICS DOCUMENT CREATE, INSERT, and SET commands), as described in the CICS Application Programming Guide. The FROM option provides an alternative way to create a message body.

CICS documents cannot be converted to the UTF-8 and UTF-16 character encodings.

FROM(data-area)
specifies a buffer of data which holds the message body. The message body is built by the application program. When you specify the FROM option, use the FROMLENGTH option to specify the length of the buffer of data. The DOCTOKEN option provides an alternative way to create the message body.

There is no set maximum limit for the size of the data-area, but its size is limited in practice by storage considerations. The CICS Internet Guide has more information about these.

FROMLENGTH(data-area)
specifies the length, as a fullword binary value, of the buffer of data supplied on the FROM option (the message body). It is important to state this value correctly, because an incorrect data length can cause problems for the recipient of the message.
MEDIATYPE(data-area)
specifies the data content of any request body, for example text/xml. The media type is up to 56 alphanumeric characters, including appropriate punctuation, Start of changebut not spacesEnd of change. See the CICS Internet Guide for more information about media types. CICS checks that the format of the media type is correct, but does not check the validity of the media type against the data content. Start of changeCICS uses this information to produce the Content-Type header for the message.End of change

Start of changeFor requests which require a body, you must specify the MEDIATYPE option. There is no default. However, if the required Content-Type header needs to contain spaces or more than 56 characters, the application can provide it using the WEB WRITE HTTPHEADER command. In this case, do not specify the MEDIATYPE option.End of change

For code page conversion to take place, the MEDIATYPE option must specify a type of data content that can be identified as text according to the IANA definitions. For non-text media types, CICS does not convert the message body.

The MEDIATYPE option is used for both the sending and receiving functions of the WEB CONVERSE command. If it is specified with a value, the value is used to construct the Content-Type header in the request, and the same field is used to receive the media type of the response that is returned by the server. If it is specified without a value, it is used only to receive the media type of the response.

METHOD(cvda)
specifies the HTTP method for the request.

The GET, HEAD, POST, PUT, TRACE, OPTIONS, and DELETE methods are supported by this command. However, some HTTP servers, particularly HTTP/1.0 servers, might not implement all of these methods.

The CICS Internet Guide has more information about the correct use of methods, including the HTTP versions that apply to each.

CICS bars the sending of a message body for methods where it is inappropriate, and requires it for methods where it is appropriate.

The CVDA values are:
GET
Obtain a resource from the server. A request body is not allowed.
HEAD
Obtain the HTTP headers, but not the response body, for a resource. A request body is not allowed.
POST
Send data to a server. A request body is required.
PUT
Create or modify a resource on the server. A request body is required.
TRACE
Trace the route of your request to the server. A request body is not allowed.
OPTIONS
Obtain information about the server. A request body is allowed, but there is no defined purpose for the body. If you do use a request body, then you must specify a media type.
DELETE
Delete a resource on the server. A request body is not allowed.
PATH(data-area)
specifies the path information for the specific resource within the server that the application needs to access.

If the URIMAP option was used to specify an existing URIMAP definition on the WEB OPEN command for this connection, the path specified in that URIMAP definition is the default path for the WEB SEND command. In these circumstances, if you do not specify path information on the WEB SEND command, the path from the URIMAP definition is used. If you specify a different path from that given in the URIMAP definition, this overrides the path from the URIMAP definition.

If the URIMAP option was not used on the WEB OPEN command, there is no default path, and you must provide path information. Path information can be extracted from a known URL using the WEB PARSE URL command.

As an alternative to using the PATH option to provide the path information, you can use the URIMAP option on the WEB CONVERSE command to specify a URIMAP definition from which the path information is taken directly.

PATHLENGTH(data-value)
specifies the length of the path, as a fullword binary value. If you are providing path information using the PATH option, you need to specify the PATHLENGTH option. Path length information is returned if you use the WEB PARSE URL command to parse a URL.
QUERYSTRING(data-area)
specifies a query string that is to be supplied to the server as part of the request. You do not need to include a question mark (?) at the beginning of the query string; if you do not include it, CICS supplies it for you automatically when constructing the request. If you include escaped characters in the query string, CICS passes them to the server in their escaped format.
QUERYSTRLEN(data-value)
specifies the length of the query string supplied on the QUERYSTRING option, as a fullword binary value.
SESSTOKEN(data-value)
specifies the session token, an 8-byte binary value that uniquely identifies this connection between CICS and a server. This value is returned by a WEB OPEN command for CICS as an HTTP client. "Session tokens" in the CICS Internet Guide explains the use of the session token.
URIMAP(data-value)
specifies the name (up to 8 characters, in mixed case) of a URIMAP definition that provides the path information for the specific resource within the server that the application needs to access. The URIMAP definition must be for CICS as an HTTP client (with USAGE(CLIENT) specified). Its HOST attribute must be the same as the HOST attribute of the URIMAP definition that was specified on the WEB OPEN command for this connection, or the same as the host name specified in the HOST option on the WEB OPEN command for this connection. A URIMAP definition specified on the WEB CONVERSE command applies only to this request.

If the URIMAP option is specified, do not specify the PATH or PATHLENGTH options.

Options for receiving the server's response

INTO(data-area)
specifies the buffer that is to contain the data being received.
MAXLENGTH(data-value)
specifies the maximum amount, as a fullword binary value, of data that CICS is to pass to the application. The MAXLENGTH option applies even when the INTO option is specified for receiving data. If the data has been sent using chunked transfer-coding, CICS assembles the chunks into a single message before passing it to the application, so the MAXLENGTH option applies to the total length of the chunked message, rather than to each individual chunk. The data is measured after any code page conversion has taken place.

Start of changeDo not use the MAXLENGTH and SET options together, because MAXLENGTH will be ignored.End of change

If the length of data exceeds the value specified and the NOTRUNCATE option is not specified, the data is truncated to that value, and the remainder of the data is discarded.

If the length of data exceeds the value specified and the NOTRUNCATE option is specified, CICS retains the remaining data and can use it to satisfy subsequent RECEIVE commands.

MEDIATYPE(data-area)
specifies a 56-character data-area to receive the media type (that is, the type of data content) for the body, for example text/xml. See the CICS Internet Guide for more information about media types.

The MEDIATYPE option is used for both the sending and receiving functions of the WEB CONVERSE command. If it is specified with a value, the value is used to construct the Content-Type header in the request, and the same field is used to receive the media type of the response that is returned by the server. If it is specified without a value, it is used only to receive the media type of the response.

NOTRUNCATE
specifies that when the data available exceeds the length requested on the MAXLENGTH option, the remaining data is not to be discarded immediately but is to be retained for retrieval by subsequent RECEIVE commands. (If no further RECEIVE commands are issued, the data is discarded during transaction termination.)

A single RECEIVE command using the SET option and without the MAXLENGTH option receives all the remaining data, whatever its length. Alternatively, you can use a series of RECEIVE commands with the NOTRUNCATE option to receive the remaining data in appropriate chunks. Keep issuing the RECEIVE command until you are no longer getting a LENGERR response. Bear in mind that if you receive less than the length requested on the MAXLENGTH option, this does not necessarily indicate the end of the data; this could happen if CICS needs to avoid returning a partial character at the end of the data.

SET(ptr-ref)
specifies a pointer reference that is to be set to the address of data received. The pointer reference is valid until the next receive command or the end of task.
STATUSCODE(data-area)
specifies a data-area to receive the HTTP status code sent by the server. The code is a binary halfword value. Examples are 200 (normal) or 404 (not found). Receiving the status code is optional, but you should always receive and check the status code in the following circumstances:
  • If you intend to make an identical request to the server, now or during a future connection.
  • If you intend to make further requests to the server using this connection.
  • If your application is carrying out any further processing that depends on the information you receive in the response.
The CICS Internet Guide has basic guidance on appropriate actions for an application to take in response to the status codes for HTTP/1.1.
STATUSTEXT(data-area)
specifies a data-area to receive any text returned by the server to describe the status code. The text is known as a reason phrase. Examples are "OK" (accompanying a 200 status code), or "Bad Request" (accompanying a 400 status code). The STATUSLEN option gives the length allowed for the text.
STATUSLEN(data-value)
specifies, as a fullword binary value, the length of the data-area to receive any text returned by the server to describe the status code (the STATUSTEXT option). The text is known as a reason phrase. Most reason phrases recommended for HTTP are short, but a data-area length of 256 characters is suggested here, in case the server replaces the recommended reason phrase with more detailed information.
TOLENGTH(data-area)
specifies a fullword binary variable which is set to the amount of data that CICS has returned to the application. Note that this might be slightly less than the limit that you set using the MAXLENGTH option, especially if a double-byte or multi-byte character set is involved, because CICS does not return a partial character at the end of the data.
  • If the NOTRUNCATE option is not specified, any further data present in the message has now been discarded. A LENGERR response with a RESP2 value of 57 is returned if further data was present.
  • If the NOTRUNCATE option is specified, any additional data is retained. A LENGERR response with a RESP2 value of 36 is returned if additional data is available. The description for the NOTRUNCATE option tells you what to do in this case.
This option is the equivalent of the LENGTH option on the WEB RECEIVE command.

Options for converting items sent and received

CHARACTERSET(data-value)
specifies the character set into which CICS translates the entity body of the HTTP request before sending. The name of the character set can consist of up to 40 alphanumeric characters, including appropriate punctuation. CICS does not support all the character sets named by IANA. The CICS Internet Guide lists the IANA character sets that are supported by CICS for code page conversion.

For conversion of the request body to take place, the CLIENTCONV option must be allowed to default to CLICONVERT, or specified as NOINCONVERT. Specifying NOCLICONVERT or NOOUTCONVERT suppresses conversion of the request body. If conversion is requested, ISO-8859-1 is used as the default if the CHARACTERSET attribute is not specified.

CLIENTCONV(cvda)
specifies whether or not CICS translates the entity body of the HTTP request before sending, and translates the entity body of the server's response. The default is that the entity body is converted both when the request is sent out, and when the response is received (CLICONVERT).
  • For the request body, you can use the CHARACTERSET option on this command to specify a character set that is suitable for the server. If conversion is requested (or happens as the default) but you do not specify a character set, the default is that CICS converts the entity body to the ISO-8859-1 character set.
  • For the response body, you do not need to specify the character set used by the server. CICS identifies this by examining the Content-Type header of the message. If the header does not provide this information, or if the named character set is not supported by CICS for code page conversion, the ISO-8859-1 character set is used.
  • For the application's code page, the default code page for the local CICS region (as specified in the LOCALCCSID system initialization parameter) is used, or an alternative EBCDIC code page that you specified on the WEB OPEN COMMAND.
Note: For message bodies with non-text media types, CICS does not convert the message body, even if an appropriate conversion option is specified.
CVDA values are:
CLICONVERT
CICS converts the entity body of the request into the character set that you identify for the server, and converts the entity body of the response into a code page suitable for the application.
NOINCONVERT
CICS converts the entity body of the request into the character set that you identify for the server. However, CICS does not convert the entity body of the response, and it is passed to the application in the character set used by the server.
NOOUTCONVERT
CICS does not convert the entity body of the request, and it is sent to the server in the code page used by the application. However, CICS does convert the entity body of the response into a code page suitable for the application.
NOCLICONVERT
CICS does not convert the entity body of the request, and it is sent to the server in the code page used by the application. CICS does not convert the entity body of the response, and it is passed to the application in the character set used by the server.

Conditions

NOTOPEN
RESP2 values are:
27
Invalid session token.
INVREQ
RESP2 values are:
10
Invalid response header.
11
Action code invalid.
13
Close status invalid.
15
Code page conversion failure.
17
Expect-100 request was rejected by the server.
22
Invalid chunk size.
32
Media type invalid.
33
Method does not support a body.
34
Method requires a body.
41
The connection has been closed.
45
The character set specified is invalid.
46
The CLIENTCONV option is invalid.
49
The format of the path option is invalid.
54
The HTTP method is not valid.
63
URIMAP object disabled.
64
Host in URIMAP definition does not match host specified when this session was opened.
67
HTTP error in response.
74
The connection has been closed (CICS sent a Connection: close header to the server).
76
MEDIATYPE option required.
79
Pipelining is in progress. WEB CONVERSE command cannot be used.
LENGERR
RESP2 values are:
5
The PATHLENGTH option value was not greater than zero.
8
The QUERYSTRLEN option value was not greater than zero.
16
Invalid MAXLENGTH.
36
Partial response body returned. Use additional RECEIVEs to obtain remainder.
50
The FROMLENGTH option value was not greater than zero.
57
The response body exceeds the length specified, and the remainder of the body has been discarded.
58
The status text exceeds the length specified.
59
The STATUSLEN option value was not greater than zero.
NOTFND
RESP2 values are:
61
The URIMAP object specified was not found.
TOKENERR
RESP2 values are:
47
The document token specified is invalid.
IOERR
RESP2 values are:
42
Socket error.
TIMEDOUT
RESP2 values are:
62
Timeout on socket receive.
NOTAUTH
RESP2 values are:
100
Path barred by security exit.
End of change