简体   繁体   中英

Getting 400 response when i try for POST request

I am using CXF and my bean is as follows

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Test {

    @XmlElement(name="id")
    protected Long Id;

    @XmlElement(name = "students")
    protected Set<String> students;

    //Getters and setters
}

When i try to use the below request it works

    @POST
    @Path("/test")
    public String getCounts(JAXBElement<Test> jaxFilters) {
        Test filter = jaxFilter.getValue();
        //Some logic
    }

But when i use the below request i am getting 400 error

@POST
@Path("/test")
public String getCounts(JAXBElement<List<Test>> jaxFilters) {
    List<Test> filter = jaxFilter.getValue();
    //Some logic
}

Can someone help me how to write the Post request to accept for the collection of jaxb beans as body in the post request. Thanks in advance.

Found the solution. Actually in POJO class instead of @XmlRootElement annotated with @XMLType and removed wrapping of JAXBElement in Rest call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM