[
https://issues.apache.org/jira/browse/CAMEL-5724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13491368#comment-13491368
]
Andrej Zachar commented on CAMEL-5724:
--------------------------------------
Hello All!
I have prepared the doc for the patch.
Because I do not have approchiate rights to provide an update for wiki, I'm
sending it here. I hope it is ok, if not, let me know what is the right process
to do it.
The Doc Update
===============
Add a brand new paragraph on the wiki page
http://camel.apache.org/spring-web-services.html
The header and attachment propagation
=====================================
Spring WS Camel supports propagation of the headers and attachments into
Spring-WS WebServiceMessage response since version 2.10.4+.
The endpoint will use so called "hook" the MessageFilter (default
implementation is provided by BasicMessageFilter) to propagate the exchange
headers and attachments into WebSdrviceMessage response.
Now you can use
exchange.getOut().getHeaders().put("myCustom","myHeaderValue")
exchange.getIn().addAttachment("myAttachment", new DataHandler(...))
Note: If the exchange header in the pipeline contains text, it generates
Qname(key)=value attribute in the soap header.
Recommended is to create a QName class directly and put into any key into
header.
How to use MTOM attachments
============================
The BasicMessageFilter provides all required information for Apache Axiom in
order to produce MTOM message. If you want to use Apache Camel Spring WS within
Apache Axiom, here is an example:
1. Simply define the messageFactory as is bellow and spring-ws will use MTOM
strategy to populate your SOAP message with optimized attachments.
<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>
2. Add into your pom.xml the following dependencies
<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>
3. Add your attachment into the pipeline, for example using a Processor
implementation.
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)));
}
}
4. Define endpoint (producer) as ussual, for example like this:
from("direct:send")
.process(new Attachement())
.to("spring-ws:http://localhost:8089/mySoapService?soapAction=mySoap&messageFactory=axiomMessageFactory");
5. Now, your producer will generate MTOM message with otpmized attachments.
The custom header and attachment filtering
==========================================
If you need to provide your custome processing of either headers or
attachments, extend existing BasicMessageFilter and override the approchiate
methods or write a brand new implementation of the MessageFilter interface.
To use your custom filter, add this into your spring context:
You can specify either a global a or a local message filter as follows:
a) the global custome filter that provides the global configuration for all
spring-ws endpoints
<bean id="messageFilter" class="your.domain.myMessageFiler"
scope="singleton" />
or
b) the local messageFilter directly on the endpoint as follows:
to("spring-ws:http://yourdomain.com?messageFilter=#<myEndpointSpecificMessageFilter>");
For more information see https://issues.apache.org/jira/browse/CAMEL-5724
If you want to create your own MessageFilter, consider overrideing the
following methods in the default implementation of MessageFilter in class
BasicMessageFilter:
protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage)
{your code /*no need to call super*/ }
protected void doProcessSoapAttachements(Message inOrOut, SoapMessage response)
{ your code /*no need to call super*/ }
Update the existing table at wiki page
http://camel.apache.org/spring-web-services.html and add the following new row:
Registry based options
=======================
messageFilter No Option to provide a custom MessageFilter since 2.10.4.
For example when you want to process your headers or attachments by your own.
Attachments processing using Axiom will produce message with attachment out of
box. You just need to provide
PS: Babak I will send tests and patch together soon. Should I create the final
patch agains trunk or agains the branch 2.10.3 where I have initially developed
this solution?
> Spring-WS consumer and producer do not propagate some custome headers and
> attachements to a response message
> ------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-5724
> URL: https://issues.apache.org/jira/browse/CAMEL-5724
> Project: Camel
> Issue Type: Improvement
> Components: camel-spring-ws
> Affects Versions: 2.10.1
> Reporter: Andrej Zachar
> Assignee: Willem Jiang
> Labels: patch
> Fix For: 2.10.3, 2.11.0
>
> Attachments: camel-spring-ws.patch, headerAndAttachmentsSupport.patch
>
>
> Hi!
> I wanted to send back as response or as a request some soap messages with
> modified header.
> I found out that SpringWebserviceProducer and SpringWebserviceConsumer do not
> populate a soap header for any outgoing message from a camel exchange.
> In the attachments I am sending you a patch against camel-spring-ws 2.10.1
> that solves this issue.
> Please let me know, what do you think about it.
> Best regards,
> Andrej
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira