Invoking JAX-WS 2.0 web Service from BPEL process using Netbeans 5.5 Enterprise pack
The goal was to put together the following technology components :
- Java EE 5
- Netbeans 5.5
- Open ESB starter Kit Beta
The first step is to acquire the bundle here and follow the instructions on this tutorial to create a web service.
The code for my web service is:
/*
* passThrough.java
*
* Created on May 24, 2006, 8:49 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.me.nullOpe;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
/**
*
* @author jc
*/
@WebService()
public class passThrough {
/**
* Web service operation
*/
@WebMethod
public String echo(@WebParam(name = "input") String input) {
// TODO implement operation
System.out.println("---"+input+"+++");
return input;
}
}
When this is done, and the service is deployed, right click on the Web Services node in your project to access the menu option "Test Web Service". The Tester page should open. Note the link to the WSDL file on that page. (If you are lost, see the Deploying and Testing the Web Service in the above mentioned tutorial
Now, lets create a BPEL workflow to invoke this service. More information on the JBI/Open ESB component of the tool bundle can be found on the Java Technology and Business Integration Services page
The first step is to create an SOA project:
- File -> New Project
- Choose Project->Samples->Service Oriented Architecture->Synchronous BPEL Process
- Next->Give a name to your project -> Finish
At this point, you should have two new nodes created in your Projects navigation panel. One for the BPEL Module, and one for the Composite Application. In order to continue, you have to add the BPEL Module to the composite application by right clicking on your Composite Application node, select "Add JBI Module", and navigate to your BPEL module jar file. You should now have a BPEL process that you can deploy and test.
More information can be found in the Netbeans Enterprise Pack 5.5 tutorial : A Simple Synchronous BPEL Process
Below are steps that are not found in the previous tutorials, and are the basic steps required to invoke web services from the BPEL process. This might not be the best way to do it, I tried to figure this by myself, and it seems to work in this simple case
The first set of steps is to import the WSDL document in the BPEL project :
- right click on the Source Package node of your BPEL application
- New -> Retrieve Schema and WSDL documents
- Select URL resource in the Location Type
- in the URL file, paste the WSDL link from your Tester session in the development of the web service, and finish
At this point, you should have two new nodes added under Source Packages . One for the WSDL, and one for the Schema. These documents were generated by JAX-WS when the service was deployed.
The next set of steps are adding a PartnerLinkType to the wsdl document. This is required by the BPEL specification, and will allow you to use this wsdl in the BPEL process as a partnerLink:
- double click on the wsdl document imported during the last step. you should see a design window allowing you to edit the wsdl document
- right click on the top level object and select "Add Extension Element" -> "BPEL <PartnerLinkType>". You should have a new node created with this label {http://schemas.xmlsoap.org/ws/2004/03/partner-link}partnerLinkType
- expand this node and edit the name (you need to have the property palette displayed to see on the right side the attribute to change
- expand the contained node with the label {http://schemas.xmlsoap.org/ws/2004/03/partner-link}role
- select the portType and enter a name for the provider role in the properties panel.
At this point, if you switch to the source view, you should have something like this added to your wsdl document :
<plink:partnerLinkType name="nullOpe">
<plink:role name="nullOpeProvider" portType="tns:passThrough"/>
</plink:partnerLinkType>
The next set of steps is adding this partnerLink to the process, and invoke it :
- double click on your bpel file in your Source Packages in order to use the BPEL designer
- delete the original assign from the SynchronousSample flow
- select the wsdl file you edited previously in the Projects navigation, and drag ad drop that file in the BPEL designer. Select the Partner Role to be your provider role, click ok.This will create the partnerLink in the designer
- drag and drop the invoke icon from the palette between the start and end in your flow (in one of the appearing target).
- right click on the just created invoke object, and select Edit. Select your newly added partnerLink, the operation should be filled, create variables for input and output by accepting the defaults. Click OK. You should now see that your invloke method is connected to the method exposed by your web service.
The next set of steps will connect the input of the BPEL process to the invoke step, and the output of the invoke step to the output of the process:
- drag and drop an assign step from the basic activities on the target just above your invoke.
- select the assign step, and you should see a mapper panel below the BPEL designer. (see the BPEL tutorial above for how to use it) connect the inputVar/inputType/paramA to the parameter in your web service input message
- drag and drop an assign step from the basic activities on the target just below your invoke.
- connect the parameter in your web service output message to the outputVar/inputType/paramA
The source view of the BPEL process should look like:
<?xml version="1.0" encoding="UTF-8"?>
<process
name="SynchronousSample"
targetNamespace="http://www.mycomp.org/SynchronousSample"
xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
xmlns:wsdlNS="http://www.mycomp.org/SynchronousSample"
xmlns:xs="http://www.mycomp.org/SynchronousSampleSchemaNamespace" xmlns:ns1="http://nullOpe.me.org/">
<import namespace="http://www.mycomp.org/SynchronousSample" location="SynchronousSample.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<import namespace="http://nullOpe.me.org/" location="localhost_8080/nullOpe/passThroughService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
<partnerLinks>
<partnerLink name="passThroughService" partnerLinkType="ns1:nullOpe" partnerRole="nullOpeProvider"/>
<partnerLink name="partnerLinkA"
partnerLinkType="wsdlNS:SynchronousSamplePartnerLinkType"
myRole="SynchronousSampleProvider" />
</partnerLinks>
<variables>
<variable name="EchoOut1" messageType="ns1:echoResponse"/>
<variable name="EchoIn1" messageType="ns1:echo"/>
<variable name="inputVar" messageType="wsdlNS:requestMessage"/>
<variable name="outputVar" messageType="wsdlNS:responseMessage"/>
</variables>
<sequence>
<receive
name="start"
partnerLink="partnerLinkA"
portType="wsdlNS:MyPortType"
operation="operationA"
variable="inputVar"
createInstance="yes"/>
<assign name="Assign1">
<copy>
<from>$inputVar.inputType/paramA</from><to>$EchoIn1.parameters/input</to>
</copy>
</assign>
<invoke name="Invoke1" partnerLink="passThroughService" operation="echo" portType="ns1:passThrough" inputVariable="EchoIn1" outputVariable="EchoOut1"/>
<assign name="Assign2">
<copy>
<from>$EchoOut1.parameters/return</from><to>$outputVar.resultType/paramA</to>
</copy>
</assign>
<reply name="end"
partnerLink="partnerLinkA"
portType="wsdlNS:MyPortType"
operation="operationA"
variable="outputVar"/>
</sequence>
</process>
the resulting workflow would look like this :

This is it. You should be able to deploy the updated project, and test it (remove the content of the output.xml to check the output).
Re: Invoking JAX-WS 2.0 web Service from BPEL process using Netbeans 5.5 Enterprise pack
WARNING: (JBIMA0405) Start of service assembly SynchronousSampleApplication succeeded partially; some service units failed to start.
* Component: sun-bpel-engine
ERROR: (BPJBI-4001:BPELSE) BPJBI-7004:Service unit SynchronousSampleApplication-SynchronousSample failed to load deployment C:\Program Files\glassfish-v2ur1\domains\domain1\jbi\service-assemblies\SynchronousSampleApplication\SynchronousSampleApplication-SynchronousSample\sun-bpel-engine : BPJBI-6024:Error while loading BPEL file C:\Program Files\glassfish-v2ur1\domains\domain1\jbi\service-assemblies\SynchronousSampleApplication\SynchronousSampleApplication-SynchronousSample\sun-bpel-engine\SynchronousSample.bpel, Exception details are Cannot parse BPEL (see below):
==> Cannot load imported document (see below):
==> Unable to import wsdl document for import (see below):
==> Failed to resolve publicId http://echopack/ and systemId EchoServiceService.wsdl to a WSDLDocument. (see below):
==> Failed to parser xsd document file:/C:/Program%20Files/glassfish-v2ur1/domains/domain1/jbi/service-assemblies/SynchronousSampleApplication/SynchronousSampleApplication-SynchronousSample/sun-bpel-engine/EchoServiceService.wsdl
* Component: sun-http-binding
INFO: (JBIMA0409) Lifecycle operation start succeeded for Service Unit SynchronousSampleApplication-sun-http-binding.
BUILD FAILED (total time: 2 seconds)
