I am building a REST Webservice with the help of Jersey on Glassfish. Now I am struggeling with my custom input Source for my searchQuerys.
If have a search Method:
@POST
@Path("search")
@Consumes({"application/xml", "application/json"})
@Produces({"application/xml", "application/json"})
public List<Index> search(SearchQuery searchqry) {
...
}
And the Class SearchQuery:
@XmlRootElement
public class SearchQuery implements Serializable {
private static final long serialVersionUID = 1L;
public SearchQuery() {
}
public SearchQuery(float lat, float lng) {
this.lat = lat;
this.lng = lng;
}
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLng() {
return lng;
}
public void setLng(float lng) {
this.lng = lng;
}
private float lat;
private float lng;
}
And my call:
curl -v -X POST --data-binary "<SearchQuery><lat>3.3</lat><lng>5.4</lng></SearchQuery>" -H "Content-Type: application/xml" -H "Accept: application/xml" http://localhost:8080/WebApplication1/resources/index/search
I tried a restconsole to send the XML request, but I get the same error:
HTTP Status 400 - Bad Request
type Status report
messageBad Request
des criptionThe request sent by the client was syntactically incorrect (Bad Request).
GlassFish Server Open Source Edition 3.1.2
* Closing connection #0
I am missing something essentially or can somebody give me a hint how to debug the unmarshalling part inside the Application Server?
I followed the guide at http://xebee.xebia.in/2011/12/30/example-of-restful-webservice-with-xml-and-json-using-maven-jaxb-jersey-tomcat-and-curl/ and tested varius combination of Annotations but no sucess :(
FINALLY found the real reason for my problem: SearchQuery is mapped to "searchQuery" inside XML
TESTClass is mapped to tESTClass inside the XML Entity