使用SOAPHandler时MTOM不起作用 [英] MTOM not working when using SOAPHandler

查看:118
本文介绍了使用SOAPHandler时MTOM不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Mtom传输文件,并且在我使用SoapHandler验证客户端签名之前,它的运行效果非常好. SoapHandler保留所有消息并将其更改为base64编码.因此,当我尝试获取大文件时,Jvm会抛出堆大小异常.你们知道解决这个问题的任何方法吗?

I try to transfer file with Mtom and it is working pretty good until i use SoapHandler to verify client signature. SoapHandler keeps all message and changes it to base64 encoded. So when i try to get huge file, Jvm throws heap size exception. Do you guys know any ways to solve this problem?

推荐答案

Java JRE带有JAX-WS Provider.该提供程序具有我认为的错误.如果添加了SoapHandler(通过直接获取HandlerChain或使用HandlerResolver),则会分解使用MTOM正确创建的消息,并将附件内联在SOAP消息中.如果附件很大,可能会导致性能很差或出现内存不足错误.

The Java JRE comes with a JAX-WS Provider. This provider has what I would consider a bug. If a SoapHandler is added, either by directly getting the HandlerChain or by using a HandlerResolver, the message, which was correctly created using MTOM, is deconstructed and the attachment(s) are placed inline within the SOAP message. If the attachments are large, this can lead to very poor performance or out of memory errors.

我发现的唯一解决方案是使用另一个JAX-WS提供程序.从测试来看,Axis2似乎运行完美(尽管它具有大量的依赖关系).只需将另一个提供程序放在类路径上,即可使用它. Java在META-INF/services中查找名为javax.xml.ws.spi.Provider的文件.如果找到此文件,它将使用指定的提供程序.主Axis2 jar将包含此文件,以确保使用了Axis2提供程序.其他提供者也可以解决此问题.

The only solution I have found is to use another JAX-WS provider. From testing, Axis2 seems to work perfectly (although it has a huge number of dependencies). Simply placing another provider on the classpath will cause it to be used. Java looks for a file in META-INF/services named javax.xml.ws.spi.Provider. If this file is found, it will use the Provider specified. The main Axis2 jar will include this file to ensure the Axis2 provider is used. Other Providers may also solve this problem.

由于此自动的提供程序检测,您可能会发现您的应用程序存在或不存在此问题,具体取决于它在何处运行.例如,如果将应用程序部署到IBM WebSphere,则该应用程序已经覆盖了默认的Provider,并且不会出现此问题.可能其他应用服务器也已覆盖默认提供程序.如果可以获取副本,IBM还提供了一个非常好的jar包com.ibm.jaxws.thinclient_7.0.0.jar,其中装有Axis2.它只能用于独立的应用程序(不在WebSphere中运行的应用程序),但是非常方便,可以解决此问题.

Because of this automatic Provider detection, you may find your application does or does not have this problem depending on where it is running. For example, if you deploy an application to IBM WebSphere it already has overridden the default Provider and you will not have this issue. Likely other Application Servers also have overridden the default Provider. If you can get ahold of a copy, IBM also provides a very nice jar, com.ibm.jaxws.thinclient_7.0.0.jar, that has Axis2 packaged in it. This can only be used for standalone applications (those not running in WebSphere), but it is very convenient and resolves this issue.

这篇关于使用SOAPHandler时MTOM不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆