开发者

Conflicting error messages for JAX-RS web service

开发者 https://www.devze.com 2023-02-28 07:16 出处:网络
I am developing a RESTful web service using JAX-RS. I am using JAXB to map my classes to the XML that is sent as a request parameter in POST and PUT requests.

I am developing a RESTful web service using JAX-RS. I am using JAXB to map my classes to the XML that is sent as a request parameter in POST and PUT requests.

To test the functionality of my web service, I wrote a simple client that creates a HttpConnection object and sends the necessary XML to the POST URI. However, this is where I am getting conflicting error messages.

If I use my client, I get an Internal Server Error in response, even though it is not one of the errors I am returning explicitly. Moreover, Tomcat gives no stack trace when I try any kind of request (GET or POST) to explain the cause of the error.

However, if I use curl to send a POST request to the same URI with the same request data, I get an Unsupported media type error (HTTP 415). The media type in both my request as well as the web service handler m开发者_Go百科ethod is "text/xml".

Can anybody guide me as to how I can troubleshoot this problem? Thanks in advance.


Troubleshooting REST: I suggest to use Fiddler to inspect your traffic. So you can see the exact requests and responses.

Unsupported media type error (HTTP 415): When passing xml, you should use application/xml or text/xml media types.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号