我用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。怎么做?
答案 0 :(得分:0)
请求标头&#39;内容类型&#39;是错的。它表示p
lication / xml而不是pp
lication / xml。
此外,我从未见过Payload
作为标题。 xml内容应该在请求的正文部分。