I have exposed a REST @POST method annotated to produce and consume XML and JSON. The method parameter and response class is a JAXB object. When called with wget and an XML request the correct XML responsed is returned. When I make a wget XML request and ask for a JSON response using the 'accept' http header I get the correct JSON response returned. My problem is when I use wget to make a JSON request I get an incorrect response. The JSON request is not being mapped to the method JAXB object parameter.
I am using Glassfish 3.0.1 and Netbeans 6.9.1 to generate and publish my war. I enabled logging using the LoggingFilter and can see my JSON request properly being recieved:
[#|2011-08-11T17:15:12.171-0700|INFO|glassfish3.0.1|com.sun.jersey.api.container.filter.LoggingFilter|_ThreadID=25;_ThreadName=Thread-1;|3 * Server in-bound request
3 > user-agent: Wget/1.12 (linux-gnu)
3 > accept: application/json
3 > host: localhost:38080
3 > connection: Keep-Alive
3 > content-type: application/json
3 > content-length: 242
I have added a custom JAXB Context Resolver(using natural builder) and see my logger messages when it is called with each JSON or XML request. My method is called with an empty JAXB object. The object when marshalled prints an empty XML payload:
ThreadName=Thread-1;|<?xml version="1.0" encoding="UTF-8" standalone="yes"?><
I haven't been able to find a reference example or tutorial that demonstrates this configuration.