You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2007/09/29 08:48:58 UTC
svn commit: r580551 - in /activemq/camel/trunk/components/camel-cxf: ./
src/main/java/org/apache/camel/component/cxf/
src/test/java/org/apache/camel/component/cxf/ src/test/resources/hello/
Author: gnodet
Date: Fri Sep 28 23:48:57 2007
New Revision: 580551
URL: http://svn.apache.org/viewvc?rev=580551&view=rev
Log:
More work on the soap component
Added:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java
- copied, changed from r578776, activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRouterTest.java
activemq/camel/trunk/components/camel-cxf/src/test/resources/hello/
activemq/camel/trunk/components/camel-cxf/src/test/resources/hello/HelloWorld-DOC.wsdl
- copied unchanged from r579961, incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/HelloWorld-DOC.wsdl
Modified:
activemq/camel/trunk/components/camel-cxf/pom.xml
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapComponent.java
Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=580551&r1=580550&r2=580551&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Fri Sep 28 23:48:57 2007
@@ -86,6 +86,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${cxf-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
<version>${cxf-version}</version>
</dependency>
@@ -164,7 +169,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
- <scope>test</scope>
</dependency>
<dependency>
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java?rev=580551&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java Fri Sep 28 23:48:57 2007
@@ -0,0 +1,67 @@
+/**
+ * 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.cxf;
+
+import org.apache.camel.AsyncProcessor;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
+
+/**
+ * A simple class to wrap an existing processor (synchronous or asynchronous)
+ * with two synchronous processor that will be executed before and after the
+ * main processor.
+ */
+public class AsyncProcessorDecorator implements AsyncProcessor {
+
+ private final AsyncProcessor processor;
+ private final Processor before;
+ private final Processor after;
+
+ public AsyncProcessorDecorator(Processor processor, Processor before, Processor after) {
+ this.processor = AsyncProcessorTypeConverter.convert(processor);
+ this.before = before;
+ this.after = after;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ AsyncProcessorHelper.process(this, exchange);
+ }
+
+ public boolean process(final Exchange exchange, final AsyncCallback callback) {
+ try {
+ before.process(exchange);
+ } catch (Throwable t) {
+ exchange.setException(t);
+ callback.done(true);
+ return true;
+ }
+ return processor.process(exchange, new AsyncCallback() {
+ public void done(boolean doneSynchronously) {
+ try {
+ after.process(exchange);
+ callback.done(doneSynchronously);
+ } catch (Throwable t) {
+ exchange.setException(t);
+ }
+ }
+ });
+ }
+
+}
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapComponent.java?rev=580551&r1=580550&r2=580551&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapComponent.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapComponent.java Fri Sep 28 23:48:57 2007
@@ -16,198 +16,33 @@
*/
package org.apache.camel.component.cxf;
-import org.apache.camel.*;
+import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
-import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
-import org.apache.camel.util.AsyncProcessorHelper;
import org.apache.camel.util.CamelContextHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.URISupport;
import java.util.Map;
/**
- * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Component</a>
-
+ * Defines the <a href="http://activemq.apache.org/camel/cxf.html">SOAP Component</a>
+ *
* @version $Revision: 576522 $
*/
public class CxfSoapComponent extends DefaultComponent {
- private static final Log LOG = LogFactory.getLog(CxfSoapComponent.class);
-
+ @Override
protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
- String name = uri.substring(uri.indexOf(':') + 1);
- Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(getCamelContext(), name);
- return new SoapEndpoint(endpoint);
- }
-
- protected void processSoapConsumerIn(Exchange exchange) throws Exception {
- LOG.info("processSoapConsumerIn: " + exchange);
- // TODO
- }
-
- protected void processSoapConsumerOut(Exchange exchange) throws Exception {
- LOG.info("processSoapConsumerOut: " + exchange);
- // TODO
- }
-
- protected void processSoapProviderIn(Exchange exchange) throws Exception {
- LOG.info("processSoapProviderIn: " + exchange);
- // TODO
- }
-
- protected void processSoapProviderOut(Exchange exchange) throws Exception {
- LOG.info("processSoapProviderOut: " + exchange);
- // TODO
- }
-
- public class SoapEndpoint implements Endpoint {
-
- private final Endpoint endpoint;
-
- public SoapEndpoint(Endpoint endpoint) {
- this.endpoint = endpoint;
- }
-
- public boolean isSingleton() {
- return endpoint.isSingleton();
- }
-
- public String getEndpointUri() {
- return endpoint.getEndpointUri();
- }
-
- public Exchange createExchange() {
- return endpoint.createExchange();
- }
-
- public Exchange createExchange(ExchangePattern pattern) {
- return endpoint.createExchange(pattern);
- }
-
- public Exchange createExchange(Exchange exchange) {
- return endpoint.createExchange(exchange);
- }
-
- public CamelContext getContext() {
- return endpoint.getContext();
- }
-
- public Producer createProducer() throws Exception {
- Producer producer = endpoint.createProducer();
- return new SoapProducer(producer);
- }
-
- public Consumer createConsumer(Processor processor) throws Exception {
- Processor soapProcessor = new AsyncProcessorDecorator(processor,
- new Processor() {
- public void process(Exchange exchange) throws Exception {
- processSoapConsumerIn(exchange);
- }
- },
- new Processor() {
- public void process(Exchange exchange) throws Exception {
- processSoapConsumerOut(exchange);
- }
- });
- return endpoint.createConsumer(soapProcessor);
- }
-
- public PollingConsumer createPollingConsumer() throws Exception {
- throw new UnsupportedOperationException();
- }
- }
-
- public class SoapProducer implements Producer, AsyncProcessor {
-
- private final Producer producer;
- private final AsyncProcessor processor;
-
- public SoapProducer(Producer producer) {
- this.producer = producer;
- this.processor = new AsyncProcessorDecorator(producer,
- new Processor() {
- public void process(Exchange exchange) throws Exception {
- processSoapProviderIn(exchange);
- }
- },
- new Processor() {
- public void process(Exchange exchange) throws Exception {
- processSoapProviderOut(exchange);
- }
- });
- }
-
- public Endpoint getEndpoint() {
- return producer.getEndpoint();
- }
-
- public Exchange createExchange() {
- return producer.createExchange();
- }
-
- public Exchange createExchange(ExchangePattern pattern) {
- return producer.createExchange(pattern);
- }
-
- public Exchange createExchange(Exchange exchange) {
- return producer.createExchange(exchange);
- }
-
- public void process(Exchange exchange) throws Exception {
- AsyncProcessorHelper.process(this, exchange);
- }
-
- public boolean process(Exchange exchange, AsyncCallback callback) {
- return processor.process(exchange, callback);
- }
-
- public void start() throws Exception {
- producer.start();
- }
-
- public void stop() throws Exception {
- producer.stop();
- }
- }
-
- public static class AsyncProcessorDecorator implements AsyncProcessor {
-
- private final AsyncProcessor processor;
- private final Processor before;
- private final Processor after;
-
- public AsyncProcessorDecorator(Processor processor, Processor before, Processor after) {
- this.processor = AsyncProcessorTypeConverter.convert(processor);
- this.before = before;
- this.after = after;
- }
-
- public void process(Exchange exchange) throws Exception {
- AsyncProcessorHelper.process(this, exchange);
- }
-
- public boolean process(final Exchange exchange, final AsyncCallback callback) {
- try {
- before.process(exchange);
- } catch (Throwable t) {
- exchange.setException(t);
- callback.done(true);
- return true;
- }
- return processor.process(exchange, new AsyncCallback() {
- public void done(boolean doneSynchronously) {
- try {
- after.process(exchange);
- callback.done(doneSynchronously);
- } catch (Throwable t) {
- exchange.setException(t);
- }
- }
- });
- }
-
+ Map soapProps = IntrospectionSupport.extractProperties(parameters, "soap.");
+ if (parameters.size() > 0) {
+ remaining += "?" + URISupport.createQueryString(parameters);
+ }
+ Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(getCamelContext(), remaining);
+ CxfSoapEndpoint soapEndpoint = new CxfSoapEndpoint(endpoint);
+ setProperties(soapEndpoint, soapProps);
+ soapEndpoint.init();
+ return soapEndpoint;
}
}
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java?rev=580551&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java Fri Sep 28 23:48:57 2007
@@ -0,0 +1,107 @@
+/**
+ * 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.cxf;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.ChainInitiationObserver;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
+import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A CXF based soap consumer.
+ * The consumer will delegate to another endpoint for the transport layer
+ * and will provide SOAP support on top of it.
+ */
+public class CxfSoapConsumer implements Consumer {
+
+ private static final Log LOG = LogFactory.getLog(CxfSoapConsumer.class);
+
+ private final CxfSoapEndpoint endpoint;
+ private final Consumer consumer;
+ private EndpointImpl ep;
+ private MessageObserver chain;
+ private Server server;
+
+ public CxfSoapConsumer(CxfSoapEndpoint endpoint, Processor processor) throws Exception {
+ this.endpoint = endpoint;
+ Processor soapProcessor = new AsyncProcessorDecorator(processor,
+ new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ processSoapConsumerIn(exchange);
+ }
+ },
+ new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ processSoapConsumerOut(exchange);
+ }
+ });
+ this.consumer = endpoint.getInnerEndpoint().createConsumer(soapProcessor);
+ WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), endpoint.getDefinition(), endpoint.getService());
+ Service cxfService = factory.create();
+ EndpointInfo ei = cxfService.getServiceInfos().iterator().next().getEndpoints().iterator().next();
+ ei.setAddress("local://" + ei.getService().getName().toString() + "/" + ei.getName().getLocalPart());
+ ei.getBinding().setProperty(AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
+ cxfService.getInInterceptors().add(new ReadHeadersInterceptor(getBus()));
+ cxfService.getInInterceptors().add(new MustUnderstandInterceptor());
+ cxfService.getInInterceptors().add(new AttachmentInInterceptor());
+ cxfService.getInInterceptors().add(new StaxInInterceptor());
+ cxfService.getInInterceptors().add(new ReadHeadersInterceptor(getBus()));
+ ep = new EndpointImpl(getBus(), cxfService, ei);
+ chain = new ChainInitiationObserver(ep, getBus());
+ server = new ServerImpl(getBus(), ep, null, chain);
+ }
+
+ public void start() throws Exception {
+ server.start();
+ consumer.start();
+ }
+
+ public void stop() throws Exception {
+ server.stop();
+ consumer.stop();
+ }
+
+ protected Bus getBus() {
+ return endpoint.getBus();
+ }
+
+ protected void processSoapConsumerIn(Exchange exchange) throws Exception {
+ LOG.info("processSoapConsumerIn: " + exchange);
+ // TODO: chain.onMessage();
+ }
+
+ protected void processSoapConsumerOut(Exchange exchange) throws Exception {
+ LOG.info("processSoapConsumerOut: " + exchange);
+ // TODO
+ }
+
+}
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java?rev=580551&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java Fri Sep 28 23:48:57 2007
@@ -0,0 +1,116 @@
+/**
+ * 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.cxf;
+
+import org.apache.camel.*;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.DOMUtils;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+import javax.wsdl.Definition;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
+
+/**
+ * A CXF based SOAP endpoint which wraps an existing
+ * endpoint with SOAP processing.
+ */
+public class CxfSoapEndpoint implements Endpoint {
+
+ private final Endpoint endpoint;
+ private Resource wsdl;
+ private org.w3c.dom.Document description;
+ private Definition definition;
+ private QName service;
+ private Bus bus;
+
+ public CxfSoapEndpoint(Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ protected Endpoint getInnerEndpoint() {
+ return endpoint;
+ }
+
+ public boolean isSingleton() {
+ return endpoint.isSingleton();
+ }
+
+ public String getEndpointUri() {
+ return endpoint.getEndpointUri();
+ }
+
+ public Exchange createExchange() {
+ return endpoint.createExchange();
+ }
+
+ public Exchange createExchange(ExchangePattern pattern) {
+ return endpoint.createExchange(pattern);
+ }
+
+ public Exchange createExchange(Exchange exchange) {
+ return endpoint.createExchange(exchange);
+ }
+
+ public CamelContext getContext() {
+ return endpoint.getContext();
+ }
+
+ public Producer createProducer() throws Exception {
+ return new CxfSoapProducer(this);
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return new CxfSoapConsumer(this, processor);
+ }
+
+ public PollingConsumer createPollingConsumer() throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setWsdl(Resource wsdl) {
+ this.wsdl = wsdl;
+ }
+
+ public void init() throws Exception {
+ Assert.notNull(wsdl, "soap.wsdl parameter must be set on the uri");
+ description = DOMUtils.readXml(wsdl.getInputStream());
+ WSDLFactory wsdlFactory = WSDLFactory.newInstance();
+ WSDLReader reader = wsdlFactory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ definition = reader.readWSDL(wsdl.getURL().toString(), description);
+ service = (QName) definition.getServices().keySet().iterator().next();
+ }
+
+ protected Bus getBus() {
+ if (bus == null) {
+ bus = BusFactory.newInstance().createBus();
+ }
+ return bus;
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public QName getService() {
+ return service;
+ }
+}
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java?rev=580551&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java Fri Sep 28 23:48:57 2007
@@ -0,0 +1,95 @@
+/**
+ * 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.cxf;
+
+import org.apache.camel.*;
+import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A CXF based soap provider.
+ * The consumer will delegate to another endpoint for the transport layer
+ * and will provide SOAP support on top of it.
+ */
+public class CxfSoapProducer implements Producer, AsyncProcessor {
+
+ private static final Log LOG = LogFactory.getLog(CxfSoapProducer.class);
+
+ private final CxfSoapEndpoint endpoint;
+ private final Producer producer;
+ private final AsyncProcessor processor;
+
+ public CxfSoapProducer(CxfSoapEndpoint endpoint) throws Exception {
+ this.endpoint = endpoint;
+ this.producer = endpoint.getInnerEndpoint().createProducer();
+ this.processor = new AsyncProcessorDecorator(producer,
+ new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ processSoapProviderIn(exchange);
+ }
+ },
+ new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ processSoapProviderOut(exchange);
+ }
+ });
+ }
+
+ public Endpoint getEndpoint() {
+ return producer.getEndpoint();
+ }
+
+ public Exchange createExchange() {
+ return producer.createExchange();
+ }
+
+ public Exchange createExchange(ExchangePattern pattern) {
+ return producer.createExchange(pattern);
+ }
+
+ public Exchange createExchange(Exchange exchange) {
+ return producer.createExchange(exchange);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ AsyncProcessorHelper.process(this, exchange);
+ }
+
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ return processor.process(exchange, callback);
+ }
+
+ public void start() throws Exception {
+ producer.start();
+ }
+
+ public void stop() throws Exception {
+ producer.stop();
+ }
+
+ protected void processSoapProviderIn(Exchange exchange) throws Exception {
+ LOG.info("processSoapProviderIn: " + exchange);
+ // TODO
+ }
+
+ protected void processSoapProviderOut(Exchange exchange) throws Exception {
+ LOG.info("processSoapProviderOut: " + exchange);
+ // TODO
+ }
+
+}
Copied: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java (from r578776, activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRouterTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java?p2=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java&p1=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRouterTest.java&r1=578776&r2=580551&rev=580551&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRouterTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java Fri Sep 28 23:48:57 2007
@@ -16,93 +16,23 @@
*/
package org.apache.camel.component.cxf;
-import org.apache.camel.CamelContext;
+import org.apache.camel.CamelTemplate;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.CXFBusFactory;
-import org.apache.cxf.endpoint.ServerImpl;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.interceptor.LoggingInInterceptor;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.core.CollectionFactory;
+public class CxfSoapTest extends ContextTestSupport {
-import junit.framework.TestCase;
-
-public class CxfRouterTest extends ContextTestSupport {
- protected static final String ROUTER_ADDRESS = "http://localhost:9000/router";
- protected static final String SERVICE_ADDRESS = "http://localhost:9002/helloworld";
- protected static final String SERVICE_CLASS = "serviceClass=org.apache.camel.component.cxf.HelloService";
-
- private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&dataFormat=POJO";
- private String serviceEndpointURI = "cxf://" + SERVICE_ADDRESS + "?" + SERVICE_CLASS + "&dataFormat=POJO";
- //private Endpoint routerEndpoint;
- //private Endpoint resultEndpoint;
- private ServerImpl server;
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- startService();
- }
-
- private void startService() {
- //start a service
- ServerFactoryBean svrBean = new ServerFactoryBean();
-
- svrBean.setAddress(SERVICE_ADDRESS);
- svrBean.setServiceClass(HelloService.class);
- svrBean.setServiceBean(new HelloServiceImpl());
- svrBean.setBus(CXFBusFactory.getDefaultBus());
-
- server = (ServerImpl)svrBean.create();
- server.start();
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (server != null) {
- server.stop();
- }
- }
-
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(routerEndpointURI).to(serviceEndpointURI);
+ from("soap:direct:consumer?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl").to("mock:consumer");
+ from("direct:provider").to("soap:mock:provider?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl");
}
};
}
-
- protected CamelContext createCamelContext() throws Exception {
- return new DefaultCamelContext();
- }
-
- public void testInvokingServerFromCXFClient() throws Exception {
- Bus bus = BusFactory.getDefaultBus();
-
- ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
- ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress(ROUTER_ADDRESS);
- clientBean.setServiceClass(HelloService.class);
- clientBean.setBus(bus);
-
- HelloService client = (HelloService) proxyFactory.create();
- String result = client.echo("hello world");
- assertEquals("we should get the right answer from router", "hello world", result);
-
- //Thread.sleep(200000);
-
+ public void testSoap() throws Exception {
+ template.sendBody("direct:consumer", "<hello/>");
+
}
-}
+}
\ No newline at end of file