Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is JAXB, and to get your example working you need to supply root element and namespace information:</p> <p><strong>Root Element</strong></p> <p>When you marshal an object with JAXB it requires information about the root element. One way to do this is to annotate your <code>Download</code> class with <code>@XmlRootElement</code></p> <pre><code>@XmlRootElement(name="Download") public class Download </code></pre> <p>If you cannot do that you will need to wrap your instance of <code>Download</code> in a <code>JAXBElement</code>:</p> <pre><code>Download download = new Download(); QName qname = new QName("HTTP://xyz.abc.Com//Vendor/DownloadWSE.xsd"; JAXBElement&lt;Download&gt; jaxbElement = new JAXBElement(qname, "Download"), Download.class, download); </code></pre> <p><strong>Namespace Qualification</strong></p> <p>Also to get the namespace qualification you are after you can use the package level <code>@XmlSchema</code> annotation:</p> <pre><code>@XmlSchema( namespace="HTTP://xyz.abc.Com//Vendor/DownloadWSE.xsd", elementFormDefault=XmlNsForm.QUALIFIED) package your.model.package.containing.download; import javax.xml.bind.annotation.*; </code></pre> <p><strong>Demo</strong></p> <pre><code>import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Marshaller; import javax.xml.namespace.QName; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Download.class); Download download = new Download(); QName qname = new QName("HTTP://xyz.abc.Com//Vendor/DownloadWSE.xsd"; JAXBElement&lt;Download&gt; jaxbElement = new JAXBElement(qname, "Download"), Download.class, download); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(jaxbElement, System.out); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload