oracle-databasecurlrightnow-crmoracle-service-cloud

HTTP Session from service cloud using PHP code


Is it possible to send custom XML messages from oracle service cloud while maintaining HTTP session?

So far I've managed to send a single message using cURL:

<?php

use \Rightnow\Connect\v1_2 as RNCPHP;
use \Rightnow\CPM\v1 as RNCPM;

    $url1 = "";
    $startInterviewHeaders = array("SOAPAction: http://oracle");
    $startInterview;

    // session

    //$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/'; 

    if(!function_exists("\curl_init")){
        \load_curl();
        echo "curl loaded";
    } else {
        echo "curl already exists   ";
    }
    $ch = curl_init();

    curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $url1);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $startInterview);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $startInterviewHeaders);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    $startInterviewresponse = curl_exec($ch);
    //echo $response;

    $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_errno= curl_errno($ch);
    echo "</br> HTTP status: " . $http_status . "</br> cURL error: " .$curl_errno . "</br>";
    curl_close($ch); //  close cURL
    echo $startInterviewresponse;


?>

EDIT: Code above sends a single message and gets a response, but when I try to maintain HTTP session with CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE, second cURL message response complains that there is no active session.

sessions.com.oracle.determinations.server.exceptions.NoActiveInterviewExceptionaction "Investigate" can not be performed without an active interview

Code I used to maintain session (worked when testing outside Rightnow environment)

curl_setopt($ch,CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name');  //could be empty, but cause problems on some hosts
    curl_setopt($ch, CURLOPT_COOKIEFILE, '/var/www/ip4.x/file/tmp');  //could be empty, but cause problems

Thanks!


Solution

  • Your code sample is a Custom Process Model. CPMs do not allow persistence and will be closed once the CPM completes. You can run multiple curl calls from one CPM, but that is not recommended; you should use an integration middleware if you need multiple calls per CPM.

    As long as you're running this code from an asynchronous CPM (synchronous CPMs don't expose curl, so that should be the case here), then an error on the OSvC side is likely an issue connecting to your "local test server", which is almost always not exposed to the public internet in an enterprise environment. Therefore, your "crash" is likely a connection error.

    Per @drew010, you need to include your error in the context of this question as well.