【发布时间】:2015-02-12 17:26:49
【问题描述】:
我有这个实体类:
package com.model;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity
import com.model.BaseEntity;
import com.model.CustomerPK;
@Entity
@Table(name = "CUSTOMER")
public class Customer extends BaseEntity {
private static final long serialVersionUID = -625869124375935833L;
@EmbeddedId
private CustomerPK id;
@Column(name = "NAME", length = 70, nullable = true)
private String name;
@Column(name = "PHONE", length = 20, nullable = true)
private String phone;
@Column(name = "ADDRESS", length = 40, nullable = true)
private String address;
@Column(name = "CITY", length = 30, nullable = true)
private String city;
....
}
我有这个 Web 服务类:
package com.ws;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
import com.servico.WSService;
import com.model.Customer;
@WebService(serviceName = "customerWS")
public class CustomerWS {
@Inject
private WSService wss;
@WebMethod(operationName = "validateCustomer")
public List<String> validateCustomer(
@XmlElement(name = "customer", required = true) Customer customer) {
return wss.validateCustomer(customer);
}
}
当我尝试启动服务时,会显示此错误:
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://--.--.-----.-----.-----.----.----.--/}baseEntity". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at ------.BaseEntity
at ------.model.BaseEntity
this problem is related to the following location:
at ------.model.BaseEntity
我无法编辑 BaseEntity 类。有没有办法在不注释 BaseEntity 类的情况下创建 Web 服务?
编辑:
我不想使用 MOXy 框架,因为我已经有在线的 Web 服务。我的问题是如果我只能编组 Customer 类,而没有她的 BaseEntity 类。 附加信息:我的客户和我的 Web 服务可以访问 Customer 类所在的同一个包。
【问题讨论】:
-
您是如何生成 JAX-WS 类的?
-
哪个 JAX-WS 类?我手动生成的 CustomerWS 类。
标签: java web-services ejb entity jax-ws