我有一个带有 Web 方法的 jax-ws Web 服务:
@WebMethod
void SetCurrentDate(Date date)
在生成的 wsdl 参数中,日期的类型为 xs:dateTime,但我需要 xs:date。 我尝试了 XmlGregorianCalendar,但它映射到 xs:anySimpleType,我也尝试了 @XmlSchemaType,但不允许使用参数。 如何使用 xsd:date 而不是 xsd:dateTime 生成 wsdl?
最佳答案
看起来唯一的方法是使用注释 @RequestWrapper (对于 jax-ws-impl 和 apache cxf):
@WebMethod
@RequestWrapper(className = "....SetCurrentDateRequest")
void SetCurrentDate(Date date)
和请求包装器:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "setCurrentDateRequest", propOrder = {
"date"
})
public class SetCurrentDateRequest {
@XmlSchemaType(name="date")
protected Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
关于java - 生成xs :date instead of xs:dateTime for WebParam,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25518143/