Conflicting error messages for JAX-RS web service
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.
精彩评论