File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes XSD Compliance with WebService and JAXB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "XSD Compliance with WebService and JAXB" Watch "XSD Compliance with WebService and JAXB" New topic
Author

XSD Compliance with WebService and JAXB

inr mohan
Ranch Hand

Joined: May 11, 2005
Posts: 61
Hi All,

I have an XSD which is refered in WSDL, I use that WSDL to create the WebService. The Array of ComplexTypes in the XSD, is generated as Java Arrays [] in generated classes.

But in JAXB, when I use the same XSD for class file generation, which is the first step in JAXB, the Array of ComplexTypes in the XSD, is generated as Collection (List)

Please let me know, how to use the same XSD for both. the reason is I will get an XML document, which will be unmarshalled and used to send them in webservice.

Please help.

Thanks in Advance,
Ayyanar...
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Try customizing the JAXB bindings by setting collectionType="indexed".

Also note the all java.util.List collections have two toArray Methods.

Alternately choose a web service framework that will let you use JAXB for (un)marshalling.
inr mohan
Ranch Hand

Joined: May 11, 2005
Posts: 61
We plan to use the JAX-RPC for webservice, Please give your suggestion on this.

Can we use JAXB in JAX-RPC webservice
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Patterns and Strategies for Building Document-Based Web Services (with JAX-RPC)
Strategy: Integration with JAXB
inr mohan
Ranch Hand

Joined: May 11, 2005
Posts: 61
Hi,

I set the collectionType="indexed", but the JAXB is not using Array [], still it generate the Collection(List.

The Cutomization done is ass follows in a .xjb file.

<jxb:bindings schemaLocation="pa-transaction-1.0.xsd" node="/xs:schema">
<jxb:globalBindings collectionType="indexed">

</jxb:globalBindings>
<jxb:schemaBindings>
<jxb ackage name="com...."/>
</jxb:schemaBindings>
</jxb:bindings>
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Sorry. Apparently there seems to be conflicting information floating around about what indexed actually means. So I had to go back to the specification JSR-000222 Java(TM) Architecture for XML Binding (JAXB)

Apparently "indexed" implements the "indexed property design pattern for a multi-valued property from the JavaBean specification" on the containing type.

(where Id is replaced with the name of the multi-valued property and Type is data type of your single valued property). So you would have to use getId() on the containing type to obtain an array of your "collection". There should be a containing type as every XML document only has a single root element.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSD Compliance with WebService and JAXB