322.8. 如何使用 MTOM 附加
BasicMessageFilter 为 Apache Axiom 提供所有必需信息,以生成 MTOM 信息。如果要在 Apache Axiom 中使用 Apache Camel Spring WS,以下示例: - 简化了消息Factory 为 bellow,Spring-WS 将使用 MTOM 策略填充您的 SOAP 消息并带有优化的附件。
- 将 添加到 pom.xml 中以下依赖项
- 将附件添加到管道中,例如使用 Processor 实现。
private class Attachement implements Processor {
public void process(Exchange exchange) throws Exception
{ exchange.getOut().copyFrom(exchange.getIn()); File file = new File("testAttachment.txt"); exchange.getOut().addAttachment("test", new DataHandler(new FileDataSource(file))); }
}
private class Attachement implements Processor {
public void process(Exchange exchange) throws Exception
{ exchange.getOut().copyFrom(exchange.getIn()); File file = new File("testAttachment.txt"); exchange.getOut().addAttachment("test", new DataHandler(new FileDataSource(file))); }
}
- 将端点(生成器)定义为 ussual,如下所示:
from("direct:send")
.process(new Attachement())
.to("spring-ws:http://localhost:8089/mySoapService?soapAction=mySoap&messageFactory=axiomMessageFactory");
from("direct:send")
.process(new Attachement())
.to("spring-ws:http://localhost:8089/mySoapService?soapAction=mySoap&messageFactory=axiomMessageFactory");
- 现在,您的制作者将通过 otpmized attachments 生成 MTOM 消息。