users@jaxb.java.net

Issue using XmlMixed, XmlRefrences, XmlRefrence annotations

From: Kyle.Bober <kyle.bober_at_gmail.com>
Date: Mon, 4 May 2009 09:06:26 -0700 (PDT)

I am having an issue with @XmlMixed, @XmlRefrences, @XmlRefrence
annotations...

I have a two classes that extend a base CriteriaSO class. The classes are
IdCriteriaSO and UserIdCriteriaSO. I also have a List wrapper object
CriteriaListSO which contains an instance of List<CriteriaSO> objects. I
annotated the List<CriteriaSO> instance with the @XmlMixed, @XmlReferences
and @XmlReference annotations. I then created a simple web service that
takes as a web parameter an instance of CriteriaListSO. The generated WSDL
looks correct but when I make a request to the web service it doesn't
populate the List<CriteriaSO> properly.

My issue is every time 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
as an object of type java.lang.String. And the contents of the String are as
follows :: "\n" For each CriteriaSO object I add to the SOAP request it will
add an additional \n to the string contents of the String object added tro
the List.

FYI :: I am using JBoss 4.2.1

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

The CriteriaSO class ::

@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;
}
}


-Kyle
-- 
View this message in context: http://www.nabble.com/Issue-using-XmlMixed%2C-XmlRefrences%2C-XmlRefrence-annotations-tp23371452p23371452.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.