Java 如何强制 Chrome Postman 返回 application/xml 而不是 application/octect-stream
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18453768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I force Chrome Postman to return application/xml instead of application/octect-stream
提问by spartikus
I am using google chrome plugin Postman for testing some restful web services. Some of my webservices have a produces annotation that has several types defined. Each time I run one of my services though, it seems postman's results are determined to always return in octect-stream form. Is there a way to force postman (or potentially my service) to return application/xml results? I would prefer not to change the annotation but will if thats my only choice.
我正在使用 google chrome 插件 Postman 来测试一些宁静的网络服务。我的一些网络服务有一个定义了多种类型的产品注释。但是,每次我运行我的一项服务时,邮递员的结果似乎总是以八位字节流形式返回。有没有办法强制邮递员(或可能是我的服务)返回 application/xml 结果?我宁愿不更改注释,但如果那是我唯一的选择,我会这样做。
My service definition -
我的服务定义——
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON,
"application/x-javascript", MediaType.APPLICATION_OCTET_STREAM } )
@Path( "/getCustomers/" )
public Response getCustomers
My postman call is just a GET call with no parameters on the header like this:
我的邮递员调用只是一个 GET 调用,标题上没有参数,如下所示:
http://myserver:8080/test/getCustomers
采纳答案by Suresh
Maybe your default response type is octect-stream
也许你的默认响应类型是octect-stream
Use the below http headers in POSTMAN
在 POSTMAN 中使用以下 http 标头
Accept: application/xml
接受:应用程序/xml
Do the server validations based on Accept headers.
根据 Accept 标头进行服务器验证。