通过 SOAP 代理弹簧 不支持的媒体类型多部分/相关;类型= "application/xop+xml" ;边界



嗨,我正试图在春季通过@RestController实现一个直通SOAP代理。为此,我以以下方式映射了一个休息控制器:

@RestController
class MyProxy {
@PostMapping(value = "/**")  
public ResponseEntity<String> proxyPost(@RequestBody(required = false) String body, HttpServletRequest request) {}
}

常规的SOAP请求运行正常。当通过代理发送MTOM类型的SOAP请求时,问题就出现了。然后spring失败,内容类型无法识别。这里有一个例外:

Caused by: org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is javax.servlet.ServletException: Unsupported Content-Type [multipart/related; type="application/xop+xml"; boundary="uuid:dacf4733-80b4-41bc-b2e1-db69b6beadf6"; start="<root.message@cxf.apache.org>"; start-info="text/xml"], expected [multipart/form-data]
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:124)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:115)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88)
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:122)
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1205)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
... 60 common frames omitted
Caused by: javax.servlet.ServletException: Unsupported Content-Type [multipart/related; type="application/xop+xml"; boundary="uuid:dacf4733-80b4-41bc-b2e1-db69b6beadf6"; start="<root.message@cxf.apache.org>"; start-info="text/xml"], expected [multipart/form-data]
at org.eclipse.jetty.server.Request.getParts(Request.java:2407)
at javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:317)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:95)
... 66 common frames omitted

当接收到multipart/*请求时,Spring将其委托给已配置的Multipart处理程序。这在默认情况下是启用的,在这种情况下应该禁用。

spring.servlet.multipart.enabled=false

将以上内容添加到您的属性应该会禁用它并阻止解析,这样您就可以在控制器中处理它。

相关内容

  • 没有找到相关文章

最新更新