JAXB解组使用@XMLJavaTypeAdapters
问题描述:
我有用于获取实例三类JAXB解组使用@XMLJavaTypeAdapters
@XmlRootElement
public class GeofenceParameter{
private GeofenceCenterAddress geofenceCenterAddress;
private GeofenceCenterCoordinates geofenceCenterCoordinates;
}
public class GeofenceCenterAddress extends GeofenceParameter{
}
public class GeofenceCenterCoordinate extends GeofenceParameter{
}
我在GeofenceCenterAddress而GeofenceCentereCoordinate
Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{
}
Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{
}
由两种不同的XmlAdapter扩展类编组和解组在地理围栏Paramtere根据Soap请求发送,从GeofenceParamter中选择GeofenceCenterAddress或GeofenceCenterCoordinate类。
为此,我已经使用注释在package-info.java文件@XmlJavaTypeAdapters{(@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate)),@XmlJavaTypeAdapter(type=forGeofenceCenterAddress)}
,但在Web服务,它会给我,我已经在这个@XmlJavaTypeAdapter(type=forGeofenceCenterCoordinate) class not of @XmlJavaTypeAdapter(type=forGeofenceCenterAddress)
从GeofenceParamter的注解即指定拳头类的实例。
可以请帮助我在JAXB继承编组和解组中编写第二类实例。
在此先感谢
答
我不记得有使用@XmlJavaTypeAdapters
,但@XmlJavaTypeAdapter
标注的正常使用,简直是@XmlJavaTypeAdapter(forGeofenceCenterCoordinate.class)
。
仅当在包级别应用注释时,才需要type参数。