I am also facing the same problem. I have deployed Rest services using
JBoss5.1 and I am calling this rest service using a HTTP client.
Here is my client code.
HttpClient client = new HttpClient();
BufferedReader br = null;
PostMethod method = new
PostMethod("
http://localhost:8080/ResultService/rest/resultservice/toc");
method.addRequestHeader("Content-type", "application/json");
com.altair.hwe.publish.resultservice.schema.resultcommonschema.ObjectFactory
ob1
= new
com.altair.hwe.publish.resultservice.schema.resultcommonschema.ObjectFactory();
com.altair.hwe.publish.resultservice.schema.tocrequestschema.ObjectFactory
ob2
= new
com.altair.hwe.publish.resultservice.schema.tocrequestschema.ObjectFactory();
TOCRequest tocRequest = ob2.createTOCRequest();
// Assume that I have populated tocRequest with proper values.
JAXBContext jc =
JAXBContext.newInstance("com.altair.hwe.publish.resultservice.schema.tocrequestschema");
BaseJSONMarshaller b = new BaseJSONMarshaller(jc,
JSONConfiguration.mapped().build());
StringWriter w = new StringWriter();
b.marshallToJSON(tocRequest, w);
StringRequestEntity ent = new StringRequestEntity(w.toString());
method.setRequestEntity(ent);
try{
int returnCode = client.executeMethod(method);
System.out.println("ret: " + returnCode);
System.out.println(method.getResponseBodyAsString());
}
catch (Exception e) {
System.err.println(e);
} finally {
method.releaseConnection();
if(br != null) try { br.close(); } catch (Exception e) {}
}
Client is generating the correct format. but on server side, all the fields
are set to null.
Here is my POST method under the rest service:-
@POST
@Path("/toc")
@Consumes({"application/json","application/xml"})
@Produces({"application/json","application/xml"})
public TOCOfResult getTOCForResultSource(TOCRequest tocRequest) throws
ResultServiceException
{
try
{
DefaultUserCredentials userCredentials = null;
try
{
userCredentials = new DefaultUserCredentials("user", "");
}
catch ( Exception e )
{
e.printStackTrace();
}
return m_resultService.getTOC(tocRequest, userCredentials);
}
catch ( ResultServiceException e )
{
LOGGER.error("Internal error occured. Could not retrieve the
TOC", e);
throw e;
}
How I can register my JAXBContextResolver class in this case.
Any sort of help would be great.
Thanks in advance.
--
View this message in context: http://jersey.576304.n2.nabble.com/JAXBContextResolver-not-being-used-tp2730064p5107836.html
Sent from the Jersey mailing list archive at Nabble.com.