【发布时间】:2014-09-03 13:36:39
【问题描述】:
我用 jax-rs 创建了 rest api。我想用 xml 处理 PUT 请求。我创建方法:
@PUT
@Consumes(MediaType.APPLICATION_XML)
@Path("/createOrder")
@Override
public void createOrder(String content)
{
///some code
}
通过 PUT 发送数据
Address: http://some_address/web-services/rest/createOrder
Encoding: UTF-8
Http-Method: PUT
Content-Type: aplication/xml
Headers: {Accept=[*/*], accept-encoding=[gzip,deflate,sdch], accept-language=[en-US,en;q=0.8], cache-control=[no-cache], connection=[keep-alive], Content-Length=[117], content-type=[aplication/xml], cookie=[JSESSIONID=CE083800388A447F94FBB1E75E994EA9], host=[localhost:8080], origin=[chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm], user-agent=[Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36]}
Payload: <note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
并得到这个错误:
WARNING: No operation matching request path "/web-services/rest/createOrder" is found, Relative Path: /createOrder, HTTP Method: PUT, ContentType: aplication/xml, Accept: */*,. Please enable FINE/TRACE log level for more details.
所有 GET 方法都有效,但我无法处理 PUT。怎么做?
【问题讨论】:
-
application/xml 有两个 p(在您的 Content-Type 标头中)