@XmlRootElement覆盖Web服务中的@WebResult

时间:2012-11-28 11:39:26

标签: xml java-ee entity jax-ws websphere-8

我有一个用@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")名称会使用<return></return>名称覆盖soap响应@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);
}

为什么会发生这种情况?

0 个答案:

没有答案