• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSD Compliance with WebService and JAXB

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Patterns and Strategies for Building Document-Based Web Services (with JAX-RPC)
Strategy: Integration with JAXB
 
inr mohan
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic