Hello,

I have a question regarding marshaling with a provider using jaxb annotations 
with JAX-RS..
I must admit it might not be a CXF question “pur sang”, but maybe you could 
give me a directions on my questions to investigate a possible solution.

Allow me to add a small example for simplicity based on HATEOAS links.

We have a request payload object defined as below which is used to 
create/update a person resource object (POST, PUT)
package somepackage;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


@XmlRootElement(name = “person")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "firstName", "lastName"})
public class Person {

    @NotNull
    private String firstName;

    @NotNull
    private String lastName;
}
Now to retrieve a person using for example /person/id we created a subclass of 
person to add HATEOAS links to the payload.

package anotherpackage;

import somepackage.AtomLink;
import somepackage.Person;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.*;
import java.util.Collections;


@XmlRootElement(name = "person")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { “links"})
public class PersonOut extends Person {

    @XmlElement(name = "links")
    Collections<AtomLink> links;
}
We hoped this way there would be able to express in the wadl that these HATEOAS 
links are only available during retrieval of data. Notice we named both 
xlmrootelements “person”.

The result of wadl though now seem to be as following:
<xs:element name="person" nillable="true" type="xs:anyType"/>

Yes, anytype.

We were under the assumption it is a good RESTful practice to align resource 
payload definition as much as possible over standard operations and if not 
possible use POST overloading or PATCH with it’s own definition. But this 
“links” object doesn’t really fit in a request payload, don’t you think.
And I would like to avoid using a header to define HATEOAS links.

So down to the questions:
Is there a way to be explicit in the wadl on which grammar to be used for 
Request or Response payload?
Is there a better way to define my person structure so that the wadl generates 
a more concrete grammar?
Is there some nifty jaxb trick that might help me out?
Is my problem absurd :) as it is considered “OK" to have grammar parts such as 
“links” showing for request payload definition due too using the same class for 
request and response and should I simply ignore it if a client passes links in 
a request?

Any tip is welcome.

Thanks in advance.

Met vriendelijke groeten - Cordialement - Best Regards - Mit freundlichen Grüßen

Peter De Winter | technical lead
 +32 2 421 46 93 |  +32 2 420 33 15 | 
 peter.de.win...@m-team.be <mailto:peter.de.win...@m-team.be>
 

 M-team asbl/vzw | Route de Lennik/Lenniksebaan 788 b1, 1070 Brussels, Belgium
 www.m-team.be <http://www.m-team.be/>





Met vriendelijke groet/Regards/Cordialement ,
Peter De Winter
Owner mijathi bvba 
Ond. Nr. 0833.250.487

Contact info
Lindenlaan 85
B-8400 Oostende 

Mobile: +32 (0)473 45 10 02
Phone: +32 (0)2808 08 65 Ext 988
email: peter.de.win...@mijathi.be
Site: mijathi.be <http://www.mijathi.be/>
Twitter: @mijathi <http://www.twitter.com/mijathi>

Instead of printing this e-mail, you could carve it into stone.

Reply via email to