The Following Code will invoke the Vaccation Request BPEL process come in samples with BPEL Manager installation.
try
{
URL url = new URL("http://host:port/wsdl link of deployed bpel");
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(url);
call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
call.setProperty(Call.SOAPACTION_URI_PROPERTY, SOAP_ACTION);
call.setProperty( Call.OPERATION_STYLE_PROPERTY , STYLE );
call.setOperationName(OPERATION_NAME);
call.addParameter(new QName(PARAMETER_NAMESPACE,"creator"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(PARAMETER_NAMESPACE,"fromDate"), XMLType.XSD_DATETIME, ParameterMode.IN);
call.addParameter(new QName(PARAMETER_NAMESPACE,"toDate"), XMLType.XSD_DATETIME, ParameterMode.IN);
call.addParameter(new QName(PARAMETER_NAMESPACE,"reason"), XMLType.XSD_STRING, ParameterMode.IN);
Object[] params = new Object[4];
params[0] = "Anna";
params[1] = new Date();
params[2] = new Date();
params[3] = "No Reason";
/* Invoke the service */
/*************************************/
call.invokeOneWay(params);
System.out.println( "Vacation Request BPEL process initiated" );
}
catch (SOAPFaultException e)
{
System.err.println("Generated fault: ");
System.out.println (" Fault Code = " + e.getFaultCode());
System.out.println (" Fault String = " + e.getFaultString());
}
catch (JAXRPCException e)
{
System.err.println("JAXRPC Exception: " + e.getMessage());
}
catch (ServiceException e)
{
System.err.println("Service Exception: " + e.getMessage());
}
catch(Exception e)
{
e.printStackTrace();
System.err.println("Other Exception: " + e.getMessage());
}
I write this code using apache axis client you need to add apache axis libraries in your project build path.
thanks for this useful post.
but could you probably gives a complete source, cause i’ve tried this code and can not fixed imports.
You need to add Apache Axis Libraries in your class path which is available on Apache site. If you unable to do so let me know.