春天 + SOAPExceptionImpl:保存多部分消息时出错
我有一个带有 jsp 页面的 Spring Web 应用程序,它调用不同的 Web 服务并在 jsp 页面中显示结果。 spring web 应用程序附加了用户名/登录名 spring security。
我正在添加对处理安全性的 Web 服务的调用。对于 WebServiceGateway,我添加了一个安全拦截器。 (见下文)
<bean id="securityInterceptor"
class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="securementActions" value="UsernameToken Timestamp" />
<property name="securementUsername" value="Bert" />
<property name="securementPassword" value="Ernie" />
<property name="timestampPrecisionInMilliseconds" value="true" />
</bean>
当我将 wss4j 添加到我的 pom 文件中时,我现在在 Web 服务端收到以下错误:
[28-13:46:26]DEBUG: org.springframework.web.servlet.FrameworkServlet.processRequest(): Could not complete request [http-8080-2]
org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:163)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:172)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1124)
at org.springframework.ws.soap.saaj.Saaj13Implementation.writeTo(Saaj13Implementation.java:268)
at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:159)
... 20 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to get header stream in saveChanges:
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1101)
... 22 more
Caused by: java.io.IOException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:295)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:306)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:302)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getHeaderBytes(MessageImpl.java:945)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1096)
... 22 more
I have a spring web application with jsp pages that calls different web services and displays the results in a jsp page. The spring web application has username/login spring security attached to it.
I am adding a call to a web service that handles security. For the WebServiceGateway, I added a security interceptor. (See below)
<bean id="securityInterceptor"
class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="securementActions" value="UsernameToken Timestamp" />
<property name="securementUsername" value="Bert" />
<property name="securementPassword" value="Ernie" />
<property name="timestampPrecisionInMilliseconds" value="true" />
</bean>
When I added the wss4j into my pom file, I now get the following error on the web service side:
[28-13:46:26]DEBUG: org.springframework.web.servlet.FrameworkServlet.processRequest(): Could not complete request [http-8080-2]
org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:163)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:172)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1124)
at org.springframework.ws.soap.saaj.Saaj13Implementation.writeTo(Saaj13Implementation.java:268)
at org.springframework.ws.soap.saaj.SaajSoapMessage.writeTo(SaajSoapMessage.java:159)
... 20 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to get header stream in saveChanges:
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1101)
... 22 more
Caused by: java.io.IOException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:295)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(EnvelopeImpl.java:306)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:302)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getHeaderBytes(MessageImpl.java:945)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:1096)
... 22 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能有点太晚了,但您似乎正在遭受所描述的 这里。 Java 6 中的 Xerces 实现显然与 Spring Web Services 不兼容。
他们的解决方案是开始弄乱认可的库,但这是我想避免的事情。我还没有找到一个不涉及修改JVM安装的好的解决方案。
Arjen Poutsma 似乎有另一个解决方案。他删除了所有 Xerces 和 Xalan 依赖项。然后就可以了。除非您在 Web 服务应用程序的其他部分需要 Xerces/Xalan 的功能,否则您可以尝试此操作。相关票证为 SWS-175。
It may be a bit too late, but you seem to be suffering from what is described here. The Xerces implementation in Java 6 is apparently not compatible with Spring Web Services.
Their solution is to start messing with endorsed libs, but this is something I would like to avoid. I have not yet found a good solution that does not involve modifying the JVM installation.
Arjen Poutsma seems to have another solution. He removed all the Xerces and Xalan dependencies. Then it works. Unless you need features from Xerces/Xalan in some other part of you web service application you could try this. The relevant ticket is SWS-175.
我遇到了完全相同的问题,其中在 tomcat 上测试时,soap web 服务的 spring 客户端工作得非常好,在 jboss 上测试时给出以下异常:
org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream:保存多部分消息时出错;嵌套异常是 com.sun.xml.messaging.saaj.SOAPExceptionImpl: 保存多部分消息时出错
根据上面给出的答案,我按如下方式更改了 jboss-deployment-struct 文件,并在排除中添加了激活、xerces 和 xalan :
这解决了 jboss 上的问题。
I got exact same issue wherein spring client of soap web service was working absolutely fine when tested on tomcat and was giving following exception when tested on jboss:
org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not write message to OutputStream: Error during saving a multipart message; nested exception is com.sun.xml.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
With the answer given above, I changed jboss-deployment-structure file as follows and added activation, xerces and xalan in exclusion:
This resolved the issue on jboss.
我今天遇到了同样的问题。尝试了所有可能的方法,最终删除了Xalan.jar和xerces.jar。事实上,不仅是 Xalan 和 Xerces JARS,还有 XercesImpl.jar 和 Xalan JARS 的所有版本。
现在它工作完全正常。
I faced the same problem today. Tried all the possible ways and finally removed Xalan.jar and xerces.jar. In fact not only Xalan and Xerces JARS but XercesImpl.jar and all versions of Xalan JARS as well.
Now it's working completely fine.