开发者

Internal Server error 500 when trying to present XML format as REST service response

开发者 https://www.devze.com 2023-02-07 18:24 出处:网络
This is regarding CXF REST service where in case of excepti开发者_开发问答on XML error tags will be the output.

This is regarding CXF REST service where in case of excepti开发者_开发问答on XML error tags will be the output.

@XmlRootElement(name = "error")
public class ErrorXMLBean {

    private String code;
    private String description;

    public RestServiceErrorXMLBean(){
        this.code = "Sample Error code";
        this.description = "Sample Error Desc";
    }

    // some getters/setters
}

Constructing the Response with below code.

Response response = Response.status(200).type(MediaType.TEXT_XML).entity(new ErrorXMLBean()).build();

My resource method has below tag to tell to CXF that It will produce XML as response

@Produces({"text/xml"})

I am getting Internal Server error 500. Can someone point me where I am wrong?

(using cxf-2.2.5.jar)


I am getting Internal Server error 500. can someone point me where I am wrong?

Look in the server logs. There is most likely a log event corresponding to the whatever caused the 500 error.

If you need more help, update your question with relevant details from the log event; e.g. the exception message and stack trace.

0

精彩评论

暂无评论...
验证码 换一张
取 消