It is a way how to start a process by sending HTTP request to "Message Start Event", the Data Receiving Icon in process models (process definition). In this article, we will tell you about how to develop applications using PHP HTTP communication module "PEAR:: HTTP_Client". And sample code as well.
See the following manual page for details of Message Start Event.
Message Start Event and Message Catching Intermediate Event
Version Details
We assume that a Process Model which contains a Message Start Event has been created and activated in advance. The process Model in this sample is available to download in our archive.
link MessageStart-en.qar
Message Start Event is started by receiving HTTP request. Here we use PEAR HTTP_Client as a library for HTTP communication in PHP. Install PEAR and HTTP_Client in advance.
The option of useBrackets must be set 'false' for setting multiple choice in Select type data, or for sending multiple files in one File type data item. Check the URL to connect in the detail screen of Process Model. Although there are URL described in the detail screens that several parameters have been specified in Query String, please exclude the Query String from a URL when you send POST.
$client =& new HTTP_Client(array("useBrackets" => false));
$url = "https://s.questetra.net/00000000/System/Event/MessageStart/start";
Three parameters, processModelInfoId, nodeNumber, key, are included in the URL listed in the process model detail screen.
In addition, set Subject and process data as needed.
For multiple choice in Select type, specify the value in array.
$params = array(
"processModelInfoId" => "1",
"nodeNumber" => "0",
"key" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"title" => "Subject",
"data[0].input" => "String",
"data[1].input" => 12345,
"data[2].selects" => array("1", "2"),
"data[3].input" => "2011-09-26",
"data[4].input" => "2011-09-26",
"data[4].time" => "12:34",
"data[6].email" => "SouthPole@questetra.com",
"data[7].console" => "Discussion type",
"data[9].input" => "<list><row><col>Letters</col><col>54321</col></row></list>"
);
Specify File type data separately. Multiple files can be handed in one data item. In the following code, two files of sample.png and sample.gif are specified. Specify the file name in referable pass to the application.
$files = array(
array("data[5].upload", array("sample.png", "sample.gif"), array("image/png", "image/gif"))
);
At last, send the request.
$client->post($url, $params, false, $files);
If the process start was successful, the status code 200 response will return.
If it failed to start the process due to an error in the parameter, status code 500 response will return. If it failed to start, the body of the response contains an XML describing the contents of the error. Response code can be retrieved by the following code to determine.
$response = $client->currentResponse();
if($response["code"] == 200) {
// Success
} else {
// Error returned
print_r($response);
}
The entire sample code including error processing has been published in the following locations
https://gist.github.com/1247456