문제

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