Multi Schema WSDL and separate packages
How to use JAXB bindings with WSDL to separate schemas into different packages.
WSDL
As discussed in my previous blog, WSDL is an XML format that describes network services. It defines endpoints and their request and response formats.
WSDL files contain schemas to describe those request and response objects. A single WSDL file could contain multiple schemas. This is commonly used to share some objects between different network services. Such as to define some common types.
Example
You may have two WSDL files.
One describes a shopping service, and the other defines a checkout service. In the checkout service, you might buy things you shopped for. So it’s easy to see why you’d want to share some objects.
Packages
You can create your client library with these WSDL files as-is. But you might want to put files from the different schemas into separate packages.
To achieve this you need to use the JAXB bindings feature. For each WSDL file create a new bindings file.
For example:
- src/main/resources/META-INF/bindings-shopping.jaxb
- src/main/resources/META-INF/bindings-checkout.jaxb
Within these files, we define the base package which our Services will go into. Then we also define a package for each of the schemas.
Now all that’s left is to tell our wsimport
task about these bindings files.
Now run the wsimport
task. It will generate a HTTP client using the separate packages you specified.
Previous Post
Originally published at https://www.brightec.co.uk.