[jboss-user] [JBossWS] - Issue using XmlMixed, XmlRefrences, XmlRefrence annotations

kyle.bober do-not-reply at jboss.com
Fri May 1 11:59:44 EDT 2009


I am having an issue with the XmlMixed, XmlRefrences, XmlRefrence annotations... Or so that is what I think is causing the issue.

I have a base class called CriteriaSO


  | @XmlRootElement(name="Criteria")
  | @XmlType(propOrder = {"sortType"})
  | @XmlSeeAlso({IdCriteriaSO.class})
  | public abstract class CriteriaSO {
  | 
  | protected SortType theSortType;
  | 
  | public CriteriaSO() {
  | super();
  | this.theSortType = KeywordAnalysisSortType.ASCENDING;
  | }
  | 
  | @XmlElement(name="SortType", required=true, nillable=false)
  | public SortType getSortType() {
  | return theSortType;
  | }
  | 
  | public void setSortType(SortType aSortType) {
  | theSortType = aSortType;
  | }
  | 
  | }
  | 

I have a two classes that extend the CriteriaSO class ::


  | @XmlRootElement(name="IdCriteria")
  | @XmlType(propOrder = {"Ids"})
  | public class IdCriteriaSO extends CriteriaSO {
  | 
  | private static final long serialVersionUID = 20090430001L;
  | 
  | private List<Integer> theIds;
  | 
  | public IdCriteriaSO() {
  | super(SortType.ASCENDING);
  | this.theKeywordAnalysisIds = new ArrayList<Integer>();
  | }
  | 
  | 
  | @XmlElementWrapper(name = "Ids", nillable=false, required=true)
  | @XmlElement(name = "Id", required = true, nillable = false)
  | public List<Integer> getIds() {
  | return theIds;
  | }
  | 
  | public void setIds(List<Integer> aIds) {
  | theIds = aIds;
  | }
  | }
  | 
  | 
  | @XmlRootElement(name="UserIdCriteria")
  | @XmlType(propOrder = {"userIds"})
  | public class UserIdCriteriaSO extends CriteriaSO {
  | 
  | private static final long serialVersionUID = 20090430001L;
  | 
  | private List<Integer> theUserIds;
  | 
  | public UserIdCriteriaSO() {
  | super(KeywordAnalysisSortType.ASCENDING);
  | this.theUserIds = new ArrayList<Integer>();
  | }
  | 
  | 
  | @XmlElementWrapper(name = "userIds", nillable=false, required=true)
  | @XmlElement(name = "userId", required = true, nillable = false)
  | public List<Integer> getUserIds() {
  | return theUserIds;
  | }
  | 
  | public void setUserIds(List<Integer> anUserIds) {
  | theUserIds = anUserIds;
  | }
  | }
  | 

I then created a List wrapper to contain the CriteriaSO object instances like so ::


  | @XmlRootElement(name="CriteriaList")
  | @XmlSeeAlso({IdCriteriaSO.class, UserIdCriteriaSO.class})
  | public class CriteriaListSO {
  | 
  | private static final long serialVersionUID = 20090424001L;
  | 
  | private List<CriteriaSO> theCriteria;
  | 
  | public CriteriaListSO() {
  | super();
  | this.theCriteria = new ArrayList<KeywordAnalysisCriteriaSO>();
  | }
  | 
  | 
  | @XmlMixed
  | @XmlElementRefs( {
  | @XmlElementRef(name = "IdCriteria", type = IdCriteriaSO.class),
  | @XmlElementRef(name = "UserIdCriteria", type = UserIdCriteriaSO.class) })
  | public List<CriteriaSO> getCriteria() {
  | return theCriteria;
  | }
  | 
  | public void setCriteria(List<sCriteriaSO> anCriteria) {
  | theCriteria = anCriteria;
  | }
  | }
  | 

I have a web service method that takes a CriteriaListSO object as a parameter.


  | @WebService(name="testService", serviceName="testService")
  | @SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
  | public class TestService {
  | 
  | 
  | @WebMethod(operationName = "echoCriteria")
  | @WebResult(name = "CriteriaList")
  | @RequestWrapper(localName="echoCriteriaRequest")
  | @ResponseWrapper(localName="echoCriteriaResponse")
  | public CriteriaListSO echoCriteria(@WebParam(name = "CriteriaList")CriteriaListSO criteriaListSO) throws RemoteException {
  | 
  | return criteriaListSO;
  | }
  | }
  | 

My issue is everytime I send a web service request to the echoCriteria web method with some CriteriaSO objects it doesn't set them in the CriteriaList object.
What I do see is one of the CriteriaList - ArrayList element's is being set to an object of type java.lang.String. And the contents of the String is the following
"\n" For each CriteriaSO object I add to the SOAP request it will add an additional \n to the string contents.

I am using JBoss 4.2.1

Any help or guidance would be appreciated. I have spent a few hours now on diffrent annotation configurations trying to figure this out.

-Kyle 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4228054#4228054

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4228054



More information about the jboss-user mailing list