Reputation: 111
I have Root object ProcessConsignmentRequest
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ProcessConsignmentRequest", propOrder = {
"request"
})
@XmlRootElement(name = "ProcessConsignmentRequest", namespace ="http://tempuri.org/")
public class ProcessConsignmentRequest {{
@XmlElementRef(name = "Request", namespace = "http://tempuri.org/", type = JAXBElement.class, required = false)
protected JAXBElement<ConsignmentRequest> request;
When I Marshal this object. The object'tag of ConsignmentRequest default set to "ConsignmentRequest" but I want it exactly is "Request". Some suggestion for me. Thanks . This xml result:
Upvotes: 0
Views: 554
Reputation: 11
Had the same issue. As I discovered, JAXBElement doesn't look to the name in your @XmlElementRef annotation. It looks to the QName that you pass to it's constructor. In my case it was
new JAXBElement<>(someService.getServiceName(), Some.class, someInstance)
I changed that code to the line below and got what I wanted:
new JAXBElement<>(new QName("MyElementName"), Some.class, someInstance)
Upvotes: 1