Invoke BPEL Process using JAVA

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.

Advertisements

About shouab

I am Shouab working as Pr Software Engg. I have 6 plus years of experience in Enterprise Application Development. I have expertise in different J2EE frameworks like JSF,Spring,Hibernate, Smart Client, Oracle SOA, Weblogic Portal and many more.
This entry was posted in BPEL. Bookmark the permalink.

4 Responses to Invoke BPEL Process using JAVA

  1. hpu says:

    thanks for this useful post.
    but could you probably gives a complete source, cause i’ve tried this code and can not fixed imports.

  2. sellamiwael says:

    Thanks for your post 🙂
    In fact, I added all jar files for axis to my libraries project but the program still not recognize the imports !! Please how can I correct this ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s