调试泽西解组错误 - 错误的请求语法不正确 [英] Debugging Jersey Unmarshalling Error - Bad Request syntactically incorrect

查看:142
本文介绍了调试泽西解组错误 - 错误的请求语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jersey on Glassfish的帮助下构建了一个REST Webservice。



如果有搜索方式:



<$ p $现在我正在为自己的searchQuerys输入自定义输入源。 ({application / xml,application / json})
@Produces({code> @POST
@Path(search)
@Consumes application / xml,application / json})
public List< Index> search(SearchQuery searchqry){
...
}

SearchQuery:

  @XmlRootElement 
public class SearchQuery实现Serializable {
private static final long serialVersionUID = 1L;
$ b $ 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;
}

私人浮动拉特;
私人浮动lng;
}

我的电话:

  curl -v -X POST --data-binary< SearchQuery>< lat> 3.3< / lat>< lng> 5.4< / lng>< / SEARCHQUERY>中-HContent-Type:application / xml-HAccept:application / xmlhttp:// localhost:8080 / WebApplication1 / resources / index / search 

我尝试了一个restconsole来发送XML请求,但是我得到了同样的错误:


HTTP状态400 - 错误请求


类型状态
报告

错误的请求

> des cription 客户端发送的
请求语法不正确(Bad
Request)。

GlassFish Server Open Source版本
3.1.2

*关闭连接#0


我基本上缺少某些东西,或者有人可以给我一个提示如何调试应用服务器中的解组部分?



我遵循 http://xebee.xebia.in / 2011/12/30 /实例-的-宁静Web网页-机智h-xml-and-json-using-maven-jaxb-jersey-tomcat-and-curl /
和已测试的注释组合,但没有成功:($ / b $ b

解决方案

FINALLY 找到了我的问题的真正原因:
SearchQuery 映射到 searchQuery 在XML内



TESTClass 映射到XML实体

中的 tESTClass >

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

这篇关于调试泽西解组错误 - 错误的请求语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆