<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@page import="com.ibm.xmlns.prod.websphere.business_process.services._7_0.binding.*"%> <%@page import="com.ibm.xmlns.prod.websphere.business_process.types._7.*"%> <%@page import="com.ibm.xmlns.prod.websphere.bpc_common.types._7.*"%> <%@page import="com.ibm.jaxws.sample.security.MySecurityHelper"%> <%@page import="com.ibm.mySerializer.mySerializer"%> <%@page import="java.util.List"%> <%@page import="wsapimodule.*"%> <%@page import="wsapimodule.advertiseprocessinterface.*"%> <% // Receive username and password via http reuqest parameters String user = "admin"; String password = "admin"; BFMJAXWSPortType bfm = BFMService.getBFMJAXWSPort(); MySecurityHelper.enhanceWithUsernameToken(bfm, user, password); // Initialize the variables which we will display on this page String myPIID = 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; try { // get the process instance ProcessInstanceType myProcessInstance = bfm.getProcessInstance( myPIID ); // get internal PIID which is required for retrieving the messages myInternalPIID = myProcessInstance.getPiid(); // get the input message and concatenate some values UserDataType userdataInput = bfm.getInputMessageForProcessInstance( myInternalPIID ); Operation1 myInputMessage = (Operation1) userdataInput.getAny(); BOCustomer customer = myInputMessage.getCustomer(); BOAddress address = customer.getAddress(); myInput = customer.getFirstName() +" "+ customer.getLastName() +", "+ address.getCity(); // 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 UserDataType userdata_Output = bfm.getOutputMessageForProcessInstance( myInternalPIID ); Operation1Response myGetOutputMessage = (Operation1Response) userdata_Output.getAny(); myOutputVarForDisplay = " (isEligible)"; if (myGetOutputMessage != null) { myOutput = myGetOutputMessage.isIsEligible().toString(); } else { myOutput = "[not set]"; } } } catch (Exception e) { System.out.println("Error while doing call: "+e); if ( e instanceof ProcessFaultMsg ) { ProcessFaultMsg pfm = (ProcessFaultMsg) e; List list = ( pfm.getFaultInfo() ).getFaultStack(); FaultStackType fault = list.get( 0 ); out.println( "

Message: " + fault.getMessage() ); } } %> <% if (doRefresh) { %> <% } // end if %> viewprocess.jsp

Web Service API - Sample




Process Instance Details

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


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


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