4

(XSD から) 生成された JAXB クラスがあります。XML および JSON として返すことができますが、テキスト/html を Produces アノテーションに追加するとすぐに、次のようになります。

"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 です。

application/xml で渡される同じ API を呼び出すと、正常に動作します。

Employee e = client.path("employeeservice/employee/1/getEmployeeById")
    .accept(MediaType.APPLICATION_XML_TYPE).get(Employee.class);

text/html に対して別の方法で行う必要があることはありますか?

ありがとう

4

1 に答える 1