3
我有一個生成的JAXB類(來自XSD)。我能夠返回XML和JSON,但只要我添加文本/ HTML我主要生產的註釋,我得到一個:沒有消息正文writer/JAX-RS/CXF
"No message body writer for response class Employee"
這裏是我的API:
@GET
@Path("/employee/{employeeId}/getEmployeeById")
@Produces({"application/xml", "application/json", "text/html"})
public Employee getEmployeeById(@PathParam("employeeId") String employeeId);
這裏是我的客戶呼叫(使用CXF客戶端):
WebClient client = WebClient.create(basePath);
client = client.path("employeeervice/employee/1/getEmployeeById").
accept(MediaType.TEXT_HTML_TYPE).type(MediaType.TEXT_HTML_TYPE);
客戶端的響應是500。
調用相同的API傳遞APPLI陽離子/ XML,它工作正常。
Employee e = client.path("employeeservice/employee/1/getEmployeeById")
.accept(MediaType.APPLICATION_XML_TYPE).get(Employee.class);
有什麼我需要做不同的文字/ HTML嗎?
感謝