CXF: how to exclude some properties when passing an object through SOAP?

I am using Apache CXF 2.4.2, and when I return an object from the database to the user, I want to exclude some properties (for example, password). How can I do this without creating a temporary class ? Is there any annotation for this?

+5
source share
2 answers

According to @ tomasz-nurkiewicz comment, I have to use annotation @XmlTransient. But as stated in the documentation

By default, if @XmlAccessorType is not in the class, and none of its superclasses are annotated with @XmlAccessorType, the following default value for the class is assumed:

@XmlAccessorType (XmlAccessType.PUBLIC_MEMBER)

XmlAccessType.PUBLIC_MEMBER , :

/ XML, XmlTransient. getter/setter, , , XML , JAXB.

@XmlTransient Tomasz Nurkiewicz. :

1) :

private String password;

@XmlTransient
public String getPassword() {
    return password;
}

2) @XmlAccessorType :

@XmlAccessorType(XmlAccessType.FIELD)
public User {

    @XmlTransient
    private String password;

}

: http://old.nabble.com/@XmlTransient-ignored-td7406659.html

+10

, JAXB XML. , @XmlTransient.

@XmlTransient
private String password;

, , , - CXF . , , SOAP...

+4

All Articles