Producing a client application from the JSON Schema
These steps show you how to use the JSON Schemas to define the JSON request and response payloads that are used by a client application to communicate with the sample EC03 program.
In the step Producing the WSBind file, the JSON web services assistant created the JSON Schema documents, ec03req.json and ec03resp.json that define the JSON data format of the request and response payloads.
JSON data is written as name:value pairs. A JSON
object is one or more name:value pairs, separated
by commas, and contained within braces.
For example: {"forename":"John","lastname":"Smith"}
Example 1; Creating JSON request data to conform to the JSON Schema
The JSON request data must conform to the JSON Schema ec03req.json.
The schema document
describes the JSON input format to the web service to drive the EC03
CICS transaction:
{
"$schema":"http:\/\/json-schema.org\/draft-04\/schema#",
"description":"Request schema for the EC03 JSON interface",
"type":"object", 1
"properties":{
"EC03Operation":{ 2
"type":"object", 3
"properties":{
"INPUTDATA":{ 4
"type":"string" 5
}
},
"required":[
"INPUTDATA"
]
}
},
"required":[
"EC03Operation"
]
}The JSON Schema shows that the JSON data must include
a JSON object ( 1 ), with the name "EC03Operation" ( 2 )
whose value is also a JSON object ( 3 ).
The nested JSON object has the name "INPUTDATA" ( 4 )
and a value of type string ( 5 ).Therefore,
the JSON request data is of the form
{"EC03Operation":{ "INPUTDATA": "testing data" }}Example 2: Creating JSON response data to conform to the JSON Schema
The JSON response data must conform to the JSON Schema ec03resp.json.
The JSON
schema document describes the format of the JSON output of the web
service that is returned from the EC03 CICS transaction:
{
"$schema":"http:\/\/json-schema.org\/draft-04\/schema#",
"description":"Response schema for the EC03 JSON interface",
"type":"object",
"properties":{
"EC03OperationResponse":{
"type":"object",
"properties":{
"INPUTDATALENGTH":{
"type":"object",
"properties":{
"inputlength":{
"type":"integer",
"maximum":2147483647,
"minimum":-2147483648
}
},
"required":[
"inputlength"
]
},
"OUTPUTMESSAGE":{
"type":"string"
},
"CICSDATETIME":{
"type":"string"
}
},
"required":[
"INPUTDATALENGTH",
"OUTPUTMESSAGE",
"CICSDATETIME"
]
}
},
"required":[
"EC03OperationResponse"
]
}This example shows that the returned JSON payload
must conform to the JSON Schema formats and be of the form:
{
"EC03OperationResponse":
{
"CICSDATETIME": "18/03/2014 13:13:35",
"OUTPUTMESSAGE": "Input data was: testing data",
"INPUTDATALENGTH":
{
"inputlength": 12
}
}
}