1

我有一个用 @XmlRootElement 注释的实体

@XmlRootElement(name = "Customer")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(propOrder = { "id", "name", "surname", "type" })
@Entity
public class Customer extends AbstractEntity {

@Id
private long id;
private String name;
private String surname;
private Type type;

public ResponseDTO() {
    this("Default", "Default");
}

public ResponseDTO(String name, String surname) {
    this.name = name;
    this.surname = surname;
    this.type = new Type("120");
}

@XmlElement(name = "id")
public Long getId() {
    return this.id;
}

public void setId(Long id) {
    this.id = id;
}

@XmlElement(name = "name")
public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

@XmlElement(name = "surname")
public String getSurname() {
    return surname;
}

public void setSurname(String surname) {
    this.surname = surname;
}

@XmlElement(name = "type")
public Type getType() {
    return type;
}

public void setType(Type type) {
    this.type = type;
}
}

在 Web 服务响应中使用实体时,名称会覆盖带有名称@XmlRootElement(name="Customer")的 soap 响应的默认根元素。当我添加它时,它仍然会用名称覆盖它。<return></return>@XmlRootElement(name="Customer")@WebResult(name="Cust")

@Remote
@WebService
public interface CustomerWS{

  @WebMethod(operationName="getCustomerByNumber")
  @WebResult(name = "Cust")
  public Customer getCustomerByNumber(@WebParam(name="customerNumber") Long customerNumber);
}

为什么会发生这种情况?

4

0 回答 0