The MVS Toolkit provides the ability for subroutines called from the Web Service to access the HTTP header data and generate direct responses to the Web Service client. This feature enables the developer to override default formatting by generating custom XML, JSON, HTML, or other formats.
The following built-in subroutines are provided to facilitate interaction between the user’s subroutine and the Web Service client.
Returns the URI of the web service being called.
For example, if the Web Service is invoked with http://www.yourserver.com:8181/orders/inquiry
/orders/inquiry will be returned.
Returns the URI parameters as a dynamic array containing a multi-attribute, multi-valued table of parameters (URL encoded) passed typically in HTTP GET requests.
For example:
http://host:port/ws/wso?ID=1&name=acme&phone=800-555-5555will result in two attributes, each with three values:
Value | Attribute 1 | Attribute 2 |
---|---|---|
Value 1 | ID | 1 |
Value 2 | name | acme |
Value 3 | phone | 800-555-5555 |
Returns a dynamic array containing a multi-attribute, multi-valued table of HTTP request header content.
For example, the following HTTP Request header:
POST /ws/wso HTTP/1.0 Host: www.yourserver.com Accept: application/json Content-type: application/ x-www-form-urlencoded Content-length: 120
will result in two attributes each with four values:
Value | Attribute 1 | Attribute 2 |
---|---|---|
Value 1 | Host | www.yourserver.com |
Value 2 | Accept | application/json |
Value 3 | Content-type | application/x-www-form-urlencoded |
Value 4 | Content-length | 120 |
The IP Address/port number of the requestor is returned in the request header's dynamic array value. To access this value, call the MVSP.GET.HTTP.REQUEST.HEADER subroutine to get the request header dynamic array and return the Remote-Address value. For example:
CALL MVSP.GET.HTTP.REQUEST.HEADER(REQUEST.HEADER) LOCATE('Remote-Address', REQUEST.HEADER, 1; VMC) THEN REMOTE.ADDRESS = REQUEST.HEADER<2, VMC> END
Returns a dynamic array containing a multi-attribute, multi-valued table of HTTP request content.
For example, the following HTTP Request content:
ID=1&name=acme&phone=800-555-5555will result in two attributes, each with three values:
Value | Attribute 1 | Attribute 2 |
---|---|---|
Value 1 | ID | 1 |
Value 2 | name | acme |
Value 3 | phone | 800-555-5555 |
Sets a dynamic array containing a multi-attribute, multi-valued table of items you want to add to the standard HTTP response or data you want to overwrite in the standard HTTP response.
For example, the following is a standard HTTP Response header:
HTTP/1.1 200 OK Content-type: application/json; charset=UTF-8 Server: Jetty(6.1.26)
If you are sending an XML response and want to add a Content length and Content type, build a two-attribute, two-valued dynamic array as follows:
Value | Attribute 1 | Attribute 2 |
---|---|---|
Value 1 | Content-type | text/xml; charset=UTF-8 |
Value 2 | Content-length | 147 |
The default status code that is returned upon success is 200. If you want to return a different status code, build a two-attribute dynamic array as follows:
Value | Attribute 1 | Attribute 2 |
---|---|---|
Value 1 | status | valid 3-digit status code |
In this example, setting the status code to 401 would return the following HTTP Response header:
HTTP/1.1 401 Unauthorized Content-type: application/json; charset=UTF-8 Server: Jetty(6.1.26)
Sets the HTTP response content. Whatever you pass in as RESPONSE will be passed back to the Web Service user as HTTP response content without any interference from the MVS Server.