2010-10-27 5 views
0

я использую CXF для создания классов из WSDL, но я не знаю, как получить доступ следующее поле:CXF/JAXB сложные типы

<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> 

Полученный класс:

@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 имеют тип объекта, если я пытаюсь получить данные, используя

.getTextWithLayout().get(0).getContent() 

Итак, как читать данные в объекте?

Благодаря

+0

Предпочитаемый контент - HTML/XHTML. – BenoitD

ответ

0

Вашего сложный типа «текст-с-макет типа» содержит «любой» тег. Это означает, что JAXB должен иметь возможность обрабатывать данные любого типа, поэтому он набирал данные как Object.

С кодом как вам нужно будет использовать getClass() или instanceof для определения типа. Если у вас есть определенный способ, которым вы хотите, чтобы это свойство выглядело, дайте мне знать, обновив вопрос, и мы можем обсудить альтернативные сопоставления, чтобы включить это поведение.

+0

Спасибо за ваш ответ. Предполагаемый контент - это HTML/XHTML. – BenoitD

+0

Ответ на любой вопрос? – BenoitD