Spring Boot,带有MTOM的Apache CXF 3.2.5发送空附件 [英] Spring Boot, Apache CXF 3.2.5 with MTOM sends empty attachment
问题描述
我在使用Apache CXF时遇到了一个奇怪的问题,大型(375MB)MTOM附件为空. 在Eclipse中本地运行它可以产生预期的结果,但是将其部署到我们的服务器上只会得到一个空的附件.
I'm having a weird issue with Apache CXF and large (375MB) MTOM attachments are empty. Running it locally in Eclipse produces the desired results, but deploying it to our server just gives an empty attachment.
服务器是用.NET编写的,不支持分块.启用分块功能后,客户端可以正常工作,但是当我禁用分箱功能时,它将失败.
The server is written in .NET and doesn't support chunking. With Chunking enabled the client works, but when i disable cunking it fails.
可悲的是,我无法在服务器上进行调试,因此我仅限于跟踪日志记录.
Sadly i'm unable to debug on the server, so i'm restricted to trace logging.
我已经尝试了所有可以谷歌使用的技巧.
I've tried every trick i've been able to google.
- Disable schema validation (CXF-4551) (CXF-7758)
- Manually copying the file to java.io.tmpdir before sending, to ensure it can be read.
- Custom DataSource
- Disable WS-Security
- Disable logging interceptor
似乎没有什么改变. 每次运行我都会得到类似以下的内容
Nothing seems to make a difference. Every run i just get something like the following
</soap:Body></soap:Envelope>
--uuid:40ef745b-ac3c-4013-bbe7-a9cc28880423
Content-Type: application/xml
Content-Transfer-Encoding: binary
Content-ID: <7611ca0a-22f8-4637-b4f7-a5dfe7f20b81-3@www.somewhere.dk>
Content-Disposition: attachment;name="32_2018-03-28_output.xml"
--uuid:40ef745b-ac3c-4013-bbe7-a9cc28880423
尝试在服务器上使用较小的(2KB)文件即可.一个75MB的文件已正确附加,但从接收方接收到HTTP 400(我怀疑这是因为文件未完全传输)
Trying with a smaller (2KB) file on the server works just fine. A 75MB file gets attached correctly, but results in a HTTP 400 from the receiver (which i suspect is because the file is not fully transferred)
有人对导致这种情况的原因有任何想法吗?
Does anyone have any ideas as to what might be causing this ?
推荐答案
经过多次试验&错误,我终于设法解决"了这一点.我启用了模式验证,现在显示数据.这是我原来问题中的两个错误都声称要修复的确切问题.
After much trial & error, i finally managed to "solve" this. I enabled schema validation, and the data now appears. This is the exact issue that both bugs in my original question claims to fix.
Client client = ClientProxy.getClient(port);
BindingProvider bp = ((BindingProvider) port);
bp.getRequestContext().put("schema-validation-enabled", "true");
这篇关于Spring Boot,带有MTOM的Apache CXF 3.2.5发送空附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!