jaxb序列化一些特殊节点的问题

Carlos_Tse 发布于 2015/06/22 00:05
阅读 1K+
收藏 0

这个是对象:


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "profile",
    "request",
    "filter"
})
@XmlRootElement(name = "SubmitXml")
public class SubmitXml {

    @XmlElement(name = "Profile")
    protected String profile;
    @XmlElement(name = "Request")
    protected SubmitXml.Request request;
    @XmlElement(name = "Filter")
    protected SubmitXml.Filter filter;

    public String getProfile() {
        return profile;
    }

    public void setProfile(String value) {
        this.profile = value;
    }

    public SubmitXml.Request getRequest() {
        return request;
    }

    public void setRequest(SubmitXml.Request value) {
        this.request = value;
    }

    public SubmitXml.Filter getFilter() {
        return filter;
    }

    public void setFilter(SubmitXml.Filter value) {
        this.filter = value;
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "any"
    })
    public static class Filter {

        @XmlAnyElement(lax = true)
        protected Object any;

        public Object getAny() {
            return any;
        }

        public void setAny(Object value) {
            this.any = value;
        }

    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "any"
    })
    public static class Request {

        @XmlAnyElement(lax = true)
        @XmlElementRefs({
            @XmlElementRef(name="AirAvailability", type=AirAvailability.class)
        })
        protected Object any;

        public Object getAny() {
            return any;
        }

        public void setAny(Object value) {
            this.any = value;
        }

    }
}




现在我要把这个对象用jaxb序列化为:


<?xml version=\"1.0\" encoding=\"utf-8\"?>
    <soap:Envelope>
        <soap:Body><SubmitXml>
            <Profile>DynGalileoProd_7OQ7</Profile>
            <Request>
                <AirAvailability_12 xmlns=\"\">
                    <AirAvailMods>
                        <GenAvail>
                            <NumSeats>2</NumSeats>
                            <Class>Y</Class>
                            <StartDt>20151201</StartDt>
                            <StartPt>TPE</StartPt>
                            <EndPt>HKG</EndPt>
                            <StartTm><![CDATA[ ]]></StartTm>
                        </GenAvail>
                    </AirAvailMods>
                </AirAvailability_12>
            </Request>
            <Filter><_ /></Filter>
        </SubmitXml>
    </soap:Body>
</soap:Envelope>



请问对象里的注解还需要怎么改才能实现出Filter这个节点的这种效果?

另外<![CDATA[ ]]>这种好像也不能直接序列化出来?老是把尖括号转码……


加载中
0
zigzagroad
zigzagroad
底下的是WebService输出的XML吧,不是普通的序列化输出的
zigzagroad
zigzagroad
用 CXF 简单方便
Carlos_Tse
Carlos_Tse
是啊,那么继续回答我的问题,如何输出我要的那种内容
0
sdlkfjlskd
sdlkfjlskd

你好,我今天也遇到这个问题问题了,查了一些百度资料,但是,还是解析 不了,这些 特殊的节点,想知道,你这边是怎么解决的了、?

返回顶部
顶部