Wednesday, May 9, 2012

Using nested Schemas within BPEL

When developing any BPEL based solution, you soon find that you are defining a common set of data objects that are used across multiple processes.

The most obvious place to define those data objects is in one or more XML Schemas which can then be referenced by each of your BPEL Processes.

Oracle BPEL PM 10.1.3 now provides the ability to import these Schemas as part of the BPEL Project Creation Wizard (in previous versions you had to import the Schema after the project was created – which you can of course still do in 10.1.3).

This all works very well, however there is a simple gotcha, that I’ve seen catch out a number of people, and that’s when you import schema’s which themselves import schemas.

Let’s take a simple example. A common scenario is to have a schema which defines common objects such as address, phoneNo, etc. This would be shared across multiple domain specific schemas such as customer (e.g. it imports the common schema to use the address, phoneNo type to hold the equivalent information for a customer).

Now, if were to import the customer schema into our BPEL Process, by default all we are importing are the definitions contained in Customer.xsd. This causes problems when we attempt to parse the customer schema as the parser can’t reference the definitions in the common schema.

The obvious answer here is to simply import the common schema as well. However this doesn’t work. To understand why let’s look at the import statements created in the <types> element of the WSDL file for the BPEL process:



The issue here is that each of the schemas has been imported into a “separate” schema, thus the common schema is not visible to the customer schema. However to fix this you simply edit the WSDL file to combine the imports into a single schema as illustrated below:

########

0 comments: