2012-06-27 4 views
0

제 휴식 서비스에서 pojos와 통신하기 위해 this 4.3 장을 사용했습니다. 지금 나는 게시하고 pojo를 얻을 수 있습니다. 그것은 잘 작동합니다. 바로 POJO를 포장으로뿐만 아니라저지 - Pojo 의사 소통 작업, getEtntity doesnt

res = Response.created(UriBuilder.fromUri(uriInfo.getAbsolutePath() + "/" + object.getObjectId()).build()).entity(new JAXBElement<ObjectPOJO>(new QName("objectpojo"), ObjectPOJO.class, object)).build(); 

내가 그것을 시도 :이 같은 개체를 래핑

서버 측에
27.06.2012 10:44:44 com.sun.jersey.api.client.ClientResponse getEntity 
SCHWERWIEGEND: A message body reader for Java class javax.xml.bind.JAXBElement, and Java type class javax.xml.bind.JAXBElement, and MIME media type application/xml was not found 
27.06.2012 10:44:44 com.sun.jersey.api.client.ClientResponse getEntity 
SCHWERWIEGEND: The registered message body readers compatible with the MIME media type are: 
application/xml -> 

: 내 응답의 실체를 얻으려고하지만 나는이 예외가 JAXBElement없이.

GenericType<JAXBElement<ObjectPOJO>> objectType = new GenericType<JAXBElement<ObjectPOJO>>() {}; 
objectType = (GenericType<JAXBElement<ObjectPOJO>>) res.getEntity(JAXBElement.class).getValue(); 

object = res.getEntity(ObjectPOJO.class); 

등 :

는 클라이언트 측에 나는 다른 접근을 시도했다. 누구든지 올바른 접근법을 아는가? 나가 말한대로, 얻고와 포스트 커뮤니케이션은 잘 작동한다.

답변

2

그것은해야한다 :

ObjectPOJO object = res.getEntity(new GenericType<JAXBElement<ObjectPOJO>>() {}).getValue(); 
+0

감사 메이트, u는 나에게 과거에 많은 도움이되었습니다. 한 실수 : 그것은 getValue()이어야합니다 –

+0

고마워, 나는 대답을 업데이 트했습니다. –