سؤال

I have an JAX-RS API and I'm generating wadl for it.

<application ....
    ..
    <request>
        <representation mediaType="application/xml"/>
    </request>
..
</application>

But I want add element to representation to it.

<application ....
    ..
    <request>
        <representation mediaType="application/xml" element="prefix1:thebook"/>
    </request>
    ..
</application>

thebook should present in grammar.

My Service:

@Path("/update/book")
@POST
@Produces({MediaType.APPLICATION_JSON})
@ElementClass(request = Book.class)
@Consumes({MediaType.APPLICATION_XML})
String updateBook(Book book);

Book.java

@XmlRootElement(name = "inventoryBean")
public class Book {
    private Long name;
    private Long id;

    // getters and setters
} 
هل كانت مفيدة؟

المحلول

There has to be a namespace declared somewhere, either in @XmlRootElement itself or in a package-level annotation, please add it and you should see a proper link to a schema element;
In this case @XmlRootElement(name = "inventoryBean", namespace = "bean") should do the job.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top