Integration of Python with Corticon Decision Service

Posted by navjot on 04-Nov-2019 10:35

Hi Guys,

Does anyone have details for integration of Python with Corticon Decision Service?  Please provide sample Python program which consume Coritcon Decision Service as REST if anyone already done this. 

Also please let me know the compatible version of Python and Corticon which supports REST service interaction. Let me know about the configurations as well that we should consider for consuming Corticon Service from Python through REST call.

Thanks in advance,

All Replies

Posted by gsaintma on 04-Nov-2019 10:48

See the sample installed in the Server work directory at \Samples\Clients\Python\RESTClient. Hope that helps.
 
 

Posted by navjot on 04-Nov-2019 10:56

I checked this directory. But i didn't find any samples. There is no directory like "\Samples\Clients\Python\RESTClient". If possible please attach files present in that directory. It would be very helpful.

Thanks in advance.

Posted by navjot on 04-Nov-2019 10:56

I checked this directory. But i didn't find any samples. There is no directory like "\Samples\Clients\Python\RESTClient". If possible please attach files present in that directory. It would be very helpful.

Thanks in advance.

Posted by gsaintma on 04-Nov-2019 11:08

Here you go. You should have it. It has been in the Server WorkDirectory since version 5.6.
 

Posted by gsaintma on 04-Nov-2019 11:10

The attachment did not get through. Here is the file:
#
# Copyright 2017 by Progress Software Corporation. All rights reserved.
#
 
# Python sample for making a REST execution call to corticon decision service.
# For this execution to work you need the ProcessOrder decision service
# deployed to your server.
 
import requests
import json
 
#Declare connection properties
corticonServerProtocol = 'http'
corticonServerAddress = 'localhost'
corticonServerPort = '8850'
corticonServerPath = '/axis/corticon/execute'
 
#File location
jsonFilePath = '../../data/OrderProcessingPayload.json'
 
#Read the file
with open(jsonFilePath, 'r') as f: jsonfileContents = f.read()
 
#Connect to the server
corticonURL = corticonServerProtocol + "://" + corticonServerAddress + ":" + corticonServerPort + corticonServerPath
response = requests.post(corticonURL, data=jsonfileContents, headers={'Content-type' : 'application/json'})
 
#Pretty-print the JSON
responseText = response.text
responseJSON = json.loads(responseText)
print json.dumps(responseJSON, indent=2, sort_keys=True)
 

Posted by navjot on 04-Nov-2019 11:53

Thank you so much for your help. I am using Corticon 5.5, I believe that's why that folder is not present in my system. Just one question, Corticon 5.5 support REST calls ?

Posted by gsaintma on 04-Nov-2019 12:06

Sure. See page 77 of the 5.5.2 Integration and Deployment Guide. By the way, REST support has been expanding in newer versions of Corticon. Your version 5.5.2 was retired last June.
 

Posted by navjot on 04-Nov-2019 14:53

Thanks for your help. Could  you please tell me the Python version also which support consuming REST service calls?

Posted by gsaintma on 04-Nov-2019 15:54

You are welcome.
Sorry, no. Maybe someone else can pick up on this thread to answer that question.
 

Posted by navjot on 04-Nov-2019 16:47

OK Thanks,

Just wanted to know whether we have flexibility to write Python code in Corticon itself? Like we can write Java code in Corticon so do we have capability to Python code as well in Corticon?

Posted by James Arsenault on 05-Nov-2019 17:10

We've not certified any specific versions of python with Corticon. Corticon can be deployed as a REST service and python can call REST services. As long as your able to make the call and pass compliant JSON, you should be able to integrate.

Corticon has no ability to generate Python code.  You may be able to run Corticon in-process and call it directly from Python script using Jython. This is not something we've tried or certified. Having worked with Jython in a past job I suspect it would work but can make no guarantees.

This thread is closed