You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/12/10 12:33:45 UTC

svn commit: r1419350 - in /camel/trunk/components/camel-spring-ws/src: main/java/org/apache/camel/component/spring/ws/ main/java/org/apache/camel/component/spring/ws/bean/ main/java/org/springframework/ main/java/org/springframework/ws/ main/java/org/s...

Author: ningjiang
Date: Mon Dec 10 11:33:43 2012
New Revision: 1419350

URL: http://svn.apache.org/viewvc?rev=1419350&view=rev
Log:
CAMEL-5815 Added support ws-relyto with thanks to Andrej

Added:
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/
    camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMappingHacked.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractWSATests.java
      - copied, changed from r1419197, camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/CamelDirectSenderTest.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/StaticIdStrategy.java
    camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml
Modified:
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java
    camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java
    camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java?rev=1419350&r1=1419349&r2=1419350&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java (original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java Mon Dec 10 11:33:43 2012
@@ -28,7 +28,9 @@ import org.apache.camel.converter.jaxp.X
 import org.apache.camel.util.jsse.SSLContextParameters;
 import org.springframework.util.StringUtils;
 import org.springframework.ws.client.core.WebServiceTemplate;
+import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
 import org.springframework.ws.soap.addressing.server.annotation.Action;
+import org.springframework.ws.transport.WebServiceMessageSender;
 
 public class SpringWebserviceConfiguration {
 
@@ -40,6 +42,8 @@ public class SpringWebserviceConfigurati
     private URI faultAction;
     private URI faultTo;
     private URI replyTo;
+    private WebServiceMessageSender replyToMessageSender;
+    private MessageIdStrategy messageIdStrategy;
     private int timeout = -1;
 
     /* Consumer configuration */
@@ -253,4 +257,30 @@ public class SpringWebserviceConfigurati
         this.replyTo = replyToAction;
     }
 
+    /** * @return Returns the replyToMessageSender for wsa:replyTo.
+     */
+    public WebServiceMessageSender getMessageSender() {
+        return replyToMessageSender;
+    }
+
+    /**
+     * @param replyToMessageSender The replyToMessageSender for wsa:replyTo to set.
+     */
+    public void setMessageSender(WebServiceMessageSender messageSender) {
+        this.replyToMessageSender = messageSender;
+    }
+
+    /** * @return Returns the messageIdStrategy.
+     */
+    public MessageIdStrategy getMessageIdStrategy() {
+        return messageIdStrategy;
+    }
+
+    /**
+     * @param messageIdStrategy The messageIdStrategy to set.
+     */
+    public void setMessageIdStrategy(MessageIdStrategy messageIdStrategy) {
+        this.messageIdStrategy = messageIdStrategy;
+    }
+    
 }

Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectConnection.java Mon Dec 10 11:33:43 2012
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.spring.ws.bean;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.ws.WebServiceMessage;
+import org.springframework.ws.WebServiceMessageFactory;
+import org.springframework.ws.transport.WebServiceConnection;
+
+/**
+ * Passes wsa:replyTo message back to the camel routing
+ */
+public class CamelDirectConnection implements WebServiceConnection {
+    private static final Logger LOG = LoggerFactory.getLogger(CamelDirectConnection.class);
+    private CamelContext camelContext;
+    private URI destination;
+
+    public CamelDirectConnection(CamelContext camelContext, URI uri) throws URISyntaxException {
+        this.camelContext = camelContext;
+        destination = new URI("direct:" + uri);
+    }
+
+    @Override
+    public void send(WebServiceMessage message) throws IOException {
+        try {
+            camelContext.createProducerTemplate().sendBody(destination.toString(), message);
+        } catch (CamelExecutionException e) {
+            // simply discard replyTo message
+            LOG.warn("Could not found any camel endpoint [" + destination + "] for wsa:ReplyTo camel mapping.", e);
+        }
+    }
+
+    @Override
+    public WebServiceMessage receive(WebServiceMessageFactory messageFactory) throws IOException {
+        return null;
+    }
+
+    @Override
+    public URI getUri() throws URISyntaxException {
+        return destination;
+    }
+
+    @Override
+    public boolean hasError() throws IOException {
+        return false;
+    }
+
+    @Override
+    public String getErrorMessage() throws IOException {
+        return null;
+    }
+
+    @Override
+    public void close() throws IOException {
+
+    }
+
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+}

Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelDirectSender.java Mon Dec 10 11:33:43 2012
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.spring.ws.bean;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.CamelContext;
+import org.springframework.ws.transport.WebServiceConnection;
+import org.springframework.ws.transport.WebServiceMessageSender;
+
+/**
+ * Use this class with conjuctions of wsa:replyTo custom routing using prefix
+ * direct Received message will be route like this: <to uri="direct:uri" />
+ */
+public class CamelDirectSender implements WebServiceMessageSender {
+
+    private CamelContext camelContext;
+
+    @Override
+    public WebServiceConnection createConnection(URI uri) throws IOException {
+        try {
+            return new CamelDirectConnection(camelContext, uri);
+        } catch (URISyntaxException e) {
+            throw new IOException(e);
+        }
+    }
+
+    @Override
+    public boolean supports(URI uri) {
+        try {
+            new CamelDirectConnection(camelContext, uri);
+            return true;
+        } catch (URISyntaxException e) {
+            return false;
+        }
+    }
+
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+}

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java?rev=1419350&r1=1419349&r2=1419350&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java (original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java Mon Dec 10 11:33:43 2012
@@ -45,6 +45,7 @@ import org.springframework.ws.server.end
 import org.springframework.ws.server.endpoint.support.PayloadRootUtils;
 import org.springframework.ws.soap.SoapMessage;
 import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
+import org.springframework.ws.soap.server.SoapEndpointMapping;
 import org.springframework.ws.transport.WebServiceConnection;
 import org.springframework.ws.transport.context.TransportContext;
 import org.springframework.ws.transport.context.TransportContextHolder;
@@ -80,7 +81,7 @@ import org.springframework.xml.xpath.XPa
  * @see org.springframework.ws.server.endpoint.mapping.XPathPayloadEndpointMapping
  * @see org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping
  */
-public class CamelEndpointMapping extends AbstractEndpointMapping implements InitializingBean, CamelSpringWSEndpointMapping {
+public class CamelEndpointMapping extends AbstractEndpointMapping implements InitializingBean, CamelSpringWSEndpointMapping, SoapEndpointMapping {
 
     private static final String DOUBLE_QUOTE = "\"";
     private Map<EndpointMappingKey, MessageEndpoint> endpoints = new ConcurrentHashMap<EndpointMappingKey, MessageEndpoint>();

Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java?rev=1419350&r1=1419349&r2=1419350&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java (original)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java Mon Dec 10 11:33:43 2012
@@ -29,7 +29,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.util.Assert;
 import org.springframework.ws.server.endpoint.MessageEndpoint;
 import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
+import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
 import org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMapping;
+import org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMappingHacked;
 import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping;
 import org.springframework.ws.transport.WebServiceConnection;
 import org.springframework.ws.transport.WebServiceMessageSender;
@@ -42,7 +44,7 @@ import org.springframework.ws.transport.
  * uses the camel uri to map to a WS-Addressing {@code Action} header.
  * <p/>
  */
-public class WSACamelEndpointMapping extends AbstractAddressingEndpointMapping implements CamelSpringWSEndpointMapping {
+public class WSACamelEndpointMapping extends AbstractAddressingEndpointMappingHacked implements CamelSpringWSEndpointMapping {
 
     private static final Logger LOG = LoggerFactory.getLogger(WSACamelEndpointMapping.class);
 
@@ -54,7 +56,6 @@ public class WSACamelEndpointMapping ext
 
     @Override
     protected Object getEndpointInternal(MessageAddressingProperties map) {
-
         for (EndpointMappingKey key : endpoints.keySet()) {
             String compositeOrSimpleKey = null;
             String simpleKey = null;
@@ -146,7 +147,7 @@ public class WSACamelEndpointMapping ext
     @Override
     protected URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap) {
         SpringWebserviceEndpoint camelEndpoint = getSpringWebserviceEndpoint(endpoint);
-        
+
         URI actionUri = camelEndpoint.getConfiguration().getOutputAction();
         if (actionUri == null) {
             actionUri = getDefaultResponseAction(camelEndpoint, requestMap);
@@ -155,6 +156,36 @@ public class WSACamelEndpointMapping ext
     }
 
     /**
+     * Configure message sender for wsa:replyTo from a camel route definition.
+     * The route definition has priority over this endpoint.
+     */
+    @Override
+    protected WebServiceMessageSender[] getMessageSenders(Object endpoint) {
+        SpringWebserviceEndpoint camelEndpoint = getSpringWebserviceEndpoint(endpoint);
+
+        if (camelEndpoint.getConfiguration().getMessageSender() != null) {
+            return new WebServiceMessageSender[] {camelEndpoint.getConfiguration().getMessageSender()};
+        }
+
+        return super.getMessageSenders(endpoint);
+    }
+
+    /**
+     * Configure message id strategy for wsa:replyTo The route definition has
+     * priority over this endpoint.
+     */
+    @Override
+    protected MessageIdStrategy getMessageStrategy(Object endpoint) {
+        SpringWebserviceEndpoint camelEndpoint = getSpringWebserviceEndpoint(endpoint);
+
+        if (camelEndpoint.getConfiguration().getMessageIdStrategy() != null) {
+            return camelEndpoint.getConfiguration().getMessageIdStrategy();
+        }
+
+        return super.getMessageStrategy(endpoint);
+    }
+
+    /**
      * return fault came uri param or default fault action or null
      */
     @Override
@@ -176,8 +207,6 @@ public class WSACamelEndpointMapping ext
         return (SpringWebserviceEndpoint)springWebserviceConsumer.getEndpoint();
     }
 
-  
-
     protected URI getDefaultResponseAction(Object endpoint, MessageAddressingProperties requestMap) {
         URI requestAction = requestMap.getAction();
         if (requestAction != null) {

Added: camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMappingHacked.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMappingHacked.java?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMappingHacked.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMappingHacked.java Mon Dec 10 11:33:43 2012
@@ -0,0 +1,309 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.ws.soap.addressing.server;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Iterator;
+import javax.xml.transform.TransformerException;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.Ordered;
+import org.springframework.util.Assert;
+import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.server.EndpointInterceptor;
+import org.springframework.ws.server.EndpointInvocationChain;
+import org.springframework.ws.server.EndpointMapping;
+import org.springframework.ws.soap.SoapHeader;
+import org.springframework.ws.soap.SoapHeaderElement;
+import org.springframework.ws.soap.SoapMessage;
+import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
+import org.springframework.ws.soap.addressing.messageid.MessageIdStrategy;
+import org.springframework.ws.soap.addressing.messageid.UuidMessageIdStrategy;
+import org.springframework.ws.soap.addressing.version.Addressing10;
+import org.springframework.ws.soap.addressing.version.Addressing200408;
+import org.springframework.ws.soap.addressing.version.AddressingVersion;
+import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
+import org.springframework.ws.soap.server.SoapEndpointMapping;
+import org.springframework.ws.transport.WebServiceMessageSender;
+import org.springframework.xml.transform.TransformerObjectSupport;
+
+/**
+ * THIS CLASS WILL BE REMOVED, WHEN THE FOLLOWING ISSUE WILL BE SOLVED: 
+ * https://jira.springsource.org/browse/SWS-817
+ * 
+ * Abstract base class for {@link EndpointMapping} implementations that handle WS-Addressing. Besides the normal {@link
+ * SoapEndpointMapping} properties, this mapping has a {@link #setVersions(org.springframework.ws.soap.addressing.version.AddressingVersion[])
+ * versions} property, which defines the WS-Addressing specifications supported. By default, these are {@link
+ * org.springframework.ws.soap.addressing.version.Addressing200408} and {@link org.springframework.ws.soap.addressing.version.Addressing10}.
+ * <p/>
+ * The {@link #setMessageIdStrategy(MessageIdStrategy) messageIdStrategy} property defines the strategy to use for
+ * creating reply <code>MessageIDs</code>. By default, this is the {@link UuidMessageIdStrategy}.
+ * <p/>
+ * The {@link #setMessageSenders(WebServiceMessageSender[]) messageSenders} are used to send out-of-band reply messages.
+ * If a request messages defines a non-anonymous reply address, these senders will be used to send the message.
+ * <p/>
+ * This mapping (and all subclasses) uses an implicit WS-Addressing {@link EndpointInterceptor}, which is added in every
+ * {@link EndpointInvocationChain} produced. As such, this mapping does not have the standard <code>interceptors</code>
+ * property, but rather a {@link #setPreInterceptors(EndpointInterceptor[]) preInterceptors} and {@link
+ * #setPostInterceptors(EndpointInterceptor[]) postInterceptors} property, which are added before and after the implicit
+ * WS-Addressing interceptor, respectively.
+ *
+ * @author Arjen Poutsma, Andrej Zachar
+ * @since 1.5.0
+ */
+public abstract class AbstractAddressingEndpointMappingHacked extends TransformerObjectSupport
+        implements SoapEndpointMapping, InitializingBean, Ordered {
+
+    private String[] actorsOrRoles;
+
+    private boolean isUltimateReceiver = true;
+
+    private MessageIdStrategy messageIdStrategy;
+
+    private WebServiceMessageSender[] messageSenders = new WebServiceMessageSender[0];
+
+    private AddressingVersion[] versions;
+
+    private EndpointInterceptor[] preInterceptors = new EndpointInterceptor[0];
+
+    private EndpointInterceptor[] postInterceptors = new EndpointInterceptor[0];
+
+    private int order = Integer.MAX_VALUE;  // default: same as non-Ordered
+
+
+    /** Protected constructor. Initializes the default settings. */
+    protected AbstractAddressingEndpointMappingHacked() {
+        initDefaultStrategies();
+    }
+
+    /**
+     * Initializes the default implementation for this mapping's strategies: the {@link
+     * org.springframework.ws.soap.addressing.version.Addressing200408} and {@link org.springframework.ws.soap.addressing.version.Addressing10}
+     * versions of the specification, and the {@link UuidMessageIdStrategy}.
+     */
+    protected void initDefaultStrategies() {
+        this.versions = new AddressingVersion[]{new Addressing200408(), new Addressing10()};
+        messageIdStrategy = new UuidMessageIdStrategy();
+    }
+
+    public final void setActorOrRole(String actorOrRole) {
+        Assert.notNull(actorOrRole, "actorOrRole must not be null");
+        actorsOrRoles = new String[]{actorOrRole};
+    }
+
+    public final void setActorsOrRoles(String[] actorsOrRoles) {
+        Assert.notEmpty(actorsOrRoles, "actorsOrRoles must not be empty");
+        this.actorsOrRoles = actorsOrRoles;
+    }
+
+    public final void setUltimateReceiver(boolean ultimateReceiver) {
+        this.isUltimateReceiver = ultimateReceiver;
+    }
+
+    public final int getOrder() {
+        return order;
+    }
+
+    /**
+     * Specify the order value for this mapping.
+     * <p/>
+     * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered.
+     *
+     * @see org.springframework.core.Ordered#getOrder()
+     */
+    public final void setOrder(int order) {
+        this.order = order;
+    }
+    
+
+    /**
+     * Set additional interceptors to be applied before the implicit WS-Addressing interceptor, e.g.
+     * <code>XwsSecurityInterceptor</code>.
+     */
+    public final void setPreInterceptors(EndpointInterceptor[] preInterceptors) {
+        Assert.notNull(preInterceptors, "'preInterceptors' must not be null");
+        this.preInterceptors = preInterceptors;
+    }
+
+    /**
+     * Set additional interceptors to be applied after the implicit WS-Addressing interceptor, e.g.
+     * <code>PayloadLoggingInterceptor</code>.
+     */
+    public final void setPostInterceptors(EndpointInterceptor[] postInterceptors) {
+        Assert.notNull(postInterceptors, "'postInterceptors' must not be null");
+        this.postInterceptors = postInterceptors;
+    }
+
+    /**
+     * Sets the message id strategy used for creating WS-Addressing MessageIds.
+     * <p/>
+     * By default, the {@link UuidMessageIdStrategy} is used.
+     */
+    public final void setMessageIdStrategy(MessageIdStrategy messageIdStrategy) {
+        Assert.notNull(messageIdStrategy, "'messageIdStrategy' must not be null");
+        this.messageIdStrategy = messageIdStrategy;
+    }
+
+    /**
+     * Sets the single message sender used for sending messages.
+     * <p/>
+     * This message sender will be used to resolve an URI to a
+     * {@link WebServiceConnection}.
+     * 
+     * @see #createConnection(URI)
+     */
+    public void setMessageSender(WebServiceMessageSender messageSender) {
+        Assert.notNull(messageSender, "'messageSender' must not be null");
+        setMessageSenders(new WebServiceMessageSender[] {messageSender});
+    }
+
+    public final void setMessageSenders(WebServiceMessageSender[] messageSenders) {
+        Assert.notNull(messageSenders, "'messageSenders' must not be null");
+        this.messageSenders = messageSenders;
+    }
+
+    public final WebServiceMessageSender[] getMessageSenders() {
+        return this.messageSenders;
+    }
+    /**
+     * Sets the WS-Addressing versions to be supported by this mapping.
+     * <p/>
+     * By default, this array is set to support {@link org.springframework.ws.soap.addressing.version.Addressing200408
+     * the August 2004} and the {@link org.springframework.ws.soap.addressing.version.Addressing10 May 2006} versions of
+     * the specification.
+     */
+    public final void setVersions(AddressingVersion[] versions) {
+        this.versions = versions;
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        if (logger.isInfoEnabled()) {
+            logger.info("Supporting " + Arrays.asList(versions));
+        }
+    }
+
+    public final EndpointInvocationChain getEndpoint(MessageContext messageContext) throws TransformerException {
+        Assert.isInstanceOf(SoapMessage.class, messageContext.getRequest());
+        SoapMessage request = (SoapMessage) messageContext.getRequest();
+        for (AddressingVersion version : versions) {
+            if (supports(version, request)) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Request [" + request + "] uses [" + version + "]");
+                }
+                MessageAddressingProperties requestMap = version.getMessageAddressingProperties(request);
+                if (requestMap == null) {
+                    return null;
+                }
+                Object endpoint = getEndpointInternal(requestMap);
+                if (endpoint == null) {
+                    return null;
+                }
+                return getEndpointInvocationChain(endpoint, version, requestMap);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Creates a {@link SoapEndpointInvocationChain} based on the given endpoint and {@link
+     * org.springframework.ws.soap.addressing.version.AddressingVersion}.
+     */
+    private EndpointInvocationChain getEndpointInvocationChain(Object endpoint,
+                                                               AddressingVersion version,
+                                                               MessageAddressingProperties requestMap) {
+        URI responseAction = getResponseAction(endpoint, requestMap);
+        URI faultAction = getFaultAction(endpoint, requestMap);
+        
+        WebServiceMessageSender[] messageSenders = getMessageSenders(endpoint);
+        MessageIdStrategy messageIdStrategy = getMessageStrategy(endpoint);
+ 
+        EndpointInterceptor[] interceptors =
+                new EndpointInterceptor[preInterceptors.length + postInterceptors.length + 1];
+        System.arraycopy(preInterceptors, 0, interceptors, 0, preInterceptors.length);
+        AddressingEndpointInterceptor interceptor = new AddressingEndpointInterceptor(version, messageIdStrategy,
+                messageSenders, responseAction, faultAction);
+        interceptors[preInterceptors.length] = interceptor;
+        System.arraycopy(postInterceptors, 0, interceptors, preInterceptors.length + 1, postInterceptors.length);
+        return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver);
+    }
+
+    private boolean supports(AddressingVersion version, SoapMessage request) {
+        SoapHeader header = request.getSoapHeader();
+        if (header != null) {
+            for (Iterator<SoapHeaderElement> iterator = header.examineAllHeaderElements(); iterator.hasNext();) {
+                SoapHeaderElement headerElement = iterator.next();
+                if (version.understands(headerElement)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    
+    /**
+     * Default implementation
+     * 
+     * @param endpoint specific message strategy
+     * @return
+     */
+    protected MessageIdStrategy getMessageStrategy(Object endpoint) {
+        return this.messageIdStrategy;
+    }
+
+    /**
+     * Default implementation
+     * 
+     * @param endpoint
+     * @return endpoint specific message senders
+     */
+    protected WebServiceMessageSender[] getMessageSenders(Object endpoint) {
+        return this.messageSenders;
+    }
+
+    /**
+     * Lookup an endpoint for the given  {@link MessageAddressingProperties}, returning <code>null</code> if no specific
+     * one is found. This template method is called by {@link #getEndpoint(MessageContext)}.
+     *
+     * @param map the message addressing properties
+     * @return the endpoint, or <code>null</code>
+     */
+    protected abstract Object getEndpointInternal(MessageAddressingProperties map);
+
+    /**
+     * Provides the WS-Addressing Action for response messages, given the endpoint, and request Message Addressing
+     * Properties.
+     *
+     * @param endpoint   the mapped endpoint
+     * @param requestMap the MAP for the request
+     * @return the response Action
+     */
+    protected abstract URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap);
+
+    /**
+     * Provides the WS-Addressing Action for response fault messages, given the endpoint, and request Message Addressing
+     * Properties.
+     *
+     * @param endpoint   the mapped endpoint
+     * @param requestMap the MAP for the request
+     * @return the response Action
+     */
+    protected abstract URI getFaultAction(Object endpoint, MessageAddressingProperties requestMap);
+
+}

Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java?rev=1419350&r1=1419349&r2=1419350&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java Mon Dec 10 11:33:43 2012
@@ -16,28 +16,12 @@
  */
 package org.apache.camel.component.spring.ws.addressing;
 
-import java.io.StringReader;
-import java.io.StringWriter;
 import java.net.URI;
-import java.net.URISyntaxException;
 
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.camel.component.spring.ws.utils.OutputChannelReceiver;
-import org.apache.camel.component.spring.ws.utils.TestUtil;
-import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.fest.assertions.Assertions;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.springframework.ws.client.core.WebServiceTemplate;
-import org.springframework.ws.soap.SoapMessage;
 import org.springframework.ws.soap.addressing.client.ActionCallback;
-import org.springframework.ws.soap.addressing.core.EndpointReference;
-import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
-import org.springframework.ws.soap.addressing.version.Addressing10;
 import org.springframework.ws.soap.client.SoapFaultClientException;
 
 /**
@@ -46,165 +30,7 @@ import org.springframework.ws.soap.clien
  * 
  * @author a.zachar
  */
-public abstract class AbstractConsumerTests extends CamelSpringTestSupport {
-    private final String xmlBody = "<GetQuote xmlns=\"http://www.webserviceX.NET/\"><symbol>GOOG</symbol></GetQuote>";
-
-    private WebServiceTemplate webServiceTemplate;
-    private OutputChannelReceiver response;
-    private OutputChannelReceiver newReply;
-
-    private StreamSource source;
-    private StreamResult result;
-    private String requestInputAction;
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        // initialize beans for catching results
-        webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
-        newReply = getMandatoryBean(OutputChannelReceiver.class, "replyReceiver");
-        response = getMandatoryBean(OutputChannelReceiver.class, "responseReceiver");
-
-        // sample data
-        source = new StreamSource(new StringReader(xmlBody));
-        result = new StreamResult(new StringWriter());
-
-        // reset from previous test
-        response.clear();
-        newReply.clear();
-        requestInputAction = null;
-    }
-
-    @After
-    public void after() throws Exception {
-        assertNotNull(result);
-    }
-
-    /**
-     * Creates WS-Addressing Action and ReplyTo param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback actionAndReplyTo(String action, String replyTo) throws URISyntaxException {
-        requestInputAction = action;
-        ActionCallback requestCallback = new ActionCallback(action);
-        if (replyTo != null) {
-            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
-        }
-        return requestCallback;
-    }
-
-    /**
-     * Creates WS-Addressing Action param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback action(String action) throws URISyntaxException {
-        return actionAndReplyTo(action, null);
-    }
-
-    /**
-     * Creates WS-Addressing To and ReplyTo param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback toAndReplyTo(String to, String replyTo) throws URISyntaxException {
-        requestInputAction = "http://doesn-not-matter.com";
-        ActionCallback requestCallback = new ActionCallback(new URI(requestInputAction), new Addressing10(), new URI(to));
-        if (replyTo != null) {
-            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
-        }
-        return requestCallback;
-    }
-
-    /**
-     * Creates WS-Addressing To param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback to(String to) throws URISyntaxException {
-        return toAndReplyTo(to, null);
-    }
-
-    /**
-     * Construct a default action for the response message from the input
-     * message using the default response action suffix.
-     * 
-     * @return
-     * @throws URISyntaxException
-     */
-    private URI getDefaultResponseAction() throws URISyntaxException {
-        return new URI(requestInputAction + "Response");
-    }
-
-    /**
-     * Only response is allow using a brand new channel
-     * 
-     * @return
-     */
-
-    protected final MessageAddressingProperties newChannelParams() {
-        assertNotNull(newReply);
-        assertNotNull(newReply.getMessageContext());
-        SoapMessage request = (SoapMessage)newReply.getMessageContext().getRequest();
-        assertNotNull(request);
-
-        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(request);
-        assertNotNull(wsaProperties);
-        assertNotNull(wsaProperties.getTo());
-        return wsaProperties;
-    }
-
-    /**
-     * Only response is allow using same channel
-     * 
-     * @return
-     */
-    protected final MessageAddressingProperties sameChannelParams() {
-        // we expect the same channel reply
-        assertNull(newReply.getMessageContext());
-
-        assertNotNull(response);
-        assertNotNull(response.getMessageContext());
-
-        SoapMessage soapResponse = (SoapMessage)response.getMessageContext().getResponse();
-        assertNotNull(soapResponse);
-
-        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(soapResponse);
-        assertNotNull(wsaProperties);
-        return wsaProperties;
-    }
-
-    /**
-     * Provides such an ActionCallback that sets the WS-Addressing param replyTo
-     * or doesn't set WS-Addressing param replyTo. In other words it cause
-     * response to be return using new or same channel as the request.
-     * 
-     * @param action
-     * @return
-     * @throws URISyntaxException
-     */
-    abstract ActionCallback channelIn(String action) throws URISyntaxException;
-
-    /**
-     * Provide corresponding results based on channel input. These two abstract methods (channelIn and
-     * channelOut)are bind together tighly.
-     * 
-     * @return
-     */
-    abstract MessageAddressingProperties channelOut();
+public abstract class AbstractConsumerTests extends AbstractWSATests {
 
     @Test
     public void defaultAction4ouput() throws Exception {

Copied: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractWSATests.java (from r1419197, camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractWSATests.java?p2=camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractWSATests.java&p1=camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java&r1=1419197&r2=1419350&rev=1419350&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java (original)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractWSATests.java Mon Dec 10 11:33:43 2012
@@ -1,333 +1,204 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.spring.ws.addressing;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.camel.component.spring.ws.utils.OutputChannelReceiver;
-import org.apache.camel.component.spring.ws.utils.TestUtil;
-import org.apache.camel.test.junit4.CamelSpringTestSupport;
-import org.fest.assertions.Assertions;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.ws.client.core.WebServiceTemplate;
-import org.springframework.ws.soap.SoapMessage;
-import org.springframework.ws.soap.addressing.client.ActionCallback;
-import org.springframework.ws.soap.addressing.core.EndpointReference;
-import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
-import org.springframework.ws.soap.addressing.version.Addressing10;
-import org.springframework.ws.soap.client.SoapFaultClientException;
-
-/**
- * Provides abstract test for fault and output params for spring-ws:to: and
- * spring-ws:action: endpoints
- * 
- * @author a.zachar
- */
-public abstract class AbstractConsumerTests extends CamelSpringTestSupport {
-    private final String xmlBody = "<GetQuote xmlns=\"http://www.webserviceX.NET/\"><symbol>GOOG</symbol></GetQuote>";
-
-    private WebServiceTemplate webServiceTemplate;
-    private OutputChannelReceiver response;
-    private OutputChannelReceiver newReply;
-
-    private StreamSource source;
-    private StreamResult result;
-    private String requestInputAction;
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        // initialize beans for catching results
-        webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
-        newReply = getMandatoryBean(OutputChannelReceiver.class, "replyReceiver");
-        response = getMandatoryBean(OutputChannelReceiver.class, "responseReceiver");
-
-        // sample data
-        source = new StreamSource(new StringReader(xmlBody));
-        result = new StreamResult(new StringWriter());
-
-        // reset from previous test
-        response.clear();
-        newReply.clear();
-        requestInputAction = null;
-    }
-
-    @After
-    public void after() throws Exception {
-        assertNotNull(result);
-    }
-
-    /**
-     * Creates WS-Addressing Action and ReplyTo param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback actionAndReplyTo(String action, String replyTo) throws URISyntaxException {
-        requestInputAction = action;
-        ActionCallback requestCallback = new ActionCallback(action);
-        if (replyTo != null) {
-            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
-        }
-        return requestCallback;
-    }
-
-    /**
-     * Creates WS-Addressing Action param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback action(String action) throws URISyntaxException {
-        return actionAndReplyTo(action, null);
-    }
-
-    /**
-     * Creates WS-Addressing To and ReplyTo param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback toAndReplyTo(String to, String replyTo) throws URISyntaxException {
-        requestInputAction = "http://doesn-not-matter.com";
-        ActionCallback requestCallback = new ActionCallback(new URI(requestInputAction), new Addressing10(), new URI(to));
-        if (replyTo != null) {
-            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
-        }
-        return requestCallback;
-    }
-
-    /**
-     * Creates WS-Addressing To param for request
-     * 
-     * @param action
-     * @param replyTo
-     * @return
-     * @throws URISyntaxException
-     */
-    protected final ActionCallback to(String to) throws URISyntaxException {
-        return toAndReplyTo(to, null);
-    }
-
-    /**
-     * Construct a default action for the response message from the input
-     * message using the default response action suffix.
-     * 
-     * @return
-     * @throws URISyntaxException
-     */
-    private URI getDefaultResponseAction() throws URISyntaxException {
-        return new URI(requestInputAction + "Response");
-    }
-
-    /**
-     * Only response is allow using a brand new channel
-     * 
-     * @return
-     */
-
-    protected final MessageAddressingProperties newChannelParams() {
-        assertNotNull(newReply);
-        assertNotNull(newReply.getMessageContext());
-        SoapMessage request = (SoapMessage)newReply.getMessageContext().getRequest();
-        assertNotNull(request);
-
-        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(request);
-        assertNotNull(wsaProperties);
-        assertNotNull(wsaProperties.getTo());
-        return wsaProperties;
-    }
-
-    /**
-     * Only response is allow using same channel
-     * 
-     * @return
-     */
-    protected final MessageAddressingProperties sameChannelParams() {
-        // we expect the same channel reply
-        assertNull(newReply.getMessageContext());
-
-        assertNotNull(response);
-        assertNotNull(response.getMessageContext());
-
-        SoapMessage soapResponse = (SoapMessage)response.getMessageContext().getResponse();
-        assertNotNull(soapResponse);
-
-        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(soapResponse);
-        assertNotNull(wsaProperties);
-        return wsaProperties;
-    }
-
-    /**
-     * Provides such an ActionCallback that sets the WS-Addressing param replyTo
-     * or doesn't set WS-Addressing param replyTo. In other words it cause
-     * response to be return using new or same channel as the request.
-     * 
-     * @param action
-     * @return
-     * @throws URISyntaxException
-     */
-    abstract ActionCallback channelIn(String action) throws URISyntaxException;
-
-    /**
-     * Provide corresponding results based on channel input. These two abstract methods (channelIn and
-     * channelOut)are bind together tighly.
-     * 
-     * @return
-     */
-    abstract MessageAddressingProperties channelOut();
-
-    @Test
-    public void defaultAction4ouput() throws Exception {
-        ActionCallback requestCallback = channelIn("http://default-ok.com/");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(getDefaultResponseAction());
-    }
-
-    @Test
-    public void defaultAction4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://default-fault.com/");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(getDefaultResponseAction());
-    }
-
-    @Test
-    public void customAction4output() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uri-ok.com");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://customURIOutputAction"));
-    }
-
-    @Test
-    public void customAction4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uri-fault.com");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://customURIFaultAction"));
-    }
-
-    @Test
-    @Ignore(value = "Not implemented yet")
-    public void overrideHeaderAction4output() throws Exception {
-        ActionCallback requestCallback = channelIn("http://override-ok.com");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://outputHeader.com"));
-    }
-
-    @Test
-    @Ignore(value = "Not implemented yet")
-    public void overrideHeaderAction4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://override-fault.com");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://faultHeader.com"));
-    }
-
-    @Test
-    @Ignore(value = "Not implemented yet")
-    public void headerAction4output() throws Exception {
-        ActionCallback requestCallback = channelIn("http://headerOnly-ok.com");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://outputHeader.com"));
-    }
-
-    @Test
-    @Ignore(value = "Not implemented yet")
-    public void headerAction4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://headerOnly-fault.com");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://faultHeader.com"));
-    }
-
-    @Test
-    public void onlyCustomOutputSpecified4output() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uriOutputOnly-ok.com/");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://customURIOutputAction"));
-    }
-
-    @Test
-    public void onlyCustomOutputSpecified4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uriOutputOnly-fault.com/");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(getDefaultResponseAction());
-    }
-
-    @Test
-    public void onlyCustomFaultSpecified4output() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uriFaultOnly-ok.com/");
-
-        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(getDefaultResponseAction());
-    }
-
-    @Test
-    public void onlyCustomFaultSpecified4fault() throws Exception {
-        ActionCallback requestCallback = channelIn("http://uriFaultOnly-fault.com/");
-        try {
-            webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
-        } catch (SoapFaultClientException e) {
-            // ok - cause fault response
-        }
-        Assertions.assertThat(channelOut().getAction()).isEqualTo(new URI("http://customURIFaultAction"));
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.spring.ws.addressing;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.camel.component.spring.ws.utils.OutputChannelReceiver;
+import org.apache.camel.component.spring.ws.utils.TestUtil;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import org.springframework.ws.soap.SoapMessage;
+import org.springframework.ws.soap.addressing.client.ActionCallback;
+import org.springframework.ws.soap.addressing.core.EndpointReference;
+import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
+import org.springframework.ws.soap.addressing.version.Addressing10;
+
+/**
+ * Provides abstract test for WS-Addressing
+ * 
+ * @author a.zachar
+ */
+public abstract class AbstractWSATests extends CamelSpringTestSupport {
+
+    protected WebServiceTemplate webServiceTemplate;
+    protected OutputChannelReceiver response;
+    protected OutputChannelReceiver newReply;
+    protected StreamSource source;
+    protected StreamResult result;
+
+    private final String xmlBody = "<GetQuote xmlns=\"http://www.webserviceX.NET/\"><symbol>GOOG</symbol></GetQuote>";
+    private String requestInputAction;
+    
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        // initialize beans for catching results
+        webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
+        newReply = getMandatoryBean(OutputChannelReceiver.class, "replyReceiver");
+        response = getMandatoryBean(OutputChannelReceiver.class, "responseReceiver");
+
+        // sample data
+        source = new StreamSource(new StringReader(xmlBody));
+        result = new StreamResult(new StringWriter());
+
+        // reset from previous test
+        response.clear();
+        newReply.clear();
+        requestInputAction = null;
+    }
+
+    @After
+    public void after() throws Exception {
+        assertNotNull(result);
+    }
+
+    /**
+     * Creates WS-Addressing Action and ReplyTo param for request
+     * 
+     * @param action
+     * @param replyTo
+     * @return
+     * @throws URISyntaxException
+     */
+    protected final ActionCallback actionAndReplyTo(String action, String replyTo) throws URISyntaxException {
+        requestInputAction = action;
+        ActionCallback requestCallback = new ActionCallback(action);
+        if (replyTo != null) {
+            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
+        }
+        return requestCallback;
+    }
+
+    /**
+     * Creates WS-Addressing Action param for request
+     * 
+     * @param action
+     * @param replyTo
+     * @return
+     * @throws URISyntaxException
+     */
+    protected final ActionCallback action(String action) throws URISyntaxException {
+        return actionAndReplyTo(action, null);
+    }
+
+    /**
+     * Creates WS-Addressing To and ReplyTo param for request
+     * 
+     * @param action
+     * @param replyTo
+     * @return
+     * @throws URISyntaxException
+     */
+    protected final ActionCallback toAndReplyTo(String to, String replyTo) throws URISyntaxException {
+        requestInputAction = "http://doesn-not-matter.com";
+        ActionCallback requestCallback = new ActionCallback(new URI(requestInputAction), new Addressing10(), new URI(to));
+        if (replyTo != null) {
+            requestCallback.setReplyTo(new EndpointReference(new URI(replyTo)));
+        }
+        return requestCallback;
+    }
+
+    /**
+     * Creates WS-Addressing To param for request
+     * 
+     * @param action
+     * @param replyTo
+     * @return
+     * @throws URISyntaxException
+     */
+    protected final ActionCallback to(String to) throws URISyntaxException {
+        return toAndReplyTo(to, null);
+    }
+
+    /**
+     * Construct a default action for the response message from the input
+     * message using the default response action suffix.
+     * 
+     * @return
+     * @throws URISyntaxException
+     */
+    protected URI getDefaultResponseAction() throws URISyntaxException {
+        return new URI(requestInputAction + "Response");
+    }
+
+    /**
+     * Only response is allow using a brand new channel
+     * 
+     * @return
+     */
+
+    protected final MessageAddressingProperties newChannelParams() {
+        assertNotNull(newReply);
+        assertNotNull(newReply.getMessageContext());
+        SoapMessage request = (SoapMessage)newReply.getMessageContext().getRequest();
+        assertNotNull(request);
+
+        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(request);
+        assertNotNull(wsaProperties);
+        assertNotNull(wsaProperties.getTo());
+        return wsaProperties;
+    }
+
+    /**
+     * Only response is allow using same channel
+     * 
+     * @return
+     */
+    protected final MessageAddressingProperties sameChannelParams() {
+        // we expect the same channel reply
+        assertNull(newReply.getMessageContext());
+
+        assertNotNull(response);
+        assertNotNull(response.getMessageContext());
+
+        SoapMessage soapResponse = (SoapMessage)response.getMessageContext().getResponse();
+        assertNotNull(soapResponse);
+
+        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(soapResponse);
+        assertNotNull(wsaProperties);
+        return wsaProperties;
+    }
+
+    /**
+     * Provides such an ActionCallback that sets the WS-Addressing param replyTo
+     * or doesn't set WS-Addressing param replyTo. In other words it cause
+     * response to be return using new or same channel as the request.
+     * 
+     * @param action
+     * @return
+     * @throws URISyntaxException
+     */
+    abstract ActionCallback channelIn(String action) throws URISyntaxException;
+
+    /**
+     * Provide corresponding results based on channel input. These two abstract
+     * methods (channelIn and channelOut)are bind together tighly.
+     * 
+     * @return
+     */
+    abstract MessageAddressingProperties channelOut();
+
+}

Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/CamelDirectSenderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/CamelDirectSenderTest.java?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/CamelDirectSenderTest.java (added)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/CamelDirectSenderTest.java Mon Dec 10 11:33:43 2012
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.spring.ws.addressing;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.spring.ws.utils.OutputChannelReceiver;
+import org.apache.camel.component.spring.ws.utils.TestUtil;
+import org.fest.assertions.Assertions;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.ws.soap.SoapMessage;
+import org.springframework.ws.soap.addressing.client.ActionCallback;
+import org.springframework.ws.soap.addressing.core.MessageAddressingProperties;
+
+/**
+ * Provides abstract test for fault and output params for spring-ws:to: and
+ * spring-ws:action: endpoints
+ * 
+ * @author a.zachar
+ */
+public class CamelDirectSenderTest extends AbstractWSATests {
+
+    private OutputChannelReceiver customChannel;
+
+    @EndpointInject(uri = "mock:camelDirect")
+    private MockEndpoint endpointCamelDirect;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        // initialize beans for catching results
+        customChannel = getMandatoryBean(OutputChannelReceiver.class, "customReceiver");
+        customChannel.clear();
+    }
+
+    /**
+     * Only response is allow using a brand custom channel
+     * 
+     * @return
+     */
+
+    private MessageAddressingProperties customChannelParams() {
+        assertNotNull(customChannel);
+        assertNotNull(customChannel.getMessageContext());
+        SoapMessage request = (SoapMessage)customChannel.getMessageContext().getRequest();
+        assertNotNull(request);
+
+        MessageAddressingProperties wsaProperties = TestUtil.getWSAProperties(request);
+        assertNotNull(wsaProperties);
+        assertNotNull(wsaProperties.getTo());
+        return wsaProperties;
+    }
+
+    @Override
+    public ActionCallback channelIn(String actionUri) throws URISyntaxException {
+        // new channel
+        return toAndReplyTo(actionUri, "mailto:andrej@chocolatejar.eu");
+    }
+
+    @Override
+    public MessageAddressingProperties channelOut() {
+        return newChannelParams();
+    }
+
+    @Test
+    public void endpointSender() throws Exception {
+        ActionCallback requestCallback = channelIn("http://sender-default.com");
+
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+
+        Assertions.assertThat(channelOut().getTo()).isEqualTo(new URI("mailto:andrej@chocolatejar.eu"));
+        Assertions.assertThat(endpointCamelDirect.getReceivedCounter()).isZero();
+    }
+
+    @Test
+    public void customSender() throws Exception {
+        ActionCallback requestCallback = channelIn("http://sender-custom.com");
+
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+
+        Assertions.assertThat(customChannelParams().getTo()).isEqualTo(new URI("mailto:andrej@chocolatejar.eu"));
+        Assertions.assertThat(endpointCamelDirect.getReceivedCounter()).isZero();
+    }
+
+    @Test
+    public void camelInvalid() throws Exception {
+        ActionCallback requestCallback = toAndReplyTo("http://sender-camel.com", "mailto:not-mappped-address@chocolatejar.eu");
+
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+        Assertions.assertThat(endpointCamelDirect.getReceivedCounter()).isZero();
+    }
+
+    @Test
+    public void camelReceivedReplyTo() throws Exception {
+        ActionCallback requestCallback = channelIn("http://sender-camel.com");
+
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+        endpointCamelDirect.assertExchangeReceived(0);
+        endpointCamelDirect.assertIsSatisfied();
+    }
+    
+    @Test
+    public void customMessageIdGenerator() throws Exception {
+        ActionCallback requestCallback = channelIn("http://messageIdStrategy-custom.com");
+        
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+        
+        Assertions.assertThat(channelOut().getMessageId()).isEqualTo(new URI("staticTestId"));
+    }
+    
+    @Test
+    public void defaultMessageIdGenerator() throws Exception {
+        ActionCallback requestCallback = channelIn("http://messageIdStrategy-default.com");
+        
+        webServiceTemplate.sendSourceAndReceiveToResult(source, requestCallback, result);
+        
+        Assertions.assertThat(channelOut().getMessageId()).isNotEqualTo(new URI("staticTestId"));
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml"});
+    }
+
+}

Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/StaticIdStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/StaticIdStrategy.java?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/StaticIdStrategy.java (added)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/StaticIdStrategy.java Mon Dec 10 11:33:43 2012
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.spring.ws.addressing;
+
+import java.net.URI;
+
+import org.springframework.ws.soap.SoapMessage;
+import org.springframework.ws.soap.addressing.messageid.UuidMessageIdStrategy;
+
+/**
+ * Generates sample ID for test purpose.
+ */
+public class StaticIdStrategy extends UuidMessageIdStrategy {
+
+    public URI newMessageId(SoapMessage message) {
+        return URI.create("staticTestId");
+    }
+}

Added: camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml?rev=1419350&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml (added)
+++ camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/CamelDirectSenderTest-context.xml Mon Dec 10 11:33:43 2012
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="
+         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+         http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+	<!-- ============================== -->
+	<!-- Camel routes -->
+	<!-- ============================== -->
+
+	<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+
+
+
+		<route>
+			<from
+				uri="spring-ws:to:http://sender-default.com?endpointMapping=#wsaEndpointMapping" />
+			<to uri="okResponse" />
+		</route>
+
+		<route>
+			<from
+				uri="spring-ws:to:http://sender-custom.com?messageSender=#customMessageSender&amp;endpointMapping=#wsaEndpointMapping" />
+			<to uri="okResponse" />
+		</route>
+
+		<route>
+			<from
+				uri="spring-ws:to:http://sender-camel.com?messageSender=#camelDirectMessageSender&amp;endpointMapping=#wsaEndpointMapping" />
+			<to uri="okResponse" />
+		</route>
+
+		<route>
+			<from uri="direct:mailto:andrej@chocolatejar.eu" />
+			<to uri="mock:camelDirect" />
+		</route>
+
+
+		<route>
+			<from
+				uri="spring-ws:to:http://messageIdStrategy-default.com?endpointMapping=#wsaEndpointMapping" />
+			<to uri="okResponse" />
+		</route>
+		<route>
+			<from
+				uri="spring-ws:to:http://messageIdStrategy-custom.com?endpointMapping=#wsaEndpointMapping&amp;messageIdStrategy=#staticId" />
+			<to uri="okResponse" />
+		</route>
+
+	</camelContext>
+
+	<!-- ============================== -->
+	<!-- The Sample Data -->
+	<!-- ============================== -->
+	<bean id="okResponse"
+		class="org.apache.camel.component.spring.ws.processor.OkResponseProcessor">
+	</bean>
+	
+	<bean id="staticId"
+		class="org.apache.camel.component.spring.ws.addressing.StaticIdStrategy">
+	</bean>
+
+
+
+	<!-- ============================== -->
+	<!-- Endpoint Mapping for WS-Addressing -->
+	<!-- ============================== -->
+	<bean id="wsaEndpointMapping"
+		class="org.apache.camel.component.spring.ws.bean.WSACamelEndpointMapping">
+		<property name="messageSender" ref="endpointMessageSender" />
+	</bean>
+
+
+
+	<!-- ============================== -->
+	<!-- WSA:Reply-To Senders -->
+	<!-- ============================== -->
+
+	<bean id="endpointMessageSender"
+		class="net.javacrumbs.springws.test.helper.InMemoryWebServiceMessageSender2">
+		<property name="webServiceMessageReceiver" ref="replyReceiver" />
+	</bean>
+
+	<bean id="customMessageSender"
+		class="net.javacrumbs.springws.test.helper.InMemoryWebServiceMessageSender2">
+		<property name="webServiceMessageReceiver" ref="customReceiver" />
+	</bean>
+
+	<bean id="camelDirectMessageSender"
+		class="org.apache.camel.component.spring.ws.bean.CamelDirectSender">
+		<property name="camelContext" ref="camelContext" />
+	</bean>
+
+
+	<!-- ============================== -->
+	<!-- The Separate Channel's Reply catchers for test analysis -->
+	<!-- ============================== -->
+	<bean id="replyReceiver"
+		class="org.apache.camel.component.spring.ws.utils.OutputChannelReceiver"
+		scope="singleton" />
+
+	<bean id="customReceiver"
+		class="org.apache.camel.component.spring.ws.utils.OutputChannelReceiver"
+		scope="singleton" />
+
+
+	<!-- ============================== -->
+	<!-- The Same Channel's Response Sender -->
+	<!-- ============================== -->
+	<bean id="responseReceiver"
+		class="org.apache.camel.component.spring.ws.utils.OutputChannelReceiver"
+		scope="singleton" />
+
+	<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
+		<property name="defaultUri" value="http://localhost" />
+		<property name="messageSender">
+			<bean
+				class="net.javacrumbs.springws.test.helper.InMemoryWebServiceMessageSender2">
+				<property name="decorator" ref="responseReceiver" />
+			</bean>
+		</property>
+	</bean>
+
+</beans>
\ No newline at end of file