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

Try Corticon Now
Running the sample JSON Request on .NET server
A Corticon Server installation provides a JSON sample (similar to the SOAP .xml sample) and a test script that runs the sample.
Note: JSON datatypes require double-quotes only on String values. As JSON does not have a date datatype, Corticon treats time values as Strings. When the other datatypes -- Booleans and numbers -- are in quotes, Corticon interprets the datatype from its Vocabulary properties and removes the quotes. Output will conform to the JSON syntax.
The sample, located at [CORTICON_WORK_DIR]\Samples\Rule Projects\OrderProcessing\OrderProcessingPayload.json, is as follows:

{"Objects": [
{
"total": null,
"shipped": null,
"item": [
{
"product": "Ball",
"price": "10.000000",
"quantity": "20",
"subtotal": null,
"__metadata": {
"#id": "Item_id_7",
"#type": "Item"
}
},
{
"product": "Racket",
"price": "20.000000",
"quantity": "1",
"subtotal": null,
"__metadata": {
"#id": "Item_id_8",
"#type": "Item"
}
},
{
"product": "Wrist Band",
"price": "5.250000",
"quantity": "2",
"subtotal": null,
"__metadata": {
"#id": "Item_id_9",
"#type": "Item"
}
}
],
"shippedOn": null,
"__metadata": {
"#id": "Order_id_1",
"#type": "Order"
},
"dueDate": "1/1/2008",
"note": null
},
{
"total": null,
"shipped": null,
"item": [
{
"product": "Pencil",
"price": "1.000000",
"quantity": "10",
"subtotal": null,
"__metadata": {
"#id": "Item_id_10",
"#type": "Item"
}
},
{
"product": "Notebook",
"price": "3.000000",
"quantity": "2",
"subtotal": null,
"__metadata": {
"#id": "Item_id_11",
"#type": "Item"
}
},
{
"product": "Eraser",
"price": "2.000000",
"quantity": "1",
"subtotal": null,
"__metadata": {
"#id": "Item_id_12",
"#type": "Item"
}
}
],
"shippedOn": null,
"__metadata": {
"#id": "Order_id_2",
"#type": "Order"
},
"dueDate": "1/1/2009",
"note": null
}
]}

To run the JSON sample:
1. Start Corticon Server .NET.
2. Open a command prompt window at [CORTICON_HOME]\Server .NET\samples\bin.
3. Launch Corticon-Api-Rest-Test.exe. 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 the path to the sample:
C:\Users\{user}\Progress\CorticonWork_5.7\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": "Order_id_2",
"text": "The total for the Order is 18.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",
"severity": "Warning",
"__metadata": {"#type": "#RuleMessage"}
},
{
"entityReference": "Order_id_2",
"text": "This Order was shipped on time. Ship date 12/1/2008",
"severity": "Info",
"__metadata": {"#type": "#RuleMessage"}
}
],
"__metadata": {"#type": "#RuleMessages"},
"version": "1.10"
},
"Objects": [
{
"total": 230.5,
"shipped": true,
"item": [
{
"product": "Ball",
"price": "10.000000",
"quantity": "20",
"__metadata": {
"#type": "Item",
"#id": "Item_id_7"
},
"subtotal": 200
},
{
"product": "Racket",
"price": "20.000000",
"quantity": "1",
"__metadata": {
"#type": "Item",
"#id": "Item_id_8"
},
"subtotal": 20
},
{
"product": "Wrist Band",
"price": "5.250000",
"quantity": "2",
"__metadata": {
"#type": "Item",
"#id": "Item_id_9"
},
"subtotal": 10.5
}
],
"shippedOn": "12/1/2008",
"__metadata": {
"#type": "Order",
"#id": "Order_id_1"
},
"dueDate": "1/1/2008",
"note": "This Order was shipped late"
},
{
"total": 18,
"shipped": true,
"item": [
{
"product": "Pencil",
"price": "1.000000",
"quantity": "10",
"__metadata": {
"#type": "Item",
"#id": "Item_id_10"
},
"subtotal": 10
},
{
"product": "Notebook",
"price": "3.000000",
"quantity": "2",
"__metadata": {
"#type": "Item",
"#id": "Item_id_11"
},
"subtotal": 6
},
{
"product": "Eraser",
"price": "2.000000",
"quantity": "1",
"__metadata": {
"#type": "Item",
"#id": "Item_id_12"
},
"subtotal": 2
}
],
"shippedOn": "12/1/2008",
"__metadata": {
"#type": "Order",
"#id": "Order_id_2"
},
"dueDate": "1/1/2009",
"note": "This Order was shipped on time"
}
],
"name": "ProcessOrder"
}