324.9. MTOM 첨부 파일을 사용하는 방법
BasicMessageFilter는 MTOM 메시지를 생성하기 위해 Apache Axiom에 필요한 모든 정보를 제공합니다. Apache Axiom에서 Apache Camel Spring WS를 사용하려는 경우 다음과 같습니다. - llow로 messageFactory를 정의하면 Spring-WS는 MTOM 전략을 사용하여 SOAP 메시지를 최적화된 첨부 파일로 채웁니다.
<bean id="axiomMessageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"> <property name="payloadCaching" value="false" /> <property name="attachmentCaching" value="true" /> <property name="attachmentCacheThreshold" value="1024" /> </bean>
- pom.xml에 다음 종속 항목을 추가합니다.
<dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-api</artifactId> <version>1.2.13</version> </dependency> <dependency> <groupId>org.apache.ws.commons.axiom</groupId> <artifactId>axiom-impl</artifactId> <version>1.2.13</version> <scope>runtime</scope> </dependency>
- 예를 들어 프로세서 구현을 사용하여 파이프라인에 연결을 추가합니다.
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))); } }
- 다음과 같이 엔드포인트(producer)를 ussual로 정의합니다.
from("direct:send") .process(new Attachement()) .to("spring-ws:http://localhost:8089/mySoapService?soapAction=mySoap&messageFactory=axiomMessageFactory");
- 이제 생산자가 otpmized 첨부 파일을 사용하여 MTOM 메시지를 생성합니다.