即使我使用 MediaType.APPLICATION_XML_VALUE,application/xml 仍不受支持的媒体类型
我通过 postman 运行以下curl 命令。
curl --location --request POST 'http://localhost:8080/cefcy/get_eD_XML' \
--header 'Content-Type: application/xml' \
--header 'Cookie: JSESSIONID=800845E7C67023C8B0B3C8CF7B6EB0E4' \
--data-raw '<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:epsos="urn:epsos-org:ep:medication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/></ClinicalDocument>'
在我的 java spring boot 项目中,我有以下内容:
@SessionScope
@RestController
public class eD extends Ctr {
private final static Logger LOG = LoggerFactory.getLogger(eD.class);
@RequestMapping(value = "/get_eD_XML", method=RequestMethod.POST,
produces = {MediaType.APPLICATION_JSON_VALUE},consumes={MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE})
protected String eD_XML(@RequestBody ObjectNode model,HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException, NoSuchAlgorithmException {
String eD = IOUtils.toString(request.getReader()); //trying to read the xml file
}
}
但是,在邮递员中,我得到以下响应:
{
"timestamp": "2022-03-02T14:12:30.070+00:00",
"status": 415,
"error": "Unsupported Media Type",
"message": "",
"path": "/cefcy/get_eD_XML"
}
I run the following curl command through postman
.
curl --location --request POST 'http://localhost:8080/cefcy/get_eD_XML' \
--header 'Content-Type: application/xml' \
--header 'Cookie: JSESSIONID=800845E7C67023C8B0B3C8CF7B6EB0E4' \
--data-raw '<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:epsos="urn:epsos-org:ep:medication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/></ClinicalDocument>'
In my java spring boot project I have the following:
@SessionScope
@RestController
public class eD extends Ctr {
private final static Logger LOG = LoggerFactory.getLogger(eD.class);
@RequestMapping(value = "/get_eD_XML", method=RequestMethod.POST,
produces = {MediaType.APPLICATION_JSON_VALUE},consumes={MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE})
protected String eD_XML(@RequestBody ObjectNode model,HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException, NoSuchAlgorithmException {
String eD = IOUtils.toString(request.getReader()); //trying to read the xml file
}
}
However, in postman I get the following response:
{
"timestamp": "2022-03-02T14:12:30.070+00:00",
"status": 415,
"error": "Unsupported Media Type",
"message": "",
"path": "/cefcy/get_eD_XML"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢 MI的博客
pom.xml
中需要以下依赖。Thanks to MI's blog the following dependency is needed in
pom.xml
.