I have to pass the namespace for root element dynamically while marshalling using jaxb (JAXB 2.1.10 - JDK 6). i will be using the genrated xml to call different webservices which is qualified with different namespaces but same input xml. here is my sample jaxb annotated class .....guide me with your valuable inputs.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"taskName",
"taskType"
})
@XmlRootElement(name = "TaskRequest", namespace = "ABC")
public class TaskRequest {
@XmlElement(name = "TaskName", required = true, namespace = "XYZ")
protected String taskName;
@XmlElement(name = "TaskType", required = true, namespace = "XYZ")
protected String taskType;
public String getTaskName() {
return taskName;
}
public void setTaskName(String value) {
this.taskName = value;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String value) {
this.taskType = value;
}
}
namespace "ABC" need to pass dynamically with different value.
You can wrap the root object in an instance of JAXBElement
to provide alternate name and namespace information.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments