Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 243A9EFD0 for ; Thu, 6 Dec 2012 06:46:57 +0000 (UTC) Received: (qmail 59961 invoked by uid 500); 6 Dec 2012 06:46:57 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 59906 invoked by uid 500); 6 Dec 2012 06:46:56 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 59886 invoked by uid 99); 6 Dec 2012 06:46:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 06:46:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 06:46:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A29CF23889BB; Thu, 6 Dec 2012 06:46:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1417747 [1/2] - 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/apache/camel/component/spring/ws/filter/impl/ main/java/org/... Date: Thu, 06 Dec 2012 06:46:14 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121206064616.A29CF23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Thu Dec 6 06:46:10 2012 New Revision: 1417747 URL: http://svn.apache.org/viewvc?rev=1417747&view=rev Log: CAMEL-5815 Support for WS-Addressing Action with thanks to Andrej Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelSpringWSEndpointMapping.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/net/ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/InMemoryWebServiceMessageSender2.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ 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/ConsumerWSAEndpointMappingRouteTest.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsActionTests.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsToTests.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsActionTests.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsToTests.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsBasicTest.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ProducerParamsPrecedenceTest.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/processor/ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/processor/FaultResponseProcessor.java - copied, changed from r1417746, camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/processor/OkResponseProcessor.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/processor/PrecedenceProcessor.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/utils/ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/utils/OutputChannelReceiver.java - copied, changed from r1417746, camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/utils/TestUtil.java camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ConsumerWSAEndpointMappingRouteTest-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ConsumerWSAParamsActionTests-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ConsumerWSAParamsTOTests-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ProducerParamsBasicTest-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/addresing/ProducerParamsPrecedenceTest-context.xml Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java 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/SpringWebserviceConstants.java camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.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/filter/impl/BasicMessageFilter.java camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilterTest.java camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/DefaultMessageFilter-context.xml camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/MessageFilter-context.xml Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java (original) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java Thu Dec 6 06:46:10 2012 @@ -26,7 +26,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher; -import org.apache.camel.component.spring.ws.bean.CamelEndpointMapping; +import org.apache.camel.component.spring.ws.bean.CamelSpringWSEndpointMapping; import org.apache.camel.component.spring.ws.filter.MessageFilter; import org.apache.camel.component.spring.ws.type.EndpointMappingKey; import org.apache.camel.component.spring.ws.type.EndpointMappingType; @@ -68,7 +68,7 @@ public class SpringWebserviceComponent e addConsumerConfiguration(remaining, parameters, configuration); addProducerConfiguration(remaining, parameters, configuration); addXmlConverterToConfiguration(parameters, configuration); - configureMessageFilter(parameters, configuration); + configureMessageFilter(parameters, configuration); setProperties(configuration, parameters); return new SpringWebserviceEndpoint(this, uri, configuration); } @@ -88,8 +88,7 @@ public class SpringWebserviceComponent e } } - private void addProducerConfiguration(String remaining, Map parameters, - SpringWebserviceConfiguration configuration) throws URISyntaxException { + private void addProducerConfiguration(String remaining, Map parameters, SpringWebserviceConfiguration configuration) throws URISyntaxException { if (configuration.getEndpointMapping() == null && configuration.getEndpointDispatcher() == null) { LOG.debug("Building Spring Web Services producer"); URI webServiceEndpointUri = new URI(UnsafeUriCharactersEncoder.encode(remaining)); @@ -134,11 +133,11 @@ public class SpringWebserviceComponent e private void addEndpointMappingToConfiguration(Map parameters, SpringWebserviceConfiguration configuration) { - // Obtain generic CamelEndpointMapping from registry - CamelEndpointMapping endpointMapping = resolveAndRemoveReferenceParameter(parameters, "endpointMapping", CamelEndpointMapping.class, null); + // Obtain generic CamelSpringWSEndpointMapping from registry + CamelSpringWSEndpointMapping endpointMapping = resolveAndRemoveReferenceParameter(parameters, "endpointMapping", CamelSpringWSEndpointMapping.class, null); if (endpointMapping == null && configuration.getEndpointDispatcher() == null) { - throw new IllegalArgumentException("No CamelEndpointMapping found in Spring ApplicationContext." - + " This bean is required for Spring-WS consumer support (unless the 'spring-ws:beanname:' URI scheme is used)"); + throw new IllegalArgumentException("No instance of CamelSpringWSEndpointMapping found in Spring ApplicationContext." + + " This bean is required for Spring-WS consumer support (unless the 'spring-ws:beanname:' URI scheme is used)"); } configuration.setEndpointMapping(endpointMapping); } @@ -157,8 +156,7 @@ public class SpringWebserviceComponent e } configuration.setXmlConverter(xmlConverter); } - - + /** * Configures the messageFilter's factory. The factory is looked up in the endpoint's URI and then in the Spring's context. * The bean search mechanism looks for a bean with the name messageFilter. 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=1417747&r1=1417746&r2=1417747&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 Thu Dec 6 06:46:10 2012 @@ -20,31 +20,37 @@ import java.net.URI; import java.net.URISyntaxException; import org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher; -import org.apache.camel.component.spring.ws.bean.CamelEndpointMapping; +import org.apache.camel.component.spring.ws.bean.CamelSpringWSEndpointMapping; import org.apache.camel.component.spring.ws.filter.MessageFilter; import org.apache.camel.component.spring.ws.filter.impl.BasicMessageFilter; import org.apache.camel.component.spring.ws.type.EndpointMappingKey; import org.apache.camel.converter.jaxp.XmlConverter; 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.server.annotation.Action; public class SpringWebserviceConfiguration { - + /* Producer configuration */ private WebServiceTemplate webServiceTemplate; private String soapAction; private URI wsAddressingAction; + private URI outputAction; + private URI faultAction; + private URI faultTo; + private URI replyTo; private int timeout = -1; /* Consumer configuration */ - private CamelEndpointMapping endpointMapping; + private CamelSpringWSEndpointMapping endpointMapping; private CamelEndpointDispatcher endpointDispatcher; private EndpointMappingKey endpointMappingKey; private SSLContextParameters sslContextParameters; private XmlConverter xmlConverter; private MessageFilter messageFilter; - + public WebServiceTemplate getWebServiceTemplate() { return webServiceTemplate; } @@ -80,7 +86,9 @@ public class SpringWebserviceConfigurati } public void setWsAddressingAction(String wsAddressingAction) throws URISyntaxException { - setWsAddressingAction(new URI(wsAddressingAction)); + if (StringUtils.hasText(wsAddressingAction)) { + setWsAddressingAction(new URI(wsAddressingAction)); + } } public int getTimeout() { @@ -91,11 +99,11 @@ public class SpringWebserviceConfigurati this.timeout = timeout; } - public CamelEndpointMapping getEndpointMapping() { + public CamelSpringWSEndpointMapping getEndpointMapping() { return endpointMapping; } - public void setEndpointMapping(CamelEndpointMapping endpointMapping) { + public void setEndpointMapping(CamelSpringWSEndpointMapping endpointMapping) { this.endpointMapping = endpointMapping; } @@ -106,7 +114,7 @@ public class SpringWebserviceConfigurati public void setEndpointMappingKey(EndpointMappingKey endpointMappingKey) { this.endpointMappingKey = endpointMappingKey; } - + public SSLContextParameters getSslContextParameters() { return sslContextParameters; } @@ -141,7 +149,6 @@ public class SpringWebserviceConfigurati return i == -1 ? uri : (uri.subSequence(0, i) + "}" + uri.substring(i + 1)).replaceFirst("\\(", "{"); } - /** * Default setter to override failsafe message filter. * @@ -165,4 +172,85 @@ public class SpringWebserviceConfigurati } return this.messageFilter; } + + /** + * Signifies the value for the response WS-Addressing Action + * header that is provided by the method. + * + * @see {@link Action} + */ + public URI getOutputAction() { + return outputAction; + } + + public void setOutputAction(String output) throws URISyntaxException { + if (StringUtils.hasText(output)) { + setOutputAction(new URI(output)); + } + } + + public void setOutputAction(URI outputAction) { + this.outputAction = outputAction; + } + + /** + * Signifies the value for the faultAction response WS-Addressing + * Fault Action header that is provided by the method. + * + * @see {@link Action} + */ + public URI getFaultAction() { + return faultAction; + } + + public void setFaultAction(String fault) throws URISyntaxException { + if (StringUtils.hasText(fault)) { + setFaultAction(new URI(fault)); + } + } + + public void setFaultAction(URI fault) { + this.faultAction = fault; + } + + /** + * Signifies the value for the faultAction response WS-Addressing + * FaultTo header that is provided by the method. + * + * @see {@link Action} + */ + public URI getFaultTo() { + return faultTo; + } + + public void setFaultTo(String faultTo) throws URISyntaxException { + if (StringUtils.hasText(faultTo)) { + setFaultTo(new URI(faultTo)); + } + } + + public void setFaultTo(URI faultTo) { + this.faultTo = faultTo; + } + + /** + * Signifies the value for the replyTo response WS-Addressing + * ReplyTo header that is provided by the method. + * + * @see {@link Action} + */ + public URI getReplyTo() { + return replyTo; + } + + public void setReplyTo(String replyToAction) throws URISyntaxException { + if (StringUtils.hasText(replyToAction)) { + setReplyTo(new URI(replyToAction)); + } + } + + public void setReplyTo(URI replyToAction) { + this.replyTo = replyToAction; + } + } Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java (original) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java Thu Dec 6 06:46:10 2012 @@ -22,6 +22,12 @@ public final class SpringWebserviceConst public static final String SPRING_WS_ENDPOINT_URI = "CamelSpringWebserviceEndpointUri"; public static final String SPRING_WS_SOAP_ACTION = "CamelSpringWebserviceSoapAction"; public static final String SPRING_WS_ADDRESSING_ACTION = "CamelSpringWebserviceAddressingAction"; + public static final String SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO = "CamelSpringWebserviceAddressingFaultTo"; + public static final String SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO = "CamelSpringWebserviceAddressingReplyTo"; + + /* Consumers constants (reserved, not impl. yet) */ + public static final String SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION = "CamelSpringWebserviceAddressingOutputAction"; + public static final String SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION = "CamelSpringWebserviceAddressingFaultAction"; private SpringWebserviceConstants() { } Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java (original) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java Thu Dec 6 06:46:10 2012 @@ -39,6 +39,7 @@ import org.springframework.ws.client.cor import org.springframework.ws.client.core.WebServiceMessageCallback; import org.springframework.ws.client.core.WebServiceTemplate; import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.core.EndpointReference; import org.springframework.ws.soap.client.core.SoapActionCallback; import org.springframework.ws.transport.WebServiceConnection; import org.springframework.ws.transport.WebServiceMessageSender; @@ -67,14 +68,17 @@ public class SpringWebserviceProducer ex Source sourcePayload = exchange.getIn().getMandatoryBody(Source.class); // Extract optional headers - String endpointUri = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, String.class); - String soapAction = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, String.class); - URI wsAddressingAction = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, URI.class); + String endpointUriHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, String.class); + String soapActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, String.class); + URI wsAddressingActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, URI.class); + URI wsReplyToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO, URI.class); + URI wsFaultToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO, URI.class); - WebServiceMessageCallback callback = new DefaultWebserviceMessageCallback(soapAction, wsAddressingAction, getEndpoint().getConfiguration(), exchange); + WebServiceMessageCallback callback = new DefaultWebserviceMessageCallback(soapActionHeader, wsAddressingActionHeader, wsReplyToHeader, + wsFaultToHeader, getEndpoint().getConfiguration(), exchange); Object body = null; - if (endpointUri != null) { - body = getEndpoint().getConfiguration().getWebServiceTemplate().sendSourceAndReceive(endpointUri, sourcePayload, callback, SOURCE_EXTRACTOR); + if (endpointUriHeader != null) { + body = getEndpoint().getConfiguration().getWebServiceTemplate().sendSourceAndReceive(endpointUriHeader, sourcePayload, callback, SOURCE_EXTRACTOR); } else { body = getEndpoint().getConfiguration().getWebServiceTemplate().sendSourceAndReceive(sourcePayload, callback, SOURCE_EXTRACTOR); } @@ -194,12 +198,16 @@ public class SpringWebserviceProducer ex protected static class DefaultWebserviceMessageCallback implements WebServiceMessageCallback { private final String soapActionHeader; private final URI wsAddressingActionHeader; + private final URI wsReplyToHeader; + private final URI wsFaultToHeader; private final SpringWebserviceConfiguration configuration; private final Exchange exchange; - public DefaultWebserviceMessageCallback(String soapAction, URI wsAddressingAction, SpringWebserviceConfiguration configuration, Exchange exchange) { + public DefaultWebserviceMessageCallback(String soapAction, URI wsAddressingAction, URI wsReplyTo, URI wsFaultTo, SpringWebserviceConfiguration configuration, Exchange exchange) { this.soapActionHeader = soapAction; this.wsAddressingActionHeader = wsAddressingAction; + this.wsReplyToHeader = wsReplyTo; + this.wsFaultToHeader = wsFaultTo; this.configuration = configuration; this.exchange = exchange; } @@ -215,8 +223,19 @@ public class SpringWebserviceProducer ex // 'to' header will default to the URL of the connection). // Note that exchange header takes precedence over endpoint option URI wsAddressingAction = wsAddressingActionHeader != null ? wsAddressingActionHeader : configuration.getWsAddressingAction(); + URI wsReplyTo = wsReplyToHeader != null ? wsReplyToHeader : configuration.getReplyTo(); + URI wsFaultTo = wsFaultToHeader != null ? wsFaultToHeader : configuration.getFaultTo(); + if (wsAddressingAction != null) { - new ActionCallback(wsAddressingAction).doWithMessage(message); + ActionCallback actionCallback = new ActionCallback(wsAddressingAction); + if (wsReplyTo != null) { + actionCallback.setReplyTo(new EndpointReference(wsReplyTo)); + } + + if (wsFaultTo != null) { + actionCallback.setFaultTo(new EndpointReference(wsFaultTo)); + } + actionCallback.doWithMessage(message); } configuration.getMessageFilter().filterProducer(exchange, message); 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=1417747&r1=1417746&r2=1417747&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 Thu Dec 6 06:46:10 2012 @@ -34,6 +34,7 @@ import org.apache.camel.component.spring import org.apache.camel.component.spring.ws.type.EndpointMappingType; import org.apache.camel.converter.jaxp.XmlConverter; import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -50,37 +51,46 @@ import org.springframework.ws.transport. import org.springframework.xml.xpath.XPathExpression; /** - * Spring {@link EndpointMapping} for mapping messages to corresponding Camel endpoints. - * This class needs to be registered in the Spring ApplicationContext when - * consuming messages using any of the following URI schemes: + * Spring {@link EndpointMapping} for mapping messages to corresponding Camel + * endpoints. This class needs to be registered in the Spring + * ApplicationContext when consuming messages using any of the + * following URI schemes: *

*

    *
  • spring-ws:rootqname:
    - * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping} + * Equivalent to endpoint mappings specified through + * {@link org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping} *

    *

  • spring-ws:soapaction:
    - * Equivalent to endpoint mappings specified through {@link org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping} + * Equivalent to endpoint mappings specified through + * {@link org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping} *

    *

  • spring-ws:uri:
    - * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.UriEndpointMapping} + * Equivalent to endpoint mappings specified through + * {@link org.springframework.ws.server.endpoint.mapping.UriEndpointMapping} *

    *

  • spring-ws:xpathresult:
    - * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.XPathPayloadEndpointMapping} + * Equivalent to endpoint mappings specified through + * {@link org.springframework.ws.server.endpoint.mapping.XPathPayloadEndpointMapping} *
- * + * * @see org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping * @see org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping * @see org.springframework.ws.server.endpoint.mapping.UriEndpointMapping * @see org.springframework.ws.server.endpoint.mapping.XPathPayloadEndpointMapping * @see org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping */ -public class CamelEndpointMapping extends AbstractEndpointMapping implements InitializingBean { +public class CamelEndpointMapping extends AbstractEndpointMapping implements InitializingBean, CamelSpringWSEndpointMapping { private static final String DOUBLE_QUOTE = "\""; private Map endpoints = new ConcurrentHashMap(); private TransformerFactory transformerFactory; private XmlConverter xmlConverter; + private String[] actorsOrRoles; + + private boolean isUltimateReceiver = true; + @Override protected Object getEndpointInternal(MessageContext messageContext) throws Exception { for (EndpointMappingKey key : endpoints.keySet()) { @@ -114,9 +124,7 @@ public class CamelEndpointMapping extend if (EndpointMappingType.SOAP_ACTION.equals(key.getType())) { Object messageKey = getSoapAction(messageContext); if (messageKey != null && key.getLookupKey().equals(messageKey)) { - return new SoapEndpointInvocationChain(endpoint, interceptors); - // possibly add support for SOAP actors/roles and ultimate - // receiver in the future + return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver); } } } @@ -125,7 +133,7 @@ public class CamelEndpointMapping extend private String getSoapAction(MessageContext messageContext) { if (messageContext.getRequest() instanceof SoapMessage) { - SoapMessage request = (SoapMessage) messageContext.getRequest(); + SoapMessage request = (SoapMessage)messageContext.getRequest(); String soapAction = request.getSoapAction(); if (StringUtils.hasLength(soapAction) && soapAction.startsWith(DOUBLE_QUOTE) && soapAction.endsWith(DOUBLE_QUOTE)) { return soapAction.substring(1, soapAction.length() - 1); @@ -151,7 +159,8 @@ public class CamelEndpointMapping extend return qName != null ? qName.toString() : null; } - private String getXPathResult(MessageContext messageContext, XPathExpression expression) throws TransformerException, XMLStreamException, ParserConfigurationException, IOException, SAXException { + private String getXPathResult(MessageContext messageContext, XPathExpression expression) throws TransformerException, XMLStreamException, ParserConfigurationException, + IOException, SAXException { if (expression != null) { Node domNode = xmlConverter.toDOMNode(messageContext.getRequest().getPayloadSource()); if (domNode != null) { @@ -163,8 +172,8 @@ public class CamelEndpointMapping extend /** * Used by Camel Spring Web Services endpoint to register consumers - * - * @param key unique consumer key + * + * @param key unique consumer key * @param endpoint consumer */ public void addConsumer(EndpointMappingKey key, MessageEndpoint endpoint) { @@ -173,7 +182,7 @@ public class CamelEndpointMapping extend /** * Used by Camel Spring Web Services endpoint to unregister consumers - * + * * @param key unique consumer key */ public void removeConsumer(Object key) { @@ -182,7 +191,7 @@ public class CamelEndpointMapping extend /** * Gets the configured TransformerFactory - * + * * @return instance of TransformerFactory */ public TransformerFactory getTransformerFactory() { @@ -191,7 +200,7 @@ public class CamelEndpointMapping extend /** * Optional setter to override default TransformerFactory - * + * * @param transformerFactory non-default TransformerFactory */ public void setTransformerFactory(TransformerFactory transformerFactory) { @@ -206,4 +215,31 @@ public class CamelEndpointMapping extend transformerFactory = TransformerFactory.newInstance(); } } + + /** + * @see {@link AbstractAddressingEndpointMapping} + * @param actorOrRole + */ + public final void setActorOrRole(String actorOrRole) { + Assert.notNull(actorOrRole, "actorOrRole must not be null"); + actorsOrRoles = new String[] {actorOrRole}; + } + + /** + * @see {@link AbstractAddressingEndpointMapping} + * @param actorsOrRoles + */ + public final void setActorsOrRoles(String[] actorsOrRoles) { + Assert.notEmpty(actorsOrRoles, "actorsOrRoles must not be empty"); + this.actorsOrRoles = actorsOrRoles; + } + + /** + * @see {@link AbstractAddressingEndpointMapping} + * @param ultimateReceiver + */ + public final void setUltimateReceiver(boolean ultimateReceiver) { + this.isUltimateReceiver = ultimateReceiver; + } + } Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelSpringWSEndpointMapping.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelSpringWSEndpointMapping.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelSpringWSEndpointMapping.java (added) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelSpringWSEndpointMapping.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,45 @@ +/** + * 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 org.apache.camel.component.spring.ws.type.EndpointMappingKey; +import org.springframework.ws.server.EndpointMapping; +import org.springframework.ws.server.endpoint.MessageEndpoint; + +/** + * Allows to register different spring-ws endpoints for camel. + * + * @author azachar + */ +public interface CamelSpringWSEndpointMapping extends EndpointMapping { + + /** + * Used by Camel Spring Web Services endpoint to register consumers + * + * @param key unique consumer key + * @param endpoint consumer + */ + void addConsumer(EndpointMappingKey key, MessageEndpoint endpoint); + + /** + * Used by Camel Spring Web Services endpoint to unregister consumers + * + * @param key unique consumer key + */ + void removeConsumer(Object key); + +} Added: 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=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java (added) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/WSACamelEndpointMapping.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,270 @@ +/** + * 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.net.URI; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.spring.ws.SpringWebserviceConsumer; +import org.apache.camel.component.spring.ws.SpringWebserviceEndpoint; +import org.apache.camel.component.spring.ws.type.EndpointMappingKey; +import org.slf4j.Logger; +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.server.AbstractAddressingEndpointMapping; +import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping; +import org.springframework.ws.transport.WebServiceConnection; +import org.springframework.ws.transport.WebServiceMessageSender; + +/** + * Provides support for full WS-Addressing. Supported are faultAction and + * response action. For more details look at @see + * {@link AbstractAddressingEndpointMapping}. Implementation of the + * {@link org.springframework.ws.server.EndpointMapping} consumer interface that + * uses the camel uri to map to a WS-Addressing {@code Action} header. + *

+ */ +public class WSACamelEndpointMapping extends AbstractAddressingEndpointMapping implements CamelSpringWSEndpointMapping { + + private static final Logger LOG = LoggerFactory.getLogger(WSACamelEndpointMapping.class); + + private Map endpoints = new ConcurrentHashMap(); + + private String outputActionSuffix = AnnotationActionEndpointMapping.DEFAULT_OUTPUT_ACTION_SUFFIX; + + private String faultActionSuffix = AnnotationActionEndpointMapping.DEFAULT_OUTPUT_ACTION_SUFFIX; + + @Override + protected Object getEndpointInternal(MessageAddressingProperties map) { + + for (EndpointMappingKey key : endpoints.keySet()) { + String compositeOrSimpleKey = null; + String simpleKey = null; + switch (key.getType()) { + case ACTION: + compositeOrSimpleKey = getActionCompositeLookupKey(map); + if (map.getAction() != null) { + simpleKey = map.getAction().toString(); + } + break; + case TO: + compositeOrSimpleKey = getToCompositeLookupKey(map); + if (map.getTo() != null) { + simpleKey = map.getTo().toString(); + } + break; + default: + throw new RuntimeCamelException( + "Invalid mapping type specified. Supported types are: spring-ws:action:(optional:?\n)" + + "spring-ws:to:(optional:?)"); + } + // lookup for specific endpoint + if (compositeOrSimpleKey != null && key.getLookupKey().equals(compositeOrSimpleKey)) { + LOG.debug("Found mapping for key" + key); + return endpoints.get(key); + } + // look up for less specific endpoint + if (simpleKey != null && key.getLookupKey().equals(simpleKey)) { + LOG.debug("Found mapping for key" + key); + return endpoints.get(key); + } + } + return null; + } + + /** + * Generate a lookupKey for a given WS-Addressing message using action + * property. The possible combination are: + *

    + *
  • wsaAction
  • + *
  • wsaAction:wsaGetTo
  • + *
+ * + * @param map + * @return + */ + protected String getActionCompositeLookupKey(MessageAddressingProperties map) { + String key = ""; + if (map.getAction() != null) { + key = map.getAction().toString(); + } + if (map.getTo() != null) { + if (!key.isEmpty()) { + key += ":"; + } + key += map.getTo().toString(); + } + return key; + } + + /** + * Generate a lookupKey for a given WS-Addressing message using getTo + * property. The possible combination are: + *
    + *
  • wsaGetTo
  • + *
  • wsaGetTo:wsaAction
  • + *
+ * + * @param map + * @return + */ + protected String getToCompositeLookupKey(MessageAddressingProperties map) { + String key = ""; + if (map.getTo() != null) { + key = map.getTo().toString(); + } + if (map.getAction() != null) { + if (!key.isEmpty()) { + key += ":"; + } + key += map.getAction().toString(); + } + return key; + } + + /** + * Return output camel uri param or default action or null + */ + @Override + protected URI getResponseAction(Object endpoint, MessageAddressingProperties requestMap) { + SpringWebserviceEndpoint camelEndpoint = getSpringWebserviceEndpoint(endpoint); + + URI actionUri = camelEndpoint.getConfiguration().getOutputAction(); + if (actionUri == null) { + actionUri = getDefaultResponseAction(camelEndpoint, requestMap); + } + return actionUri; + } + + /** + * return fault came uri param or default fault action or null + */ + @Override + protected URI getFaultAction(Object endpoint, MessageAddressingProperties requestMap) { + SpringWebserviceEndpoint camelEndpoint = getSpringWebserviceEndpoint(endpoint); + + URI actionUri = camelEndpoint.getConfiguration().getFaultAction(); + if (actionUri == null) { + actionUri = getDefaultFaultAction(camelEndpoint, requestMap); + } + return actionUri; + + } + + private SpringWebserviceEndpoint getSpringWebserviceEndpoint(Object endpoint) { + Assert.isInstanceOf(SpringWebserviceConsumer.class, endpoint, "Endpoint needs to be an instance of SpringWebserviceConsumer"); + + SpringWebserviceConsumer springWebserviceConsumer = (SpringWebserviceConsumer)endpoint; + return (SpringWebserviceEndpoint)springWebserviceConsumer.getEndpoint(); + } + + + + protected URI getDefaultResponseAction(Object endpoint, MessageAddressingProperties requestMap) { + URI requestAction = requestMap.getAction(); + if (requestAction != null) { + return URI.create(requestAction.toString() + getOutputActionSuffix()); + } else { + return null; + } + } + + protected URI getDefaultFaultAction(Object endpoint, MessageAddressingProperties requestMap) { + URI requestAction = requestMap.getAction(); + if (requestAction != null) { + return URI.create(requestAction.toString() + getFaultActionSuffix()); + } else { + return null; + } + } + + /* + * (non-Javadoc) + * @see + * org.apache.camel.component.spring.ws.bean.CamelSpringWSEndpoint#addConsumer + * (org.apache.camel.component.spring.ws.type.EndpointMappingKey, + * org.springframework.ws.server.endpoint.MessageEndpoint) + */ + public void addConsumer(EndpointMappingKey key, MessageEndpoint endpoint) { + endpoints.put(key, endpoint); + } + + /* + * (non-Javadoc) + * @see org.apache.camel.component.spring.ws.bean.CamelSpringWSEndpoint# + * removeConsumer(java.lang.Object) + */ + public void removeConsumer(Object key) { + endpoints.remove(key); + } + + /** + * Sets the single message sender used for sending messages. + *

+ * 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}); + } + + /** + * Returns the suffix to add to request Actions for reply + * messages. + */ + public String getOutputActionSuffix() { + return outputActionSuffix; + } + + /** + * Sets the suffix to add to request Actions for reply + * messages. + * + * @see #DEFAULT_OUTPUT_ACTION_SUFFIX + */ + public void setOutputActionSuffix(String outputActionSuffix) { + Assert.hasText(outputActionSuffix, "'outputActionSuffix' must not be empty"); + this.outputActionSuffix = outputActionSuffix; + } + + /** + * Returns the suffix to add to request Actions for reply fault + * messages. + */ + public String getFaultActionSuffix() { + return faultActionSuffix; + } + + /** + * Sets the suffix to add to request Actions for reply fault + * messages. + * + * @see #DEFAULT_FAULT_ACTION_SUFFIX + */ + public void setFaultActionSuffix(String faultActionSuffix) { + Assert.hasText(faultActionSuffix, "'faultActionSuffix' must not be empty"); + this.faultActionSuffix = faultActionSuffix; + } + +} Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java (original) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/filter/impl/BasicMessageFilter.java Thu Dec 6 06:46:10 2012 @@ -105,8 +105,12 @@ public class BasicMessageFilter implemen HashSet headerKeySet = new HashSet(headers.keySet()); headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION.toLowerCase()); - headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION.toLowerCase()); headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI.toLowerCase()); + headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION.toLowerCase()); + headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO.toLowerCase()); + headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO.toLowerCase()); + headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION.toLowerCase()); + headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION.toLowerCase()); headerKeySet.remove(LOWERCASE_BREADCRUMB_ID); Modified: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java (original) +++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java Thu Dec 6 06:46:10 2012 @@ -21,6 +21,8 @@ package org.apache.camel.component.sprin */ public enum EndpointMappingType { ROOT_QNAME("rootqname:"), + ACTION("action:"), + TO("to:"), SOAP_ACTION("soapaction:"), XPATHRESULT("xpathresult:"), URI("uri:"), Added: camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/InMemoryWebServiceMessageSender2.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/InMemoryWebServiceMessageSender2.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/InMemoryWebServiceMessageSender2.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/net/javacrumbs/springws/test/helper/InMemoryWebServiceMessageSender2.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,80 @@ +/** + * 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 net.javacrumbs.springws.test.helper; + +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.transport.WebServiceMessageReceiver; + +/** + * This class allows to spring to set the property webServiceMessageReceiver from + * the bean context. + * We have to use use the package net.javacrumbs.springws.test.helper to get it work + * + */ +public class InMemoryWebServiceMessageSender2 extends InMemoryWebServiceMessageSender { + + private WebServiceMessageReceiver decorator; + + @Override + public WebServiceMessageReceiver getWebServiceMessageReceiver() { + return super.getWebServiceMessageReceiver(); + } + + @Override + public void setWebServiceMessageReceiver(WebServiceMessageReceiver webServiceMessageReceiver) { + super.setWebServiceMessageReceiver(webServiceMessageReceiver); + } + + public void decorateResponseReceiver() { + final WebServiceMessageReceiver original = getWebServiceMessageReceiver(); + setWebServiceMessageReceiver(new WebServiceMessageReceiver() { + + @Override + public void receive(MessageContext messageContext) throws Exception { + decorator.receive(messageContext); + original.receive(messageContext); + } + }); + } + + /* + * (non-Javadoc) + * @see net.javacrumbs.springws.test.helper.InMemoryWebServiceMessageSender# + * afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() { + super.afterPropertiesSet(); + if (decorator != null) { + decorateResponseReceiver(); + } + } + + /** + * * @return Returns the decorator. + */ + public WebServiceMessageReceiver getDecorator() { + return decorator; + } + + /** + * @param decorator The decorator to set. + */ + public void setDecorator(WebServiceMessageReceiver decorator) { + this.decorator = decorator; + } +} Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java (original) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java Thu Dec 6 06:46:10 2012 @@ -18,9 +18,11 @@ package org.apache.camel.component.sprin import java.io.StringReader; import java.io.StringWriter; + import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.apache.camel.component.spring.ws.utils.TestUtil; import org.apache.camel.test.junit4.CamelSpringTestSupport; import org.junit.Before; import org.junit.Test; @@ -49,7 +51,7 @@ public class ConsumerEndpointMappingByBe StreamResult result = new StreamResult(sw); webServiceTemplate.sendSourceAndReceiveToResult(source, result); assertNotNull(result); - assertEquals(expectedResponse, sw.toString()); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); } @Override Modified: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java?rev=1417747&r1=1417746&r2=1417747&view=diff ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java (original) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java Thu Dec 6 06:46:10 2012 @@ -18,15 +18,20 @@ package org.apache.camel.component.sprin import java.io.StringReader; import java.io.StringWriter; +import java.net.URI; + import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.apache.camel.component.spring.ws.utils.TestUtil; import org.apache.camel.test.junit4.CamelSpringTestSupport; import org.junit.Before; import org.junit.Test; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.version.Addressing10; import org.springframework.ws.soap.client.core.SoapActionCallback; public class ConsumerEndpointMappingResponseHandlingRouteTest extends CamelSpringTestSupport { @@ -52,7 +57,7 @@ public class ConsumerEndpointMappingResp StreamResult result = new StreamResult(sw); webServiceTemplate.sendSourceAndReceiveToResult(source, result); assertNotNull(result); - assertEquals(expectedResponse, sw.toString()); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); } @Test @@ -62,7 +67,7 @@ public class ConsumerEndpointMappingResp StreamResult result = new StreamResult(sw); webServiceTemplate.sendSourceAndReceiveToResult(source, new SoapActionCallback("http://www.webserviceX.NET/GetQuote"), result); assertNotNull(result); - assertEquals(expectedResponse, sw.toString()); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); } @Test @@ -72,7 +77,7 @@ public class ConsumerEndpointMappingResp StreamResult result = new StreamResult(sw); webServiceTemplate.sendSourceAndReceiveToResult("http://localhost/stockquote2", source, result); assertNotNull(result); - assertEquals(expectedResponse, sw.toString()); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); } @Test @@ -82,7 +87,28 @@ public class ConsumerEndpointMappingResp StreamResult result = new StreamResult(sw); webServiceTemplate.sendSourceAndReceiveToResult(source, result); assertNotNull(result); - assertEquals(expectedResponse, sw.toString()); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); + } + + @Test + public void testAction() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuoteNoNamespace)); + StringWriter sw = new StringWriter(); + StreamResult result = new StreamResult(sw); + webServiceTemplate.sendSourceAndReceiveToResult(source, new ActionCallback("http://www.webserviceX.NET/GetQuote"), result); + assertNotNull(result); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); + } + + @Test + public void testTo() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuoteNoNamespace)); + StringWriter sw = new StringWriter(); + StreamResult result = new StreamResult(sw); + webServiceTemplate.sendSourceAndReceiveToResult(source, new ActionCallback(new URI("http://action-does-not-matter-here"), new Addressing10(), new URI("http://url.to")), + result); + assertNotNull(result); + TestUtil.assertEqualsIgnoreNewLinesSymbol(expectedResponse, sw.toString()); } @Override Added: 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=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/AbstractConsumerTests.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,333 @@ +/** + * 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 = "GOOG"; + + 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")); + } + +} Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSAEndpointMappingRouteTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSAEndpointMappingRouteTest.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSAEndpointMappingRouteTest.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSAEndpointMappingRouteTest.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,184 @@ +/** + * 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.net.URI; + +import javax.xml.transform.stream.StreamSource; + +import org.apache.camel.EndpointInject; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.component.spring.ws.utils.TestUtil; +import org.apache.camel.test.junit4.CamelSpringTestSupport; +import org.junit.Before; +import org.junit.Test; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.client.WebServiceIOException; +import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.version.Addressing10; +import org.springframework.ws.soap.client.core.SoapActionCallback; + +public class ConsumerWSAEndpointMappingRouteTest extends CamelSpringTestSupport { + + private final String xmlBody = "GOOG"; + + @EndpointInject(uri = "mock:testDefault") + private MockEndpoint resultEndpointActionDefault; + + @EndpointInject(uri = "mock:testAction") + private MockEndpoint resultEndpointAction; + + @EndpointInject(uri = "mock:testTo") + private MockEndpoint resultEndpointTo; + + @EndpointInject(uri = "mock:testActionAndTo") + private MockEndpoint resultEndpointActionAndTo; + + @EndpointInject(uri = "mock:testToAndAction") + private MockEndpoint resultEndpointToAndAction; + + @EndpointInject(uri = "mock:testToMoreSpecific") + private MockEndpoint resultEndpointToMoreSpecific; + + @EndpointInject(uri = "mock:testActionMoreSpecific") + private MockEndpoint resultEndpointActionMoreSpecific; + + @EndpointInject(uri = "mock:testOutputAndFault") + private MockEndpoint resultOutputAndFault; + + @EndpointInject(uri = "mock:testOutputAndFault2") + private MockEndpoint resultOutputAndFault2; + + @EndpointInject(uri = "mock:testSoapAction") + private MockEndpoint resultSoapAction; + + @EndpointInject(uri = "mock:testReplyTo") + private MockEndpoint resultReplyTo; + + private WebServiceTemplate webServiceTemplate; + + @Before + public void setUp() throws Exception { + super.setUp(); + webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class); + } + + @Test + public void testWSAddressingAction() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback("http://www.stockquotes.edu/myUniqueAction"), TestUtil.NOOP_SOURCE_EXTRACTOR); + // here is localhost as to by default + resultEndpointAction.expectedMinimumMessageCount(1); + resultEndpointAction.assertIsSatisfied(); + } + + @Test + public void testWSAddressingTo() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://www.stockquotes.edu/does-not-matter"), new Addressing10(), + new URI("http://myUniqueToUrl")), TestUtil.NOOP_SOURCE_EXTRACTOR); + + resultEndpointTo.expectedMinimumMessageCount(1); + resultEndpointTo.assertIsSatisfied(); + } + + @Test + public void testWSAddressingActionAndTo() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://actionAndTo"), new Addressing10(), new URI("http://url4.to")), + TestUtil.NOOP_SOURCE_EXTRACTOR); + resultEndpointActionAndTo.expectedMinimumMessageCount(1); + resultEndpointActionAndTo.assertIsSatisfied(); + } + + @Test + public void testWSAddressingToAndAction() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://toAndAction"), new Addressing10(), new URI("http://url3.to")), + TestUtil.NOOP_SOURCE_EXTRACTOR); + + resultEndpointToAndAction.expectedMinimumMessageCount(1); + resultEndpointToAndAction.assertIsSatisfied(); + } + + @Test + public void testWSAddressingResolveToMoreSpecif() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://action1"), new Addressing10(), new URI("http://url1.to")), + TestUtil.NOOP_SOURCE_EXTRACTOR); + + resultEndpointToMoreSpecific.expectedMinimumMessageCount(1); + resultEndpointToMoreSpecific.assertIsSatisfied(); + + resultEndpointActionMoreSpecific.expectedMinimumMessageCount(0); + resultEndpointActionMoreSpecific.assertIsSatisfied(); + } + + @Test + public void testWSAddressingResolveActionMoreSpecif() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://action2"), new Addressing10(), new URI("http://url2.to")), + TestUtil.NOOP_SOURCE_EXTRACTOR); + + resultEndpointToMoreSpecific.expectedMinimumMessageCount(0); + resultEndpointToMoreSpecific.assertIsSatisfied(); + + resultEndpointActionMoreSpecific.expectedMinimumMessageCount(1); + resultEndpointActionMoreSpecific.assertIsSatisfied(); + } + + @Test + public void testWSAddressingActionResponseActions() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback("http://www.stockquotes.edu/WSAddresingActionReply"), TestUtil.NOOP_SOURCE_EXTRACTOR); + resultOutputAndFault.expectedMinimumMessageCount(1); + resultOutputAndFault.assertIsSatisfied(); + } + + @Test + public void testWSAddressingToResponseActions() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback(new URI("http://doesn-not-matter.com"), new Addressing10(), new URI("http://urlOutputAndFault2.to")), + TestUtil.NOOP_SOURCE_EXTRACTOR); + resultOutputAndFault2.expectedMinimumMessageCount(1); + resultOutputAndFault2.assertIsSatisfied(); + } + + @Test(expected = WebServiceIOException.class) + public void testWrongWSAddressingAction() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new ActionCallback("http://this-is-a-wrong-ws-addressing-action"), TestUtil.NOOP_SOURCE_EXTRACTOR); + resultEndpointAction.assertIsSatisfied(); + } + + @Test + public void testClassicalSoapHttpHeaderInterference() throws Exception { + StreamSource source = new StreamSource(new StringReader(xmlBody)); + webServiceTemplate.sendSourceAndReceive(source, new SoapActionCallback("http://www.stockquotes.edu/soapHttpHeaderAction"), TestUtil.NOOP_SOURCE_EXTRACTOR); + + resultSoapAction.expectedMinimumMessageCount(1); + resultSoapAction.assertIsSatisfied(); + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/component/spring/ws/addresing/ConsumerWSAEndpointMappingRouteTest-context.xml"}); + } +} Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsActionTests.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsActionTests.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsActionTests.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsActionTests.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,43 @@ +/** + * 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.URISyntaxException; + +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; + +public class ConsumerWSANewChannelParamsActionTests extends AbstractConsumerTests { + + public ActionCallback channelIn(String actionUri) throws URISyntaxException { + // new channel + return actionAndReplyTo(actionUri, "mailto:reply-to-trigger@new-channel.com"); + } + + @Override + public MessageAddressingProperties channelOut() { + return newChannelParams(); + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/component/spring/ws/addresing/ConsumerWSAParamsActionTests-context.xml"}); + } + +} Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsToTests.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsToTests.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsToTests.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSANewChannelParamsToTests.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,43 @@ +/** + * 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.URISyntaxException; + +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; + +public class ConsumerWSANewChannelParamsToTests extends AbstractConsumerTests { + + public ActionCallback channelIn(String actionUri) throws URISyntaxException { + // new channel + return toAndReplyTo(actionUri, "mailto:reply-to-trigger@new-channel.com"); + } + + @Override + public MessageAddressingProperties channelOut() { + return newChannelParams(); + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/component/spring/ws/addresing/ConsumerWSAParamsTOTests-context.xml"}); + } + +} Added: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsActionTests.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsActionTests.java?rev=1417747&view=auto ============================================================================== --- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsActionTests.java (added) +++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/addressing/ConsumerWSASameChannelParamsActionTests.java Thu Dec 6 06:46:10 2012 @@ -0,0 +1,43 @@ +/** + * 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.URISyntaxException; + +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.soap.addressing.client.ActionCallback; +import org.springframework.ws.soap.addressing.core.MessageAddressingProperties; + +public class ConsumerWSASameChannelParamsActionTests extends AbstractConsumerTests { + + public ActionCallback channelIn(String actionUri) throws URISyntaxException { + // same channel + return action(actionUri); + } + + @Override + MessageAddressingProperties channelOut() { + return sameChannelParams(); + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext(new String[] {"org/apache/camel/component/spring/ws/addresing/ConsumerWSAParamsActionTests-context.xml"}); + } + +}