You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/11/04 08:15:30 UTC
svn commit: r1030847 [1/2] - in /camel/trunk: apache-camel/
apache-camel/src/main/descriptors/ components/
components/camel-spring-integration/ components/camel-spring-javaconfig/
components/camel-spring-ws/ components/camel-spring-ws/src/ components/c...
Author: davsclaus
Date: Thu Nov 4 07:15:27 2010
New Revision: 1030847
URL: http://svn.apache.org/viewvc?rev=1030847&view=rev
Log:
CAMEL-3105: New camel-spring-ws component. Thanks to Richard Kettelerij for the contribution.
Added:
camel/trunk/components/camel-spring-ws/
camel/trunk/components/camel-spring-ws/pom.xml (with props)
camel/trunk/components/camel-spring-ws/src/
camel/trunk/components/camel-spring-ws/src/main/
camel/trunk/components/camel-spring-ws/src/main/java/
camel/trunk/components/camel-spring-ws/src/main/java/org/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java (with props)
camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java (with props)
camel/trunk/components/camel-spring-ws/src/main/resources/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/
camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/springws
camel/trunk/components/camel-spring-ws/src/test/
camel/trunk/components/camel-spring-ws/src/test/java/
camel/trunk/components/camel-spring-ws/src/test/java/org/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerLocalRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/StockQuoteResponseProcessor.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/jaxb/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/jaxb/QuoteRequest.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/jaxb/QuoteResponse.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/jaxb/package-info.java (with props)
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/
camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/util/FileUtil.java (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/
camel/trunk/components/camel-spring-ws/src/test/resources/log4j.properties (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ConsumerEndpointMappingResponseHandlingRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ConsumerEndpointMappingRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ConsumerMarshallingRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerLocalRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/ProducerRemoteRouteTest-context.xml (with props)
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/jaxb/
camel/trunk/components/camel-spring-ws/src/test/resources/org/apache/camel/component/spring/ws/jaxb/jaxb.index
camel/trunk/components/camel-spring-ws/src/test/resources/stockquote-response.xml (with props)
Modified:
camel/trunk/apache-camel/pom.xml
camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
camel/trunk/components/camel-spring-integration/pom.xml
camel/trunk/components/camel-spring-javaconfig/pom.xml
camel/trunk/components/pom.xml
camel/trunk/parent/pom.xml
Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1030847&r1=1030846&r2=1030847&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Thu Nov 4 07:15:27 2010
@@ -342,6 +342,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-ws</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-sql</artifactId>
</dependency>
<dependency>
Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1030847&r1=1030846&r2=1030847&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Thu Nov 4 07:15:27 2010
@@ -106,6 +106,7 @@
<include>org.apache.camel:camel-spring-integration</include>
<include>org.apache.camel:camel-spring-javaconfig</include>
<include>org.apache.camel:camel-spring-security</include>
+ <include>org.apache.camel:camel-spring-ws</include>
<include>org.apache.camel:camel-sql</include>
<include>org.apache.camel:camel-stream</include>
<include>org.apache.camel:camel-stringtemplate</include>
Modified: camel/trunk/components/camel-spring-integration/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-integration/pom.xml?rev=1030847&r1=1030846&r2=1030847&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-integration/pom.xml (original)
+++ camel/trunk/components/camel-spring-integration/pom.xml Thu Nov 4 07:15:27 2010
@@ -38,12 +38,6 @@
<repositories>
<repository>
- <id>spring.maven.milestone</id>
- <name>Spring Milestone Maven Repo</name>
- <url>http://repository.springsource.com/maven/bundles/milestone</url>
- </repository>
-
- <repository>
<id>spring.maven.release</id>
<name>Spring Release Maven Repo</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
Modified: camel/trunk/components/camel-spring-javaconfig/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-javaconfig/pom.xml?rev=1030847&r1=1030846&r2=1030847&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-javaconfig/pom.xml (original)
+++ camel/trunk/components/camel-spring-javaconfig/pom.xml Thu Nov 4 07:15:27 2010
@@ -39,7 +39,7 @@
org.springframework.*;version="[3,4)",
*
</camel.osgi.import>
- <spring-version>3.0.3.RELEASE</spring-version>
+ <spring-version>3.0.5.RELEASE</spring-version>
<junit-version>4.8.1</junit-version>
</properties>
Added: camel/trunk/components/camel-spring-ws/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/pom.xml?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/pom.xml (added)
+++ camel/trunk/components/camel-spring-ws/pom.xml Thu Nov 4 07:15:27 2010
@@ -0,0 +1,130 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.6-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-spring-ws</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Spring Web Services</name>
+ <description>Camel support for Spring Web Services</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.spring.ws.*</camel.osgi.export.pkg>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>spring.maven.release</id>
+ <name>Spring Release Maven Repo</name>
+ <url>http://repository.springsource.com/maven/bundles/release</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-core</artifactId>
+ <version>${spring-ws-version}</version>
+ <!-- spring-webmvc is only used by Spring 2.5 -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-support</artifactId>
+ <version>${spring-ws-version}</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jaxb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.javacrumbs</groupId>
+ <artifactId>spring-ws-test</artifactId>
+ <version>0.19</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>spring-2.x</id>
+ <dependencies>
+ <!-- need spring-webmvc when using Spring 2.x -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${spring-version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+</project>
Propchange: camel/trunk/components/camel-spring-ws/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-spring-ws/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,155 @@
+/**
+ * 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;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import javax.xml.transform.TransformerFactory;
+
+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.type.EndpointMappingKey;
+import org.apache.camel.component.spring.ws.type.EndpointMappingType;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.CamelContextHelper;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.ws.WebServiceMessageFactory;
+import org.springframework.ws.client.core.WebServiceTemplate;
+import org.springframework.ws.transport.WebServiceMessageSender;
+import org.springframework.xml.xpath.XPathExpression;
+import org.springframework.xml.xpath.XPathExpressionFactory;
+
+/**
+ * Apache Camel component for working with Spring Web Services (a.k.a Spring-WS).
+ */
+public class SpringWebserviceComponent extends DefaultComponent {
+ private static final Log LOG = LogFactory.getLog(SpringWebserviceComponent.class);
+
+ public SpringWebserviceComponent() {
+ super();
+ }
+
+ public SpringWebserviceComponent(CamelContext context) {
+ super(context);
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ SpringWebserviceConfiguration configuration = new SpringWebserviceConfiguration();
+ addConsumerConfiguration(remaining, parameters, configuration);
+ addProducerConfiguration(remaining, parameters, configuration);
+ addXmlConverterToConfiguration(parameters, configuration);
+ setProperties(configuration, parameters);
+ return new SpringWebserviceEndpoint(this, configuration);
+ }
+
+ private void addConsumerConfiguration(String remaining, Map<String, Object> parameters,
+ SpringWebserviceConfiguration configuration) {
+ EndpointMappingType type = EndpointMappingType.getTypeFromUriPrefix(remaining);
+ if (type != null) {
+ LOG.debug("Building Spring Web Services consumer of type " + type);
+ String lookupKey = getLookupKey(remaining, type);
+ if (EndpointMappingType.BEANNAME.equals(type)) {
+ addEndpointDispatcherToConfiguration(configuration, lookupKey);
+ } else {
+ addEndpointMappingToConfiguration(parameters, configuration);
+ }
+ if (EndpointMappingType.XPATHRESULT.equals(type)) {
+ XPathExpression expression = getXPathExpressionFromParameters(parameters);
+ configuration.setEndpointMappingKey(new EndpointMappingKey(type, lookupKey, expression));
+ } else {
+ configuration.setEndpointMappingKey(new EndpointMappingKey(type, lookupKey, null));
+ }
+ }
+ }
+
+ private void addProducerConfiguration(String remaining, Map<String, Object> 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));
+
+ // Obtain a WebServiceTemplate from the registry when specified by
+ // an option on the component, else create a new template with
+ // Spring-WS defaults
+ WebServiceTemplate webServiceTemplate = resolveAndRemoveReferenceParameter(parameters,
+ "webServiceTemplate", WebServiceTemplate.class, new WebServiceTemplate());
+ WebServiceMessageSender messageSender = resolveAndRemoveReferenceParameter(parameters,
+ "messageSender", WebServiceMessageSender.class, null);
+ WebServiceMessageFactory messageFactory = resolveAndRemoveReferenceParameter(parameters,
+ "messageFactory", WebServiceMessageFactory.class, null);
+
+ if (webServiceTemplate.getDefaultUri() == null) {
+ webServiceTemplate.setDefaultUri(webServiceEndpointUri.toString());
+ }
+ if (messageSender != null) {
+ webServiceTemplate.setMessageSender(messageSender);
+ }
+ if (messageFactory != null) {
+ webServiceTemplate.setMessageFactory(messageFactory);
+ }
+ configuration.setWebServiceTemplate(webServiceTemplate);
+ }
+ }
+
+ private String getLookupKey(String remaining, EndpointMappingType type) {
+ String lookupKey = remaining.substring(type.getPrefix().length());
+ return lookupKey.startsWith("//") ? lookupKey.substring(2) : lookupKey;
+ }
+
+ private XPathExpression getXPathExpressionFromParameters(Map<String, Object> parameters) {
+ String xpathExpression = getAndRemoveParameter(parameters, "expression", String.class);
+ if (xpathExpression == null) {
+ throw new RuntimeCamelException("Expression parameter is required when using XPath endpoint mapping");
+ }
+ XPathExpression expression = XPathExpressionFactory.createXPathExpression(xpathExpression);
+ return expression;
+ }
+
+ private void addEndpointMappingToConfiguration(Map<String, Object> parameters,
+ SpringWebserviceConfiguration configuration) {
+ // Obtain generic CamelEndpointMapping from registry
+ CamelEndpointMapping endpointMapping = resolveAndRemoveReferenceParameter(parameters, "endpointMapping", CamelEndpointMapping.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 'springws:beanname:' URI scheme is used)");
+ }
+ configuration.setEndpointMapping(endpointMapping);
+ }
+
+ private void addEndpointDispatcherToConfiguration(SpringWebserviceConfiguration configuration, String lookupKey) {
+ // Obtain CamelEndpointDispatcher with the given name from registry
+ CamelEndpointDispatcher endpoint = CamelContextHelper.mandatoryLookup(getCamelContext(), lookupKey, CamelEndpointDispatcher.class);
+ configuration.setEndpointDispatcher(endpoint);
+ }
+
+ private void addXmlConverterToConfiguration(Map<String, Object> parameters, SpringWebserviceConfiguration configuration) {
+ XmlConverter xmlConverter = new XmlConverter();
+ TransformerFactory transformerFactory = resolveAndRemoveReferenceParameter(parameters, "transformerFactory", TransformerFactory.class, null);
+ if (transformerFactory != null) {
+ xmlConverter.setTransformerFactory(transformerFactory);
+ }
+ configuration.setXmlConverter(xmlConverter);
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,111 @@
+/**
+ * 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;
+
+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.type.EndpointMappingKey;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.springframework.ws.client.core.WebServiceTemplate;
+
+public class SpringWebserviceConfiguration {
+
+ /* Producer configuration */
+ private WebServiceTemplate webServiceTemplate;
+ private String soapAction;
+ private URI wsAddressingAction;
+
+ /* Consumer configuration */
+ private CamelEndpointMapping endpointMapping;
+ private CamelEndpointDispatcher endpointDispatcher;
+ private EndpointMappingKey endpointMappingKey;
+
+ private XmlConverter xmlConverter;
+
+ public WebServiceTemplate getWebServiceTemplate() {
+ return webServiceTemplate;
+ }
+
+ public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
+ this.webServiceTemplate = webServiceTemplate;
+ }
+
+ public String getSoapAction() {
+ return soapAction;
+ }
+
+ public void setSoapAction(String soapAction) {
+ this.soapAction = soapAction;
+ }
+
+ public String getEndpointUri() {
+ if (endpointMappingKey != null) {
+ // only for consumers, use lookup key as endpoint uri/key
+ return endpointMappingKey.getLookupKey();
+ } else if (webServiceTemplate != null) {
+ return webServiceTemplate.getDefaultUri();
+ }
+ return null;
+ }
+
+ public URI getWsAddressingAction() {
+ return wsAddressingAction;
+ }
+
+ public void setWsAddressingAction(URI wsAddressingAction) {
+ this.wsAddressingAction = wsAddressingAction;
+ }
+
+ public void setWsAddressingAction(String wsAddressingAction) throws URISyntaxException {
+ this.wsAddressingAction = new URI(wsAddressingAction);
+ }
+
+ public CamelEndpointMapping getEndpointMapping() {
+ return endpointMapping;
+ }
+
+ public void setEndpointMapping(CamelEndpointMapping endpointMapping) {
+ this.endpointMapping = endpointMapping;
+ }
+
+ public EndpointMappingKey getEndpointMappingKey() {
+ return endpointMappingKey;
+ }
+
+ public void setEndpointMappingKey(EndpointMappingKey endpointMappingKey) {
+ this.endpointMappingKey = endpointMappingKey;
+ }
+
+ public CamelEndpointDispatcher getEndpointDispatcher() {
+ return endpointDispatcher;
+ }
+
+ public void setEndpointDispatcher(CamelEndpointDispatcher endpointDispatcher) {
+ this.endpointDispatcher = endpointDispatcher;
+ }
+
+ public XmlConverter getXmlConverter() {
+ return xmlConverter;
+ }
+
+ public void setXmlConverter(XmlConverter xmlConverter) {
+ this.xmlConverter = xmlConverter;
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,28 @@
+/**
+ * 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;
+
+public final class SpringWebserviceConstants {
+
+ /* Producer constants */
+ 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";
+
+ private SpringWebserviceConstants() {
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConstants.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,134 @@
+/**
+ * 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;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.impl.DefaultExchange;
+import org.springframework.ws.WebServiceMessage;
+import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.server.endpoint.MessageEndpoint;
+import org.springframework.ws.soap.SoapHeader;
+import org.springframework.ws.soap.SoapHeaderElement;
+import org.springframework.ws.soap.SoapMessage;
+
+public class SpringWebserviceConsumer extends DefaultConsumer implements MessageEndpoint {
+
+ private SpringWebserviceEndpoint endpoint;
+ private SpringWebserviceConfiguration configuration;
+
+ public SpringWebserviceConsumer(Endpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ this.endpoint = (SpringWebserviceEndpoint) endpoint;
+ this.configuration = this.endpoint.getConfiguration();
+ }
+
+ /**
+ * Invoked by Spring-WS when a {@link WebServiceMessage} is received
+ */
+ public void invoke(MessageContext messageContext) throws Exception {
+ Exchange exchange = new DefaultExchange(endpoint.getCamelContext(), ExchangePattern.InOptionalOut);
+ populateExchangeFromMessageContext(messageContext, exchange);
+
+ // start message processing
+ getProcessor().process(exchange);
+
+ // create webservice response from output body
+ if (exchange.getPattern().isOutCapable()) {
+ Message responseMessage = exchange.getOut(Message.class);
+ if (responseMessage != null) {
+ Source responseBody = responseMessage.getBody(Source.class);
+ WebServiceMessage response = messageContext.getResponse();
+ XmlConverter xmlConverter = configuration.getXmlConverter();
+ xmlConverter.toResult(responseBody, response.getPayloadResult());
+ }
+ }
+ }
+
+ private void populateExchangeFromMessageContext(MessageContext messageContext, Exchange exchange) {
+ populateExchangeWithPropertiesFromMessageContext(messageContext, exchange);
+
+ // create inbound message
+ WebServiceMessage request = messageContext.getRequest();
+ SpringWebserviceMessage inMessage = new SpringWebserviceMessage(request);
+ inMessage.setHeaders(extractSoapHeadersFromWebServiceMessage(request));
+ exchange.setIn(inMessage);
+ }
+
+ private void populateExchangeWithPropertiesFromMessageContext(MessageContext messageContext, Exchange exchange) {
+ // convert WebserviceMessage properties (added through interceptors) to
+ // Camel exchange properties
+ String[] propertyNames = messageContext.getPropertyNames();
+ if (propertyNames != null) {
+ for (String propertyName : propertyNames) {
+ exchange.setProperty(propertyName, messageContext.getProperty(propertyName));
+ }
+ }
+ }
+
+ private Map<String, Object> extractSoapHeadersFromWebServiceMessage(WebServiceMessage request) {
+ Map<String, Object> headers = new HashMap<String, Object>();
+ if (request instanceof SoapMessage) {
+ SoapMessage soapMessage = (SoapMessage) request;
+ SoapHeader soapHeader = soapMessage.getSoapHeader();
+ if (soapHeader != null) {
+ Iterator<?> attibutesIterator = soapHeader.getAllAttributes();
+ while (attibutesIterator.hasNext()) {
+ QName name = (QName) attibutesIterator.next();
+ headers.put(name.toString(), soapHeader.getAttributeValue(name));
+ }
+ Iterator<?> elementIter = soapHeader.examineAllHeaderElements();
+ while (elementIter.hasNext()) {
+ Object element = elementIter.next();
+ if (element instanceof SoapHeaderElement) {
+ QName name = ((SoapHeaderElement) element).getName();
+ headers.put(name.toString(), element);
+ }
+ }
+ }
+ }
+ return headers;
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (configuration.getEndpointMapping() != null) {
+ configuration.getEndpointMapping().removeConsumer(configuration.getEndpointMappingKey());
+ }
+ super.doStop();
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ if (configuration.getEndpointMapping() != null) {
+ configuration.getEndpointMapping().addConsumer(configuration.getEndpointMappingKey(), this);
+ }
+ super.doStart();
+ }
+
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,54 @@
+/**
+ * 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;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+public class SpringWebserviceEndpoint extends DefaultEndpoint {
+
+ private SpringWebserviceConfiguration configuration;
+
+ public SpringWebserviceEndpoint(Component component, SpringWebserviceConfiguration configuration) {
+ super(configuration.getEndpointUri(), component);
+ this.configuration = configuration;
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ SpringWebserviceConsumer consumer = new SpringWebserviceConsumer(this, processor);
+ if (configuration.getEndpointDispatcher() != null) {
+ configuration.getEndpointDispatcher().setConsumerMessageEndpoint(consumer);
+ }
+ return consumer;
+ }
+
+ public Producer createProducer() throws Exception {
+ return new SpringWebserviceProducer(this);
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public SpringWebserviceConfiguration getConfiguration() {
+ return configuration;
+ }
+
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceEndpoint.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,50 @@
+/**
+ * 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;
+
+import org.apache.camel.impl.DefaultMessage;
+import org.springframework.ws.WebServiceMessage;
+
+public class SpringWebserviceMessage extends DefaultMessage {
+ private WebServiceMessage webServiceMessage;
+
+ public SpringWebserviceMessage(WebServiceMessage webServiceMessage) {
+ super();
+ this.webServiceMessage = webServiceMessage;
+ }
+
+ @Override
+ protected Object createBody() {
+ if (webServiceMessage != null) {
+ return webServiceMessage.getPayloadSource();
+ }
+ return null;
+ }
+
+ public WebServiceMessage getWebServiceMessage() {
+ return webServiceMessage;
+ }
+
+ public void setWebServiceMessage(WebServiceMessage webServiceMessage) {
+ this.webServiceMessage = webServiceMessage;
+ }
+
+ @Override
+ public String toString() {
+ return "SpringWebserviceMessage[" + webServiceMessage + "]";
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceMessage.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,98 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.net.URI;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.impl.DefaultProducer;
+import org.springframework.ws.WebServiceMessage;
+import org.springframework.ws.client.core.SourceExtractor;
+import org.springframework.ws.client.core.WebServiceMessageCallback;
+import org.springframework.ws.soap.addressing.client.ActionCallback;
+import org.springframework.ws.soap.client.core.SoapActionCallback;
+
+public class SpringWebserviceProducer extends DefaultProducer {
+
+ private static final SourceExtractor SOURCE_EXTRACTOR = new NoopSourceExtractor();
+ private SpringWebserviceEndpoint endpoint;
+
+ public SpringWebserviceProducer(Endpoint endpoint) {
+ super(endpoint);
+ this.endpoint = (SpringWebserviceEndpoint) endpoint;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ // Let Camel TypeConverter hierarchy handle the conversion of XML messages to Source objects
+ 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);
+
+ WebServiceMessageCallback callback = new DefaultWebserviceMessageCallback(soapAction, wsAddressingAction);
+ Object body = null;
+ if (endpointUri != null) {
+ body = endpoint.getConfiguration().getWebServiceTemplate().sendSourceAndReceive(endpointUri, sourcePayload, callback, SOURCE_EXTRACTOR);
+ } else {
+ body = endpoint.getConfiguration().getWebServiceTemplate().sendSourceAndReceive(sourcePayload, callback, SOURCE_EXTRACTOR);
+ }
+ exchange.getOut().setBody(body);
+ }
+
+ protected class DefaultWebserviceMessageCallback implements WebServiceMessageCallback {
+ private String soapActionHeader;
+ private URI wsAddressingActionHeader;
+
+ public DefaultWebserviceMessageCallback(String soapAction, URI wsAddressingAction) {
+ this.soapActionHeader = soapAction;
+ this.wsAddressingActionHeader = wsAddressingAction;
+ }
+
+ public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
+ // Add SoapAction to webservice request. Note that exchange header
+ // takes precedence over endpoint option
+ String soapAction = soapActionHeader != null ? soapActionHeader : endpoint.getConfiguration().getSoapAction();
+ if (soapAction != null) {
+ new SoapActionCallback(soapAction).doWithMessage(message);
+ }
+ // Add WS-Addressing Action to webservice request (the WS-Addressing
+ // 'to' header will default to the URL of the connection).
+ // Note that exchange header takes precedence over endpoint option
+ URI wsAddressingAction = wsAddressingActionHeader != null ? wsAddressingActionHeader : endpoint.getConfiguration().getWsAddressingAction();
+ if (wsAddressingAction != null) {
+ new ActionCallback(wsAddressingAction).doWithMessage(message);
+ }
+ }
+ }
+
+ /**
+ * A {@link SourceExtractor} that performs no conversion, instead conversion
+ * is handled by Camel's {@link TypeConverter} hierarchy.
+ */
+ private static class NoopSourceExtractor implements SourceExtractor {
+ public Object extractData(Source source) throws IOException, TransformerException {
+ return source;
+ }
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/SpringWebserviceProducer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.springframework.util.Assert;
+import org.springframework.ws.context.MessageContext;
+import org.springframework.ws.server.endpoint.MessageEndpoint;
+import org.springframework.ws.server.endpoint.mapping.AbstractMapBasedEndpointMapping;
+
+/**
+ * Spring {@link MessageEndpoint} for dispatching messages received by Spring-WS to a Camel
+ * endpoint. This class needs to be registered in the Spring <tt>ApplicationContext</tt>
+ * when consuming messages using the <tt>springws:beanname:</tt> URI scheme.
+ * <p/>
+ * For example, when using a route such as <tt>from("springws:beanname:stockQuote").to("...");</tt>
+ * the following bean definition needs to be present in the <tt>ApplicationContext</tt>:
+ * <p/>
+ * {@code
+ * <bean id="stockQuote" class="org.apache.camel.component.spring.ws.bean.CamelEndpointDispatcher" />
+ * }
+ *
+ * @see AbstractMapBasedEndpointMapping#setMappings(java.util.Properties)
+ * @see AbstractMapBasedEndpointMapping#setEndpointMap(java.util.Map)
+ */
+public class CamelEndpointDispatcher implements MessageEndpoint {
+
+ private MessageEndpoint consumerMessageEndpoint;
+
+ public void invoke(MessageContext messageContext) throws Exception {
+ Assert.notNull(consumerMessageEndpoint);
+ consumerMessageEndpoint.invoke(messageContext);
+ }
+
+ public MessageEndpoint getConsumerMessageEndpoint() {
+ return consumerMessageEndpoint;
+ }
+
+ public void setConsumerMessageEndpoint(MessageEndpoint consumer) {
+ this.consumerMessageEndpoint = consumer;
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointDispatcher.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,209 @@
+/**
+ * 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.URISyntaxException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.spring.ws.type.EndpointMappingKey;
+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.StringUtils;
+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.server.endpoint.MessageEndpoint;
+import org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping;
+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.transport.WebServiceConnection;
+import org.springframework.ws.transport.context.TransportContext;
+import org.springframework.ws.transport.context.TransportContextHolder;
+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 <tt>ApplicationContext</tt> when
+ * consuming messages using any of the following URI schemes:
+ * <p/>
+ * <ul>
+ * <li><tt>springws:rootqname:</tt><br/>
+ * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping}
+ * <p/>
+ * <li><tt>springws:soapaction:</tt><br/>
+ * Equivalent to endpoint mappings specified through {@link org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping}
+ * <p/>
+ * <li><tt>springws:uri:</tt><br/>
+ * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.UriEndpointMapping}
+ * <p/>
+ * <li><tt>springws:xpathresult:</tt><br/>
+ * Equivalent to endpoint mappings specified through {@link org.springframework.ws.server.endpoint.mapping.XPathPayloadEndpointMapping}
+ * </ul>
+ *
+ * @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 {
+
+ private static final String DOUBLE_QUOTE = "\"";
+ private Map<EndpointMappingKey, MessageEndpoint> endpoints = new ConcurrentHashMap<EndpointMappingKey, MessageEndpoint>();
+ private TransformerFactory transformerFactory;
+ private XmlConverter xmlConverter;
+
+ @Override
+ protected Object getEndpointInternal(MessageContext messageContext) throws Exception {
+ for (EndpointMappingKey key : endpoints.keySet()) {
+ Object messageKey = null;
+ switch (key.getType()) {
+ case ROOT_QNAME:
+ messageKey = getRootQName(messageContext);
+ break;
+ case SOAP_ACTION:
+ messageKey = getSoapAction(messageContext);
+ break;
+ case XPATHRESULT:
+ messageKey = getXPathResult(messageContext, key.getExpression());
+ break;
+ case URI:
+ messageKey = getUri();
+ break;
+ default:
+ throw new RuntimeCamelException("Invalid mapping type specified. Supported types are: root QName, SOAP action, XPath expression and URI");
+ }
+ if (messageKey != null && key.getLookupKey().equals(messageKey)) {
+ return endpoints.get(key);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext, Object endpoint, EndpointInterceptor[] interceptors) {
+ for (EndpointMappingKey key : endpoints.keySet()) {
+ 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 super.createEndpointInvocationChain(messageContext, endpoint, interceptors);
+ }
+
+ private String getSoapAction(MessageContext messageContext) {
+ if (messageContext.getRequest() instanceof SoapMessage) {
+ 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);
+ }
+ return soapAction;
+ }
+ return null;
+ }
+
+ private String getUri() throws URISyntaxException {
+ TransportContext transportContext = TransportContextHolder.getTransportContext();
+ if (transportContext != null) {
+ WebServiceConnection webServiceConnection = transportContext.getConnection();
+ if (webServiceConnection != null) {
+ return webServiceConnection.getUri().toString();
+ }
+ }
+ return null;
+ }
+
+ private String getRootQName(MessageContext messageContext) throws TransformerException, XMLStreamException {
+ QName qName = PayloadRootUtils.getPayloadRootQName(messageContext.getRequest().getPayloadSource(), transformerFactory);
+ return qName != null ? qName.toString() : null;
+ }
+
+ 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) {
+ return expression.evaluateAsString(domNode.getFirstChild());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Used by Camel Spring Web Services endpoint to register consumers
+ *
+ * @param key unique consumer key
+ * @param endpoint consumer
+ */
+ public void addConsumer(EndpointMappingKey key, MessageEndpoint endpoint) {
+ endpoints.put(key, endpoint);
+ }
+
+ /**
+ * Used by Camel Spring Web Services endpoint to unregister consumers
+ *
+ * @param key unique consumer key
+ */
+ public void removeConsumer(Object key) {
+ endpoints.remove(key);
+ }
+
+ /**
+ * Gets the configured TransformerFactory
+ *
+ * @return instance of TransformerFactory
+ */
+ public TransformerFactory getTransformerFactory() {
+ return transformerFactory;
+ }
+
+ /**
+ * Optional setter to override default TransformerFactory
+ *
+ * @param transformerFactory non-default TransformerFactory
+ */
+ public void setTransformerFactory(TransformerFactory transformerFactory) {
+ this.transformerFactory = transformerFactory;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ xmlConverter = new XmlConverter();
+ if (transformerFactory != null) {
+ xmlConverter.setTransformerFactory(transformerFactory);
+ } else {
+ transformerFactory = TransformerFactory.newInstance();
+ }
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/bean/CamelEndpointMapping.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.converter;
+
+import org.apache.camel.Converter;
+
+/**
+ * A helper class to transform to and from {@link org.springframework.xml.transform.StringSource} implementations
+ * available in both Camel and Spring Webservices.
+ * <p/>
+ * Rationale: most of the time this converter will not be used since both Camel
+ * and Spring-WS use the {@Source} interface abstraction. There is
+ * however a chance that you may end up with incompatible {@link org.springframework.xml.transform.StringSource}
+ * implementations, this converter handles these (corner)cases.
+ * <p/>
+ * Note that conversion options are limited by Spring's {@link org.springframework.xml.transform.StringSource}
+ * since it's the most simple one. It has just one constructor that accepts a
+ * String as input.
+ */
+@Converter
+public final class StringSourceConverter {
+
+ private StringSourceConverter() {
+ }
+
+ /**
+ * Converts a Spring-WS {@link org.springframework.xml.transform.StringSource}
+ * to a Camel {@link org.apache.camel.converter.jaxp.StringSource}
+ */
+ @Converter
+ public static org.apache.camel.converter.jaxp.StringSource toStringSourceFromSpring(org.springframework.xml.transform.StringSource springStringSource) {
+ return new org.apache.camel.converter.jaxp.StringSource(springStringSource.toString());
+ }
+
+ /**
+ * Converts a Camel {@link org.apache.camel.converter.jaxp.StringSource}
+ * to a Spring-WS {@link org.springframework.xml.transform.StringSource}
+ */
+ @Converter
+ public static org.springframework.xml.transform.StringSource toStringSourceFromCamel(org.apache.camel.converter.jaxp.StringSource camelStringSource) {
+ return new org.springframework.xml.transform.StringSource(camelStringSource.getText());
+ }
+}
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/converter/StringSourceConverter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,88 @@
+/**
+ * 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.type;
+
+import org.springframework.xml.xpath.XPathExpression;
+
+public class EndpointMappingKey {
+ private EndpointMappingType type;
+ private String lookupKey;
+
+ /* expression in case type is 'xpath' */
+ private XPathExpression expression;
+
+ public EndpointMappingKey(EndpointMappingType type, String lookupKey, XPathExpression expression) {
+ this.type = type;
+ this.lookupKey = lookupKey;
+ this.expression = expression;
+ }
+
+ public EndpointMappingType getType() {
+ return type;
+ }
+
+ public void setType(EndpointMappingType type) {
+ this.type = type;
+ }
+
+ public String getLookupKey() {
+ return lookupKey;
+ }
+
+ public void setLookupKey(String lookupKey) {
+ this.lookupKey = lookupKey;
+ }
+
+ public XPathExpression getExpression() {
+ return expression;
+ }
+
+ public void setExpression(XPathExpression expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((lookupKey == null) ? 0 : lookupKey.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ EndpointMappingKey other = (EndpointMappingKey) obj;
+ if (lookupKey == null) {
+ if (other.lookupKey != null) {
+ return false;
+ }
+ } else if (!lookupKey.equals(other.lookupKey)) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingKey.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java (added)
+++ camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,56 @@
+/**
+ * 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.type;
+
+/**
+ * Endpoint mappings supported by consumer through uri configuration.
+ */
+public enum EndpointMappingType {
+ ROOT_QNAME("rootqname:"),
+ SOAP_ACTION("soapaction:"),
+ XPATHRESULT("xpathresult:"),
+ URI("uri:"),
+ BEANNAME("beanname:");
+
+ private String prefix;
+
+ private EndpointMappingType(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Find {@link EndpointMappingType} that corresponds with the prefix of the
+ * given uri. Matching of uri prefix against enum values is case-insensitive
+ *
+ * @param uri remaining uri part of Spring-WS component
+ * @return EndpointMappingType corresponding to uri prefix
+ */
+ public static EndpointMappingType getTypeFromUriPrefix(String uri) {
+ if (uri != null) {
+ for (EndpointMappingType type : EndpointMappingType.values()) {
+ if (uri.toLowerCase().startsWith(type.getPrefix())) {
+ return type;
+ }
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/main/java/org/apache/camel/component/spring/ws/type/EndpointMappingType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (added)
+++ camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Thu Nov 4 07:15:27 2010
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.camel.component.spring.ws.converter
\ No newline at end of file
Added: camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/springws
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/springws?rev=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/springws (added)
+++ camel/trunk/components/camel-spring-ws/src/main/resources/META-INF/services/org/apache/camel/component/springws Thu Nov 4 07:15:27 2010
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.spring.ws.SpringWebserviceComponent
\ No newline at end of file
Added: 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=1030847&view=auto
==============================================================================
--- camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java (added)
+++ camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java Thu Nov 4 07:15:27 2010
@@ -0,0 +1,66 @@
+/**
+ * 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;
+
+import java.io.IOException;
+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.util.FileUtil;
+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;
+
+public class ConsumerEndpointMappingByBeanNameRouteTest extends CamelSpringTestSupport {
+
+ private final String xmlRequestForGoogleStockQuote = "<GetQuote xmlns=\"http://www.stockquotes.edu/\"><symbol>GOOG</symbol></GetQuote>";
+
+ private String expectedResponse;
+ private WebServiceTemplate webServiceTemplate;
+
+ public ConsumerEndpointMappingByBeanNameRouteTest() throws IOException {
+ expectedResponse = FileUtil.readFileAsString("src/test/resources/stockquote-response.xml");
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ webServiceTemplate = (WebServiceTemplate) applicationContext.getBean("webServiceTemplate");
+ }
+
+ @Test
+ public void testBeanName() throws Exception {
+ StreamSource source = new StreamSource(new StringReader(xmlRequestForGoogleStockQuote));
+ StringWriter sw = new StringWriter();
+ StreamResult result = new StreamResult(sw);
+ webServiceTemplate.sendSourceAndReceiveToResult(source, result);
+ assertNotNull(result);
+ assertEquals(expectedResponse, sw.toString());
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext(
+ "org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest-context.xml");
+ }
+
+}
Propchange: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-spring-ws/src/test/java/org/apache/camel/component/spring/ws/ConsumerEndpointMappingByBeanNameRouteTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date