<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="javax.xml.soap.SOAPElement" import="javax.xml.soap.SOAPException" %> <% // Initialize the variables which we will display on this page String myPIID = (String) request.getParameter("PIID"); // passed in URL as "...?PIID=_PI:..." String myInternalPIID = myPIID; // will be refreshed later String myExecutionState = null; String myInput = ""; String myOutput = "(not available yet)"; String myOutputVarForDisplay = ""; boolean doRefresh = false; boolean piidExists; // get the process instance com.ibm.www.GetProcessInstance myGetProcessInstanceParms = new com.ibm.www.GetProcessInstance(); com.ibm.www.GetProcessInstanceResponse myGetProcessInstanceResponse = null; try { // here, as PIID the process instance name may be used; // when starting a process using BPC explorer, user may choose this; // otherwise this is the _PI:... name. myGetProcessInstanceParms.setPiid(myPIID); myGetProcessInstanceResponse = MyBFMAccess.getProcessInstance(myGetProcessInstanceParms); piidExists = true; } catch (Exception e) { System.out.println("Process instance "+myPIID+" does not exist."); piidExists = false; } if (piidExists) { try { // get hold of the process instance object com.ibm.www.ProcessInstanceType myProcessInstance = myGetProcessInstanceResponse.getProcessInstance(); // get internal PIID which is required for retrieving the messages myInternalPIID = myProcessInstance.getPiid(); // prepare to query input message com.ibm.www.GetInputMessageForProcessInstance myGetInputMessageForPIParms = new com.ibm.www.GetInputMessageForProcessInstance(); myGetInputMessageForPIParms.setPiid(myInternalPIID); com.ibm.www.GetInputMessageForProcessInstanceResponse myGetInputMessageForPIResponse = null; // get the input message and concatenate some values myGetInputMessageForPIResponse = MyBFMAccess.getInputMessageForProcessInstance(myGetInputMessageForPIParms); SOAPElement myInputMessage = myGetInputMessageForPIResponse.get_any(); org.w3c.dom.Node tmpNode; tmpNode = myInputMessage.getElementsByTagName("firstName").item(0); if (tmpNode!=null && tmpNode.getFirstChild()!=null) myInput = tmpNode.getFirstChild().getNodeValue(); tmpNode = myInputMessage.getElementsByTagName("lastName").item(0); if (tmpNode!=null && tmpNode.getFirstChild()!=null) myInput += " "+tmpNode.getFirstChild().getNodeValue(); tmpNode = myInputMessage.getElementsByTagName("city").item(0); if (tmpNode!=null && tmpNode.getFirstChild()!=null) myInput += ", "+tmpNode.getFirstChild().getNodeValue(); // get the execution state myExecutionState = myProcessInstance.getExecutionState(); if (myExecutionState.equals("STATE_RUNNING")) { // still in running state, try again in a moment doRefresh = true; } else if (myExecutionState.equals("STATE_FINISHED")) { // done, get the output message com.ibm.www.GetOutputMessageForProcessInstance myGetOutputMessageParms = new com.ibm.www.GetOutputMessageForProcessInstance(); com.ibm.www.GetOutputMessageForProcessInstanceResponse myGetOutputMessageResponse = null; myGetOutputMessageParms.setPiid(myInternalPIID); myGetOutputMessageResponse = MyBFMAccess.getOutputMessageForProcessInstance(myGetOutputMessageParms); if (myGetOutputMessageResponse != null) { SOAPElement myOutputMessage = myGetOutputMessageResponse.get_any(); String myOutputVar = myOutputMessage.getFirstChild().getNodeName(); myOutputVarForDisplay = " (" + myOutputVar + ")"; tmpNode = myOutputMessage.getElementsByTagName(myOutputVar).item(0); if (tmpNode!=null && tmpNode.getFirstChild()!=null) { myOutput = tmpNode.getFirstChild().getNodeValue(); } else { myOutput = "[not set]"; } } } } catch (Exception e) { System.out.println("Error while doing call: "+e); e.printStackTrace(System.out); } } // end if %> <% if (doRefresh) { %> <% } // end if %> viewprocess.jsp

Web Service API - Sample




<% if (!piidExists) { %> Process instance <%=myPIID%> does not exist. <% } else { %>

Process Instance Details

<% if (!myInput.equals("")) { %> <% } // end if %>
Input values:<%=myInput%>
Execution state:<%=myExecutionState%>
Internal name:<%=myInternalPIID%>
Output<%=myOutputVarForDisplay%>:<%=myOutput%>
<% } // end if %>

Advanced sample - Home <% if (doRefresh) { %>


This page will refresh automatically. <% } // end if %>