繁体   English   中英

使用@XMLJavaTypeAdapters进行JAXB解组

[英]JAXB Unmarshalling Using @XMLJavaTypeAdapters

我有三节课

@XmlRootElement
public class GeofenceParameter{

    private GeofenceCenterAddress geofenceCenterAddress;

    private GeofenceCenterCoordinates geofenceCenterCoordinates;
}

public class  GeofenceCenterAddress extends GeofenceParameter{

}

public class  GeofenceCenterCoordinate extends GeofenceParameter{

}

我已经制作了两个不同的XmlAdapter扩展类来对GeofenceCenterAddress和GeofenceCentereCoordinate中的Geofence Paramtere进行编组和解组

Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{
}

Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{
}

根据Soap请求发送,从GeofenceParamter获取相关的GeofenceCenterAddress或GeofenceCenterCoordinate类的实例。

为此我在package-info.java文件中使用了注释@XmlJavaTypeAdapters{(@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)),@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)}

但是在Web Service中,它会给我一个类的实例,我已经在注释中指定了一个,即@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate) class not of @XmlJavaTypeAdapter(type=forGeofenceCenterAddress)来自GeofenceParamter @XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate) class not of @XmlJavaTypeAdapter(type=forGeofenceCenterAddress)

你能不能在JAXB继承编组和解组中帮助我修改第二类的实例。

提前致谢

我不记得使用过@XmlJavaTypeAdapters ,但@XmlJavaTypeAdapter注释的正常用法只是@XmlJavaTypeAdapter(forGeofenceCenterCoordinate.class)

仅当在包级别应用注释时,才需要type参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM