skip to main content
Corticon Server: Deploying Web Services with Java : Consuming a Decision Service on Java server : Path 4: Using JSON/RESTful client to consume a Decision Service on Java Server : Running the sample JSON Request
 

Try Corticon Now
Running the sample JSON Request
A Corticon Server installation provides a JSON sample (similar to the SOAP .xml sample) and a test script that runs the sample.
The sample, located at [CORTICON_WORK_DIR]\Samples\Rule Projects\OrderProcessing\OrderProcessingPayload.json, is as follows:

{"Objects": [{
"total": null,
"myItems": [
{
"product": "Ball",
"price": "10.000000",
"quantity": "20",
"subtotal": null,
"__metadata": {
"#id": "Item_id_1",
"#type": "Item"
}
},
{
"product": "Racket",
"price": "20.000000",
"quantity": "1",
"subtotal": null,
"__metadata": {
"#id": "Item_id_2",
"#type": "Item"
}
},
{
"product": "Wrist Band",
"price": "5.250000",
"quantity": "2",
"subtotal": null,
"__metadata": {
"#id": "Item_id_3",
"#type": "Item"
}
}
],
"shipped": null,
"shippedOn": null,
"__metadata": {
"#id": "Order_id_1",
"#type": "Order"
},
"dueDate": "1/1/2008 12:00:00 AM",
"note": null
}]}
To run the JSON sample:
1. Start Corticon Server.
2. Open a command prompt window at [CORTICON_HOME]\Server\bin.
3. Enter testServerREST.bat, and then type help and press Enter. The command transaction list is displayed:

---------------------------------------------------------
--- Current Apache Axis Location: http://localhost:8850/axis
---------------------------------------------------------

Transactions:
-1 - Exit REST API Test
---------------------------------------------------------
0 - Change Connection Parameters
---------------------------------------------------------
142 - Execute JSON REST request
143 - Execute JSON REST request (by specific Decision Service Major Version)
144 - Execute JSON REST request (by specific Decision Service Major and Minor Version)
145 - Execute JSON REST request (by specific execution Date)
146 - Execute JSON REST request (by specific execution Date and Decision Service Major Version)
----------------------------------------------------------
Enter transaction number
4. Enter 142.
5. When prompted for Input JSON File Path, enter (or copy) the path to the sample:
C:\Users\{user}\Progress\CorticonWork_5.6\Samples\Rule Projects\OrderProcessing\OrderProcessingPayload.json
6. When prompted for Input Decision Service Name, enter (or copy) the name of the Decision Service that is the sample's target:
ProcessOrder
The request is processed, and its output is placed at [CORTICON_WORK_DIR]\output with a name formatted as OutputCRString_{epochTime}.json where {epochTime} is the number of seconds that have elapsed since 1/1/1970. The input file is also placed there. The output for the sample is as follows:
{
"Messages": {
"Message": [
{
"entityReference": "Item_id_3",
"text": "The subtotal of line item for Wrist Band is 10.500000.",
"severity": "Info",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Item_id_2",
"text": "The subtotal of line item for Racket is 20.000000.",
"severity": "Info",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Item_id_1",
"text": "The subtotal of line item for Ball is 200.000000.",
"severity": "Info",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Order_id_1",
"text": "The total for the Order is 230.500000.",
"severity": "Info",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Order_id_1",
"text": "This Order was shipped late. Ship date 12/1/2008 12:00:00 AM",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
}
],
"__metadata": {"#type": "#RuleMessages"},
"version": "0.0"
},
"Objects": [{
"total": 230.5,
"myItems": [
{
"product": "Ball",
"price": "10.000000",
"quantity": "20",
"subtotal": 200,
"__metadata": {
"#id": "Item_id_1",
"#type": "Item"
}
},
{
"product": "Racket",
"price": "20.000000",
"quantity": "1",
"subtotal": 20,
"__metadata": {
"#id": "Item_id_2",
"#type": "Item"
}
},
{
"product": "Wrist Band",
"price": "5.250000",
"quantity": "2",
"subtotal": 10.5,
"__metadata": {
"#id": "Item_id_3",
"#type": "Item"
}
}
],
"shipped": true,
"shippedOn": "12/1/2008 12:00:00 AM",
"__metadata": {
"#id": "Order_id_1",
"#type": "Order"
},
"dueDate": "1/1/2008 12:00:00 AM",
"note": "This Order was shipped late"
}]
}