IBM Support

JAXB collection types display as java.lang.List on JAX-WS operations

Troubleshooting


Problem

When you use Java™ Architecture for XML Binding (JAXB) customization to customize a collection property such as the following: [] [] JAXB generates JavaBeans that satisfy the JAXB specification requirements for indexed properties. The JavaBeans contain getter and setter methods that return an internal implementation of an indexed array list. The following example demonstrates what a JAXB generated JavaBeans would look like when customized to an indexed array: [] public Items[] getReturn() public void setReturn(Items[] values) public Items setReturn(int idx, Items value) public Items getReturn(int idx) public int getReturnLength() [] However, the collection property within the JavaBeans remains of the type java.lang.List. protected List _return; This problem causes a conflict when the type is referenced in a JAX-WS operation or when the type is referenced within another JAXB element. It is not possible to customize the JAX-WS types or the JAXB elements to contain anything else but a java.lang.List collection type. For example, when you start from WSDL, you are not able to generate the following: [] public Items[] createAccount( [] Instead, wsimport always generates a List, like in this example: [] public List createAccount() []

Cause

The problem is caused by the JAXB specification design for indexed properties.

Resolving The Problem

As long as the schema and the WSDL are the same on both the client and server, the XML types can be mapped to different Java objects on each side.

It is therefore safe if your pre-existing JavaBeans or SEIs contain an indexed array type on the server through the use of wsgen, and a java.lang.List type on the client side through the use of wsimport.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Services (for example: SOAP or UDDI or WSGW or WSIF)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;6.1","Edition":"Base;Express;Feature Pack for Web Services;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21264009