I have seen posts that exist around this issue, but as I am new to jaxB I am having a bit of trouble I have a Root element set up and declaring my XML elements aswell. what am I doing wrong here?
I am getting this error
org.springframework.oxm.MarshallingFailureException: JAXB marshalling exception; nested exception is javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "au.test.Search.ws.model.SearchRequest" as an element because it is missing an @XmlRootElement annotation]
However this is my SearchRequest Class
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"searchControls",
"searchCriteria",
"searchFilters"
})
@XmlRootElement(name = "searchRequest")
public class SearchRequest {
@XmlElement(required = true)
protected SearchControls searchControls;
@XmlElement(required = true)
protected NameSearchCriteria searchCriteria;
@XmlElement
protected NameSearchFilters searchFilters;
public SearchControls getSearchControls() {
return searchControls;
}
public void setSearchControls(SearchControls value) {
this.searchControls = value;
}
public NameSearchCriteria getSearchCriteria() {
return searchCriteria;
}
public void setSearchCriteria(NameSearchCriteria value) {
this.searchCriteria = value;
}
public NameSearchFilters getSearchFilters() {
return searchFilters;
}
public void setSearchFilters(NameSearchFilters value) {
this.searchFilters = value;
}
}
How searchControls,criteria and Filters are set up
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NameSearchFilters", propOrder = {
})
public class NameSearchFilters {
protected FilterOperator operator;
public FilterOperator getOperator() {
return operator;
}
public void setOperator(FilterOperator value) {
this.operator = value;
}
}
How i am unmarshalling as requested using org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive
public SearchResponse performSearch(SearchRequest searchRequest) {
searchResponse = (SearchResponse) getWebServiceTemplate()
.marshalSendAndReceive(searchRequest);