Question & Answer
Question
How do you generate JAX-WS Client classes that implement the java.io.Serializable interface?
Cause
The JAX-WS wsimport tool uses the JAXB xjc tool to generate the JAXB data objects. The JAXB specification defines a <serializable> customization. When that customization is used, the JAXB data objects will extend java.io.Serializable. See the JSR-000222 Java(TM) Architecture for XML Binding (JAXB) Specification for more information.
Answer
Currently required steps:
- From the annotated Java classes, generate a WebService Bottom Up asking for the wsdl to be generated in the project. This will create the wsdl and the schema files.
- Now that you know the schema name, add inside the same directory where the schema resides the following file (JAXB external bindings file). The only parameter that needs to change in this file is the schema location, which must be the (relative) path to the generated schema file:
File Bindings.xml:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="1.0">
<jaxb:bindings schemaLocation="Bean1Service_schema1.xsd"
node="/xs:schema">
<jaxb:globalBindings >
<xjc:serializable/>
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
The bindings can also be customized inline, in the generated XML schema, but the approach of using an external bindings file has the advantage that the same external JAXB binding file can be reused in every project, apart from the name schema change (above, Bean1Service_schema1.xsd indicates the name of the schema). Also, if you need to regenerate the wsdl/schema, the binding file remains untouched.
- When you want to generate the client, in the Wizard you have the option to add an external bindings file:
- Running the wizard is equivalent to executing the following command line (the example listed below is for Websphere Application Server 6.1 on Windows):
C:\Program Files\IBM\SDP\runtimes\base_v61\bin\wsimport.bat"
<path>\Bean1Service.wsdl -b <path>\Bindings.xml -keep
Related Information
[{"Product":{"code":"SSRTLW","label":"Rational Application Developer for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Services Development","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS4JCV","label":"Rational Software Architect for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Services Development","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5","Edition":"","Line of Business":{"code":"LOB15","label":"Integration"}}]
Was this topic helpful?
Document Information
Modified date:
29 September 2018
UID
swg21420871