Options:
- Check your
ObjectFactory
for a method like createProducts(...)
.
- Use
JAXBElement<Products>
.
- Customize your element with
<jaxb:class name="ProductsElement"/>
- you'll get a ProductsElement
with @XmlRootElement
.
- You can also use jaxb2-annotate-plugin to add
@XmlRootElement
to your existing Products
class.
Update
Here's a small example from one of my projects. There I have a consrtuct like
<element name="Capabilities" type="wps:WPSCapabilitiesType">
</element>
In the ObjectFactory
I have:
@XmlElementDecl(namespace = "http://www.opengis.net/wps/1.0.0", name = "Capabilities")
public JAXBElement<WPSCapabilitiesType> createCapabilities(WPSCapabilitiesType value) {
return new JAXBElement<WPSCapabilitiesType>(_Capabilities_QNAME, WPSCapabilitiesType.class, null, value);
}
So you should get a method like createProducts(...)
in your ObjectFactory
- not for the type but for the element. This was about the option 1.
Option 2 - it's not cryptic. You just create an instance of JAXBElement
providing a qualified name of the element, type of the value and the value:
new JAXBElement<WPSCapabilitiesType>(_Capabilities_QNAME, WPSCapabilitiesType.class, null, value);
In your case will be something like new JAXBElement<ProductsType>(new QName("products"), Products.class, null, products)
.
Finally, you say that you have no Products
class but only Product
class. Hm. This would mean you don't get a class generated for the anonymous complex type which is declared in the products
element. Which is not impossible, but I somehow doubt this is a case here. Check your classes if you have a class like ProductsType
or ProductsElement
.