%@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="javax.xml.namespace.QName"%>
<%@page import="java.util.List"%>
<%@page import="com.ibm.jaxws.sample.security.MySecurityHelper"%>
<%@page import="com.ibm.mySerializer.mySerializer"%>
<%@page import="wsapimodule.*"%>
<%@page import="wsapimodule.advertiseprocessinterface.*"%>
startprocess.jsp
Web Service API - Sample
<%
try {
// Receive username and password via http reuqest parameters
String user = "admin";
String password = "admin";
BFMJAXWSPortType bfm = BFMService.getBFMJAXWSPort();
MySecurityHelper.enhanceWithUsernameToken(bfm, user, password);
// Process template settings
String myOperation = "operation1"; // Interface editor: we did use the default
String myPortTypeName = "advertiseProcessInterface"; // see Interface editor
String myInterfaceURI = "http://WSApiModule/"+myPortTypeName; // see IF editor
String myNamespacePrefix = "mynsprefix"; // can be any value
String myProcessTemplateName = "advertiseProcess";
// Data received from HTML form
String myFName = (String) request.getParameter("fname"); // first name
String myLName = (String) request.getParameter("lname"); // last name
String mySName = (String) request.getParameter("sname"); // street name
String myCName = (String) request.getParameter("cname"); // city name
// assemble the process input message
BOAddress address = new BOAddress();
address.setStreet( mySName );
address.setCity( myCName );
BOCustomer customer = new BOCustomer();
customer.setFirstName( myFName );
customer.setLastName( myLName );
customer.setAddress( address );
Operation1 operation1 = new Operation1();
operation1.setCustomer( customer );
// prepare parameters for starting the process
UserDataType userdata = new UserDataType();
userdata.setAny(mySerializer.getElement("wsapimodule.advertiseprocessinterface", operation1));
String piid = bfm.sendMessage(myProcessTemplateName, new QName(myInterfaceURI, myPortTypeName), myOperation, userdata, null);
if (piid == null) {
out.println("No response available; please inspect server logs for possible problems.");
System.out.println("Call failed, no response to be processed");
} else {
out.println("Asynchronous process started successfully.
");
out.println("Follow this link to see the process status and to inspect the results.
");
System.out.println("Process started, PIID = "+piid);
} // end if
} catch (Exception e) {
System.out.println(e.getStackTrace());
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() );
}
}
%>
Advanced sample - Home