通过 SOAP 代理 spring 不支持的媒体类型 multipart/lated;类型=“应用程序/xop”xml”;边界

发布于 2025-01-12 02:07:41 字数 2662 浏览 0 评论 0原文

您好,我正在尝试在 Spring 中通过 @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="<[email protected]>"; 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="<[email protected]>"; 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

Hi I am trying to implement a pass through SOAP proxy via @RestController in spring. For this purpose I have mapped a rest controller in following way:

@RestController
class MyProxy {

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

The regular SOAP requests are going OK. The problem comes when a MTOM type of SOAP request is send via the proxy. Then spring failes with unrecognized content type. Here is the exception:

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="<[email protected]>"; 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="<[email protected]>"; 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么敢 2025-01-19 02:07:41

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

spring.servlet.multipart.enabled=false

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

When receiving a multipart/* request Spring delegates this to the configured Multipart handler. This is enabled by default and for this case should be disabled.

spring.servlet.multipart.enabled=false

Adding the above to your properties should disable it and prevent the parsing, so you can handle it in your controller.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文