I am just starting with Glassfish, and trying to set up a restful web service that can take a JSON string and parse it and return proper results. The web service looks like this:
@Path("/process")
public class SurveyResponseProcessor
{
@GET
@Produces("text/plain")
public String getReferrals()
{
return "Only POST operation are supported.";
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String postReferrals(ResponseDetails details)
{
return "done - " + details.getSurveyId();
}
}
The class that I expected to get the JSON:
@XmlRootElement
public class ResponseDetails
{
@XmlElement String providerId;
@XmlElement String surveyId;
@XmlElement String respondentId;
public String getProviderId()
{
return providerId;
}
public void setProviderId(String providerId)
{
this.providerId = providerId;
}
public String getSurveyId()
{
return surveyId;
}
public void setSurveyId(String surveyId)
{
this.surveyId = surveyId;
}
public String getRespondentId()
{
return respondentId;
}
public void setRespondentId(String respondentId)
{
this.respondentId = respondentId;
}
}
The POST body: {"providerId":"1","surveyId":"5","respondentId":"23"}
The error message:
<p><b>message</b>Internal Server Error</p><p><b>description</b>The server encountered an internal error that prevented it from fulfilling this request.</p>
Nothing shows up in any of the logs.
EDIT TO ADD: If I set it to consume text and change the arguments, this works just fine, telling me it is not a routing issue. Is it possible I haven't set JAXB or Jersey somewhere? I am using IntelliJ, if that matters.