I use CXF to generate the classes from WSDL but I don't know how to access the following field :
<s:complexType name="text-with-layout-type" mixed="true">
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded"/>
</s:sequence>
<s:attribute name="L" type="s:string"/>开发者_开发知识库;
</s:complexType>
The resulting class is :
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "text-with-layout-type", propOrder = {
"content"
})
public class TextWithLayoutType {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
@XmlAttribute(name = "L")
protected String l;
/**
* Gets the value of the content property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the content property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getContent().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Object }
* {@link String }
*
*
*/
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
/**
* Gets the value of the l property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getL() {
return l;
}
/**
* Sets the value of the l property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setL(String value) {
this.l = value;
}
}
I have an Object type if I try to get data using
.getTextWithLayout().get(0).getContent()
So how can read the data in the Object ?
Thanks
Your complex type "text-with-layout-type" contains an "any" tag. This means that JAXB needs to be able to handle any type of data, therefore it typed the data as Object.
With the code as is you will need to leverage getClass() or instanceof to figure out the type. If you have a particular way you want this property to look then let me know through an update to the question and we can discuss alternative mappings to enable that behaviour.
精彩评论