oh. is there any documentation or example out there? Regards
Karuna Pydipati StubHub/eBay - Platform & Services Phone: (415)222-8752 Email: [email protected] <mailto:[email protected]> ________________________________ From: Sergey Beryozkin [mailto:[email protected]] Sent: Thursday, October 29, 2009 10:04 AM To: Pydipati, Karuna; [email protected] Subject: Re: Messagebodywriter issue for RESTful web services Hi, thanks for the confirmation.... You can also explicitly register a JAXB provider and instruct it to 'marshalAsJaxbElement' and then you can avoid setting this annotation cheers, Sergey ----- Original Message ----- From: Pydipati, Karuna <mailto:[email protected]> To: [email protected] ; Sergey Beryozkin <mailto:[email protected]> Sent: Thursday, October 29, 2009 4:59 PM Subject: RE: Messagebodywriter issue for RESTful web services I found the issue. I forgot to add "@XmlRootElement(name = "UserContactResponse")" above the class @XmlRootElement(name = "UserContactResponse") public class UserContactResponse { Regards Karuna Pydipati StubHub/eBay - Platform & Services Phone: (415)222-8752 Email: [email protected] <mailto:[email protected]> ________________________________ From: Pydipati, Karuna Sent: Wednesday, October 28, 2009 9:40 PM To: [email protected]; Sergey Beryozkin Subject: Messagebodywriter issue for RESTful web services I am getting the following error and I tried all options. I remember that similar code was working few months back without any custom Serializers 1) Error in log ========= ---------------------------- ID: 1 Address: /xxxapi/xxxRestService/patientmatch/3/contacts/1 Encoding: Content-Type: Headers: {connection=[keep-alive], host=[localhost:8080], user-agent=[Java/1.5.0_14], Content-Type=[null], Accept=[text/html, Payload: -------------------------------------- Oct 28, 2009 9:25:04 PM org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor writeResponseErrorMessage WARNING: .No message body writer found for response class : UserContactResponse. Oct 28, 2009 9:25:04 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose INFO: Outbound Message --------------------------- ID: 1 Encoding: Content-Type: text/xml Headers: {Date=[Thu, 29 Oct 2009 04:25:04 GMT]} Payload: .No message body writer found for response class : UserContactResponse. -------------------------------------- 2) Interface class package com.xxx.ws.rest; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.PathSegment; import com.xxx.ws.soap.PatientMatchResp; import com.xxx.ws.soap.UserContactResponse; @Path("/patientmatch/") @Consumes( { "application/xml" }) @Produces( { "application/xml" }) public interface XXXService { @GET @Path("/{userid}/contacts/{contactId}") public UserContactResponse getContact(@PathParam("userid") String userGuid, @PathParam("contactId") String contactId); } 3) Impl class @WebService(endpointInterface = "com.xxx.ws.rest.XXXService", serviceName = "/") public class XXXServiceImpl implements XXXService { private static Logger log = Logger.getLogger(XXXServiceImpl .class); public UserContactResponse getContact(String userid, String contactId) { // TODO Auto-generated method stub UserContactResponse ucr = new UserContactResponse(); UserContact uc = new UserContact(); uc.setCity("fremont"); uc.setActive(true); uc.setAptNumber("11"); uc.setChkPmtToCo(true); uc.setCompany("fff"); ucr.setUserContact(uc); return ucr; } } 4) UserContactResponse (this contains UserContact which has few String and Long fieds. Thats all. No arrays or List) import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "UserContactResponse", propOrder = { "userContact" }) public class UserContactResponse { @XmlElement(name = "UserContact", required = true) UserContact userContact; public UserContact getUserContact() { return userContact; } public void setUserContact(UserContact userContact) { this.userContact = userContact; } } 4) cxf-bean.xml file <jaxws:endpoint id="XXXService" implementor="com.xxx.ws.soap.XXXServiceImpl" address="/XXXService"/> <bean id="xxxRestService" class="com.xxx.ws.rest.XXXServiceImpl" /> <jaxrs:server id="restServices" address="/xxxRestService"> <jaxrs:serviceBeans> <ref bean="xxxRestService" /> </jaxrs:serviceBeans> </jaxrs:server> Regards Karuna Pydipati StubHub/eBay - Platform & Services Phone: (415)222-8752 Email: [email protected] <mailto:[email protected]>
