Integration of Python with Corticon Decision Service - Forum - Corticon - Progress Community

Integration of Python with Corticon Decision Service

 Forum

Integration of Python with Corticon Decision Service

This question is not answered

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
  • See the sample installed in the Server work directory at \Samples\Clients\Python\RESTClient. Hope that helps.
     
     
  • 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.

  • 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.

  • Here you go. You should have it. It has been in the Server WorkDirectory since version 5.6.
     
  • 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)
     
  • 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 ?

  • 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.
     
  • Thanks for your help. Could  you please tell me the Python version also which support consuming REST service calls?

  • You are welcome.
    Sorry, no. Maybe someone else can pick up on this thread to answer that question.
     
  • 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?

  • 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.