Skip to main content
Jump to: navigation, search

Stardust/Knowledge Base/Integration/UI/UIMashup/PHP Example


This example assumes that the reader is familiar with the use of the External Web Application type provided by Stardust. The example model referenced here may be downloaded from this location.

External PHP Page

global $baseUri;
global $inData;
$inData = $_GET['ippInteractionUri']."/inData";
global $outData;
$outData = $_GET['ippInteractionUri']."/outData";
<script type="text/javascript" src="<?php print "$baseUri"; ?>/plugins/processportal/IppProcessPortal.js""></script>
<?php $url_contents = file_get_contents($inData);
	  $doc = new DOMDocument();
	  $doc->preserveWhiteSpace = false;
	  $xpath = new DOMXPath($doc);
	  $rootNamespace = $doc->lookupNamespaceUri($doc->namespaceURI);
	  $xpath->registerNamespace('x', $rootNamespace); 	
	  $xpath->registerNamespace('Student', ''); 	
	  $xpath->registerNamespace('ns5', ''); 	
	  $nodelist = $xpath->query("//x:inDataValues/x:parameter/x:xml/Student:Student");
	  foreach ($nodelist as $node) {
	 			//echo $node->nodeName." ", $node->nodeValue." ";
				$nodelistchildren = $node->childNodes;
				foreach ($nodelistchildren as $nodeChild) {
					echo $nodeChild->nodeName." ", $nodeChild->nodeValue." ";
				echo "<br>";
	  $url = $outData."/Student2";
	  $xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Student:Student xmlns:Student=\"\" xmlns=\"\"><Id xmlns:ns5=\"\" xmlns=\"\">576</Id><FirstName xmlns:ns5=\"\" xmlns=\"\">Amit</FirstName><LastName xmlns:ns5=\"\" xmlns=\"\">Kapoor</LastName><Age xmlns:ns5=\"\" xmlns=\"\">35</Age><Address xmlns:ns5=\"\" xmlns=\"\"><Street1>14/19 Karol Bagh</Street1><Street2>Connaught Place</Street2><City>Delhi</City><State>DL</State><Zip>11001</Zip></Address></Student:Student>";
	  // Start curl
	$ch = curl_init();
	// Clean up string
	$putString = stripslashes($xmlString);
	// Put string into a temporary file
	$putData = tmpfile();
	// Write the string to the temporary file
	fwrite($putData, $putString);
	// Move back to the beginning of the file
	fseek($putData, 0);
	$headers = array(
    'Accept: application/xml',
    'Content-Type: application/xml',
	// Headers
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	// Binary transfer i.e. --data-BINARY
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_URL, $url);
	// Using a PUT method i.e. -XPUT
	curl_setopt($ch, CURLOPT_PUT, true);
	// Instead of POST fields use these settings
	curl_setopt($ch, CURLOPT_INFILE, $putData);
	curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString));
	$output = curl_exec($ch);
			print curl_error($ch);
	  else {
		    $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
              case 200:
                  $result = 'HTTP CODE -> ' . $returnCode;
				  print $result;	  
	// Close the file
	// Stop curl
<button onclick="InfinityBpm.ProcessPortal.completeActivity()">Complete your activity instance now</button>

Back to the top