Goal
When creating SOA projects like bpel it is often desired to call a service residing in one project from another project. Typically to do this one needs to have the wsdl contract of the invoked service available in the project which
wants to call this service.
Copying wsdl from one project to another can accomplish this task but this can lead to duplication of wsdls. Also the side effect is that when the original wsdl contract changes, it is hard to find out who is using it and user needs to redo changes everywhere, the wsdl is copied.
How can we avoid copying wsdl across projects? There is an option available which can avoid copying wsdl and use
reference to original wsdl. This is described in details below:
Assumption
The assumption is that user is familiar with concept of bpel, understand bpel and composite app project as available in netbeans and is able to deploy bpel projects to openesb
bpel engine
.
Technical Details:
Refering resource (wsdl/xsd) by reference uses catalog.xml at each project and updates it as new resources from
other projects are added. Catalog.xml acts as a redirection mechanism where the resource is referred by a system id which maps to the physical location of the resource. An artifact (ex bpel or wsdl) can refer to the resource from
another project using this system id.
How to accomplish this goal:
Here we describe high level flow of how to use wsdls across projects when using bpel project in netbeans. Following are the steps:
(1) Create a bpel project (We use SynchronousSample bpel project as available in netbeans which also creates a composite app project which can be used to deploy this bpel project)
The bpel project is shown below. Note it has one wsdl file which specifies the web service implemented in the bpel process.
(2) Create another bpel project and composite app project which can deploy this bpel project:
In this project we will call the service as implemented in SynchronousSample project of step (1).
(3) Add wsdl service by reference:
There are two ways to do it:
- (a)one is to right click on "Referenced Resources" node on the project as shown below:
Then select "Add Project Resource" option to browse to the location of the wsdl file in another project. (In our case
SynchronousSample project as created in step (1)).
Once we select the wsdl file, the "Referenced Resources" node on the project gets updated and it shows the referenced
resource:
Above mechanism should be available in most SOA projects.
- (b)Another option is to directly drag and drop wsdl from SynchronousSample project created in Step (1), to another
project created in Step (2). This is bpel project specific functionality and may not be available in other
SOA projects:
(4) Under the cover a project level catalog.xml file gets updated and one catalog entry is added for this referenced wsdl. catalog.xml provides the functionality to be able to refer a resource of another project:
(5) When the project is build, it creates a service unit jar file for deployment to the project specific engine. (In this case bpel engine). This service unit jar packages a catalog.xml and also all the referenced resources from other projects:
(6) Once a resource from another project is added, The dialogs in the project which refers artifacts from another project shows the referenced resources as well, so that user can select them. For example when creating a bpel variable
the wsdl file (and messages declared in it) from other project is also listed: