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/10/21 09:56:29 UTC

svn commit: r586863 - in /activemq/camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/util/ main/resources/org/apache/camel/component/cxf/util/ test/java/org/apache/camel/component/c...

Author: gnodet
Date: Sun Oct 21 00:56:26 2007
New Revision: 586863

URL: http://svn.apache.org/viewvc?rev=586863&view=rev
Log:
CAMEL-180: Add soap:xxx protocol in CXF component, thx Willem

Added:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataInInterceptor.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataOutInterceptor.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/Dummy.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduit.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduitSelector.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestination.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestinationFactory.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/WSDLSoapServiceFactoryBean.java
    activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/RequestBody.xml
    activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapRequest.xml
Modified:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.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/main/java/org/apache/camel/component/cxf/util/CxfEndpointUtils.java
    activemq/camel/trunk/components/camel-cxf/src/main/resources/org/apache/camel/component/cxf/util/Messages.properties
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java Sun Oct 21 00:56:26 2007
@@ -29,12 +29,12 @@
  * @version $Revision$
  */
 public class CxfBinding {
-    public Object extractBodyFromCxf(CxfExchange exchange, Message message) {
+    public static Object extractBodyFromCxf(CxfExchange exchange, Message message) {
         //  TODO how do we choose a format?
         return getBody(message);
     }
 
-    protected Object getBody(Message message) {
+    protected static Object getBody(Message message) {
         Set<Class<?>> contentFormats = message.getContentFormats();
         if (contentFormats != null) {
             for (Class<?> contentFormat : contentFormats) {            

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Sun Oct 21 00:56:26 2007
@@ -80,15 +80,15 @@
     }
 
     public CxfExchange createExchange() {
-        return new CxfExchange(getContext(), getExchangePattern(), getBinding());
+        return new CxfExchange(getContext(), getExchangePattern());
     }
 
     public CxfExchange createExchange(ExchangePattern pattern) {
-        return new CxfExchange(getContext(), pattern, getBinding());
+        return new CxfExchange(getContext(), pattern);
     }
 
     public CxfExchange createExchange(Message inMessage) {
-        return new CxfExchange(getContext(), getExchangePattern(), getBinding(), inMessage);
+        return new CxfExchange(getContext(), getExchangePattern(), inMessage);
     }
            
     public String getDataFormat() {

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java Sun Oct 21 00:56:26 2007
@@ -32,13 +32,11 @@
  *
  * @version $Revision$
  */
-public class CxfExchange extends DefaultExchange {
-    private final CxfBinding binding;
+public class CxfExchange extends DefaultExchange {   
     private Exchange exchange;
 
-    public CxfExchange(CamelContext context, CxfBinding binding, Exchange exchange) {
-        super(context);
-        this.binding = binding;
+    public CxfExchange(CamelContext context, Exchange exchange) {
+        super(context);        
         this.exchange = exchange;
 
         setIn(new CxfMessage(exchange.getInMessage()));
@@ -48,13 +46,12 @@
         }    
     }
 
-    public CxfExchange(CamelContext context, ExchangePattern pattern, CxfBinding binding) {
-        super(context, pattern);
-        this.binding = binding;
+    public CxfExchange(CamelContext context, ExchangePattern pattern) {
+        super(context, pattern);        
     }
 
-    public CxfExchange(CamelContext context, ExchangePattern pattern, CxfBinding binding, Message inMessage) {
-        this(context, pattern, binding);
+    public CxfExchange(CamelContext context, ExchangePattern pattern, Message inMessage) {
+        this(context, pattern);
         this.exchange = inMessage.getExchange();
 
         setIn(new CxfMessage(inMessage));
@@ -92,12 +89,7 @@
     }
 
 
-    /**
-     * @return the Camel <-> JBI binding
-     */
-    public CxfBinding getBinding() {
-        return binding;
-    }
+    
 
     // Expose CXF APIs directly on the exchange
     //-------------------------------------------------------------------------

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java Sun Oct 21 00:56:26 2007
@@ -90,6 +90,6 @@
 
     @Override
     protected Object createBody() {
-        return getExchange().getBinding().extractBodyFromCxf(getExchange(), cxfMessage);
+        return CxfBinding.extractBodyFromCxf(getExchange(), cxfMessage);
     }
 }

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,89 @@
+/**
+ * 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 java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.transform.Source;
+
+import org.apache.camel.Exchange;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+
+public class CxfSoapBinding {
+    
+    public org.apache.cxf.message.Message getCxfInMessage(org.apache.camel.Exchange exchange, boolean isClient) {
+        MessageImpl answer = new MessageImpl();
+        org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty("CxfExchange", 
+                                                                        org.apache.cxf.message.Exchange.class);
+        org.apache.camel.Message message = null;
+        if (isClient) {
+            message = exchange.getOut();            
+        } else {
+            message = exchange.getIn();
+        }
+        if (cxfExchange == null) {
+            cxfExchange = new ExchangeImpl();
+            exchange.setProperty("CxfExchange", cxfExchange);
+        }    
+        Object body = message.getBody(InputStream.class);
+        if (body == null) {
+            body = message.getBody();
+        }
+        if (body instanceof InputStream) {
+            answer.setContent(InputStream.class, body);             
+        }
+        answer.setExchange(cxfExchange);
+        cxfExchange.setInMessage(answer);
+        return answer;
+    }
+    
+    public org.apache.cxf.message.Message getCxfOutMessage(org.apache.camel.Exchange exchange, boolean isClient) {
+        org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty("CxfExchange", org.apache.cxf.message.Exchange.class);
+        assert cxfExchange != null;
+        org.apache.cxf.endpoint.Endpoint cxfEndpoint = cxfExchange.get(org.apache.cxf.endpoint.Endpoint.class);
+        org.apache.cxf.message.Message outMessage = cxfEndpoint.getBinding().createMessage();
+        outMessage.setExchange(cxfExchange);
+        cxfExchange.setOutMessage(outMessage);
+        org.apache.camel.Message message = null;
+        if (isClient) {
+            message = exchange.getIn();
+        }
+        else {
+            message = exchange.getOut();
+        }    
+        // send the body back
+        Object body = message.getBody(Source.class);
+        if (body == null) {
+            body = message.getBody();
+        }
+        if (body instanceof Source) {
+            outMessage.setContent(Source.class, body);             
+        }
+        outMessage.putAll(message.getHeaders());
+        return outMessage;
+    }
+     
+
+}

Modified: 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=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java Sun Oct 21 00:56:26 2007
@@ -16,12 +16,24 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+
+import org.apache.camel.CamelException;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Exchange;
+import org.apache.camel.component.cxf.util.NullConduit;
+import org.apache.camel.component.cxf.util.CxfEndpointUtils;
+import org.apache.camel.component.cxf.util.NullDestinationFactory;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.ChainInitiationObserver;
 import org.apache.cxf.wsdl11.WSDLServiceFactory;
@@ -29,7 +41,12 @@
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
 import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
@@ -46,9 +63,8 @@
     private static final Log LOG = LogFactory.getLog(CxfSoapConsumer.class);
 
     private final CxfSoapEndpoint endpoint;
-    private final Consumer consumer;
-    private EndpointImpl ep;
-    private MessageObserver chain;
+    private final Consumer consumer;    
+    private MessageObserver inMessageObserver;     
     private Server server;
 
     public CxfSoapConsumer(CxfSoapEndpoint endpoint, Processor processor) throws Exception {
@@ -65,25 +81,28 @@
                     }
                 });
         this.consumer = endpoint.getInnerEndpoint().createConsumer(soapProcessor);
-        WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), endpoint.getDefinition(), endpoint.getService());
-        Service cxfService = factory.create();
-        // need to find with the endpoint and service Qname
-        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);
+        Class sei = CxfEndpointUtils.getSEIClass(endpoint.getServiceClass());
+        ServerFactoryBean sfb = CxfEndpointUtils.getServerFactoryBean(sei);
+        sfb.setWsdlURL(endpoint.getWsdl().getURL().toString());        
+        if (endpoint.getServiceName() != null) {
+            sfb.setServiceName(endpoint.getServiceName());
+        }
+        if (endpoint.getEndpointName() != null) {
+            sfb.setEndpointName(endpoint.getEndpointName());
+        }
+        // we do not need use the destination here
+        sfb.setDestinationFactory(new NullDestinationFactory());
+        sfb.setStart(false);
+        
+        server = sfb.create();
     }
-
+    
+    
     public void start() throws Exception {
         server.start();
+        inMessageObserver = server.getDestination().getMessageObserver();
         consumer.start();
+       
     }
 
     public void stop() throws Exception {
@@ -97,12 +116,32 @@
 
     protected void processSoapConsumerIn(Exchange exchange) throws Exception {
         LOG.info("processSoapConsumerIn: " + exchange);
-        // TODO: chain.onMessage();
+        CxfSoapBinding binding = endpoint.getCxfSoapBinding();
+        org.apache.cxf.message.Message inMessage = binding.getCxfInMessage(exchange, false);
+        org.apache.cxf.message.Exchange cxfExchange = inMessage.getExchange();
+        cxfExchange.put(org.apache.cxf.endpoint.Endpoint.class, server.getEndpoint());
+        cxfExchange.put(Bus.class, getBus());
+        cxfExchange.setConduit(new NullConduit());        
+        // get the message input stream, deal with the exchange in message
+        inMessageObserver.onMessage(inMessage);       
+        exchange.getIn().setBody(inMessage.getContent(Source.class));
+        //TODO copy the right header information
+        exchange.getIn().setHeaders(inMessage);
+        
     }
 
     protected void processSoapConsumerOut(Exchange exchange) throws Exception {
         LOG.info("processSoapConsumerOut: " + exchange);
-        // TODO
+        CxfSoapBinding binding = endpoint.getCxfSoapBinding();
+        // TODO check if the message is oneway message
+        // Get the method name form the soap endpoint
+        org.apache.cxf.message.Message outMessage = binding.getCxfOutMessage(exchange, false);
+        org.apache.cxf.message.Exchange cxfExchange = outMessage.getExchange();
+        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
+        outMessage.setInterceptorChain(chain);        
+        chain.doIntercept(outMessage);
+        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);               
+        exchange.getOut().setBody(outputStream.getInputStream());        
     }
 
 }

Modified: 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=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapEndpoint.java Sun Oct 21 00:56:26 2007
@@ -36,10 +36,13 @@
 
     private final Endpoint endpoint;
     private Resource wsdl;
+    private String serviceClass;
     private org.w3c.dom.Document description;
     private Definition definition;
-    private QName service;
+    private QName serviceName;
+    private QName endpointName;
     private Bus bus;
+    private CxfSoapBinding cxfSoapBinding;
 
     public CxfSoapEndpoint(Endpoint endpoint) {
         this.endpoint = endpoint;
@@ -84,19 +87,56 @@
     public PollingConsumer createPollingConsumer() throws Exception {
         throw new UnsupportedOperationException();
     }
+    
+    public Resource getWsdl() {
+        return wsdl;
+    }
 
     public void setWsdl(Resource wsdl) {
         this.wsdl = wsdl;
     }
+    
+    public void setServiceClass(String serviceClass) {
+        this.serviceClass = serviceClass;
+    }
+    
+    public String getServiceClass() {
+        return serviceClass;
+    }
+    
+    public void setServiceName(String serviceName) {
+        this.serviceName = QName.valueOf(serviceName);
+    }
+    
+    public void setEndpointName(String endpointName) {
+        this.endpointName = QName.valueOf(endpointName);
+    }
+    
+    public QName getEndpointName() {
+        return endpointName;
+    }
+    
+    public CxfSoapBinding getCxfSoapBinding() {
+        if (cxfSoapBinding == null) {
+            cxfSoapBinding = new CxfSoapBinding();
+        }
+        return cxfSoapBinding;
+    }
+    
+    public void setCxfSoapBinding(CxfSoapBinding bing) {
+        cxfSoapBinding = bing;
+    }
 
     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();
+        if (serviceName == null) {
+            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);
+            serviceName = (QName) definition.getServices().keySet().iterator().next();
+        }    
     }
 
     protected Bus getBus() {
@@ -110,7 +150,7 @@
         return definition;
     }
 
-    public QName getService() {
-        return service;
+    public QName getServiceName() {
+        return serviceName;
     }
 }

Modified: 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=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java Sun Oct 21 00:56:26 2007
@@ -16,10 +16,29 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.io.OutputStream;
+
+import javax.xml.transform.Source;
+
 import org.apache.camel.*;
+import org.apache.camel.component.cxf.util.CxfEndpointUtils;
+import org.apache.camel.component.cxf.util.Dummy;
+import org.apache.camel.component.cxf.util.NullConduit;
+import org.apache.camel.component.cxf.util.NullConduitSelector;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
 
 /**
  * A CXF based soap provider.
@@ -33,6 +52,8 @@
     private final CxfSoapEndpoint endpoint;
     private final Producer producer;
     private final AsyncProcessor processor;
+    private ClientImpl client;
+    
 
     public CxfSoapProducer(CxfSoapEndpoint endpoint) throws Exception {
         this.endpoint = endpoint;
@@ -48,9 +69,28 @@
                         processSoapProviderOut(exchange);
                     }
                 });
+        
+        //create the endpoint and setup the intercepters
+        Class sei = CxfEndpointUtils.getSEIClass(endpoint.getServiceClass());
+        ClientFactoryBean cfb = CxfEndpointUtils.getClientFactoryBean(sei);
+        if (sei == null) {
+            cfb.setServiceClass(Dummy.class);
+        } else {
+            cfb.setServiceClass(sei);
+        }
+        cfb.setWsdlURL(endpoint.getWsdl().getURL().toString()); 
+        if (endpoint.getServiceName() != null) {
+            cfb.setServiceName(endpoint.getServiceName());
+        }
+        if (endpoint.getEndpointName() != null) {
+            cfb.setEndpointName(endpoint.getEndpointName());
+        }
+        cfb.setConduitSelector(new NullConduitSelector());
+        client = (ClientImpl) cfb.create();
+        
     }
 
-    public Endpoint getEndpoint() {
+    public org.apache.camel.Endpoint getEndpoint() {
         return producer.getEndpoint();
     }
 
@@ -82,14 +122,41 @@
         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
+        CxfSoapBinding binding = endpoint.getCxfSoapBinding();
+        org.apache.cxf.message.Message inMessage = binding.getCxfInMessage(exchange, true);
+        client.setInInterceptors(client.getEndpoint().getService().getInInterceptors());
+        client.onMessage(inMessage);
+        
+        exchange.getOut().setBody(inMessage.getContent(Source.class));
+        //TODO copy the right header information
+        exchange.getOut().setHeaders(inMessage);
+    }
+    
+    protected Bus getBus() {
+        return endpoint.getBus();
+    }
+
+    protected void processSoapProviderIn(Exchange exchange) throws Exception {
+        LOG.info("processSoapProviderIn: " + exchange);
+        org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();        
+        org.apache.cxf.message.Exchange cxfExchange = new ExchangeImpl();        
+        cxfExchange.put(org.apache.cxf.endpoint.Endpoint.class, cxfEndpoint);
+        cxfExchange.put(Bus.class, getBus());
+        cxfExchange.setConduit(new NullConduit());
+        exchange.setProperty("CxfExchange", cxfExchange);
+        CxfSoapBinding binding = endpoint.getCxfSoapBinding();
+        org.apache.cxf.message.Message outMessage = binding.getCxfOutMessage(exchange, true);
+        outMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+        outMessage.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
+        InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(cxfExchange);
+        outMessage.setInterceptorChain(chain);
+               
+        chain.doIntercept(outMessage);
+        CachedOutputStream outputStream = (CachedOutputStream)outMessage.getContent(OutputStream.class);
+                
+        exchange.getOut().setBody(outputStream.getInputStream());
     }
 
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfEndpointUtils.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfEndpointUtils.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfEndpointUtils.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfEndpointUtils.java Sun Oct 21 00:56:26 2007
@@ -95,6 +95,14 @@
 
         return endpointInfo;
     }
+    
+    public static Class getSEIClass(String className) throws ClassNotFoundException {
+        if (className == null) {
+            return null;
+        } else {
+            return ClassLoaderUtils.loadClass(className, CxfEndpointUtils.class);
+        }
+    }
 
     public static boolean hasWebServiceAnnotation(Class<?> cls) {
         if (cls == null) {
@@ -113,11 +121,17 @@
     }
     
     public static ServerFactoryBean getServerFactoryBean(Class<?> cls) throws CamelException {
-        
-        try {            
-            boolean isJSR181SEnabled = CxfEndpointUtils.hasWebServiceAnnotation(cls);
-            ServerFactoryBean serverFactory = isJSR181SEnabled ? new JaxWsServerFactoryBean() 
-                        : new ServerFactoryBean();            
+        ServerFactoryBean serverFactory  = null;
+        try { 
+            if (cls == null) {
+                serverFactory = new ServerFactoryBean();
+                serverFactory.setServiceFactory(new WSDLSoapServiceFactoryBean());
+                
+            } else {
+                boolean isJSR181SEnabled = CxfEndpointUtils.hasWebServiceAnnotation(cls);
+                serverFactory = isJSR181SEnabled ? new JaxWsServerFactoryBean() 
+                            : new ServerFactoryBean();
+            }    
             return serverFactory;
         } catch (Exception e) {
             throw new CamelException(e);
@@ -126,10 +140,16 @@
     }
     
     public static ClientFactoryBean getClientFactoryBean(Class<?> cls) throws CamelException {
-        try {            
-            boolean isJSR181SEnabled = CxfEndpointUtils.hasWebServiceAnnotation(cls);
-            ClientFactoryBean clientFactory = isJSR181SEnabled ? new JaxWsClientFactoryBean() 
-                        : new ClientFactoryBean();            
+        ClientFactoryBean clientFactory = null;
+        try {
+            if (cls == null) {
+                clientFactory = new ClientFactoryBean();
+                clientFactory.setServiceFactory(new WSDLSoapServiceFactoryBean());
+            } else {
+                boolean isJSR181SEnabled = CxfEndpointUtils.hasWebServiceAnnotation(cls);
+                clientFactory = isJSR181SEnabled ? new JaxWsClientFactoryBean() 
+                        : new ClientFactoryBean(); 
+            }    
             return clientFactory;
         } catch (Exception e) {
             throw new CamelException(e);

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataInInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataInInterceptor.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataInInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataInInterceptor.java Sun Oct 21 00:56:26 2007
@@ -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.cxf.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class DataInInterceptor extends AbstractInDatabindingInterceptor {
+    private static final Logger LOG = LogUtils.getL7dLogger(DataInInterceptor.class);
+    
+    public DataInInterceptor() {
+        super(Phase.UNMARSHAL);       
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
+        try {            
+            // put the payload source as a document
+            message.setContent(Source.class, new DOMSource(StaxUtils.read(xmlReader)));
+        } catch (XMLStreamException e) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION",
+                                                                   LOG),
+                            e);
+        }        
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataOutInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataOutInterceptor.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataOutInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/DataOutInterceptor.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,61 @@
+/**
+ * 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.util;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class DataOutInterceptor extends AbstractOutDatabindingInterceptor {
+    private static final Logger LOG = LogUtils.getL7dLogger(DataOutInterceptor.class);
+    
+    public DataOutInterceptor() {
+        super(Phase.MARSHAL);        
+    }
+    
+    public void handleMessage(Message message) throws Fault {
+        XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
+        try {            
+            // put the payload source as a document
+            Source source = message.getContent(Source.class);            
+            if(source != null ) {
+                XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(source);
+                StaxUtils.copy(xmlReader, xmlWriter);
+            }    
+        } catch (XMLStreamException e) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION",
+                                                                   LOG, e),
+                            e);
+        } 
+        
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/Dummy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/Dummy.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/Dummy.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/Dummy.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,22 @@
+/**
+ * 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.util;
+
+// Dummy class for setting service class
+public class Dummy {
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduit.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduit.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduit.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduit.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,64 @@
+/**
+ * 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.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+public class NullConduit implements Conduit{
+
+    public void close() {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void close(Message message) throws IOException {        
+        OutputStream outputStream = message.getContent(OutputStream.class);
+        if (outputStream != null) {
+            outputStream.close();
+        }
+    }
+
+    public Destination getBackChannel() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public EndpointReferenceType getTarget() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void prepare(Message message) throws IOException {
+        CachedOutputStream outputStream = new CachedOutputStream();
+        message.setContent(OutputStream.class, outputStream);
+        
+    }
+
+    public void setMessageObserver(MessageObserver observer) {
+        // TODO Auto-generated method stub
+        
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduitSelector.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduitSelector.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduitSelector.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullConduitSelector.java Sun Oct 21 00:56:26 2007
@@ -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.cxf.util;
+
+import org.apache.cxf.endpoint.ConduitSelector;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.Conduit;
+
+public class NullConduitSelector implements ConduitSelector {
+    private Endpoint endpoint;
+    private NullConduit nullConduit;
+    
+    public NullConduitSelector() {
+        nullConduit = new NullConduit();
+    }
+    public void complete(Exchange exchange) {
+        //do nothing here
+        
+    }
+
+    public Endpoint getEndpoint() {
+       return endpoint;
+    }
+
+    public void prepare(Message message) {
+        //do nothing here
+        
+    }
+
+    public Conduit selectConduit(Message message) {        
+        return nullConduit;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+        
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestination.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestination.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestination.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestination.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,61 @@
+/**
+ * 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.util;
+
+import java.io.IOException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.ChainInitiationObserver;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+public class NullDestination implements Destination{
+    MessageObserver messageObserver;
+       
+    public NullDestination() {
+        // do nothing here   
+    }
+        
+    public EndpointReferenceType getAddress() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address) throws IOException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public MessageObserver getMessageObserver() {
+        return messageObserver;
+    }
+
+    public void shutdown() {
+        messageObserver = null;
+        
+    }
+
+    public void setMessageObserver(MessageObserver observer) {
+        messageObserver = observer;
+        
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestinationFactory.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestinationFactory.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestinationFactory.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/NullDestinationFactory.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,47 @@
+/**
+ * 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.util;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+
+public class NullDestinationFactory implements DestinationFactory{
+
+    public Destination getDestination(EndpointInfo ei) throws IOException {
+        // setup the endpoint information
+        ei.setAddress("local://" + ei.getService().getName().toString() + "/" + ei.getName().getLocalPart());
+        // working as the dispatch mode, the binding factory will not add interceptor
+        ei.getBinding().setProperty(AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
+        // do nothing here , just creating a null destination to store the observer
+        return new NullDestination();
+    }
+
+    public List<String> getTransportIds() {        
+        return null;
+    }
+
+    public Set<String> getUriPrefixes() {        
+        return null;
+    }
+
+}

Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/WSDLSoapServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/WSDLSoapServiceFactoryBean.java?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/WSDLSoapServiceFactoryBean.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/WSDLSoapServiceFactoryBean.java Sun Oct 21 00:56:26 2007
@@ -0,0 +1,120 @@
+/**
+ * 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.util;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
+import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapHeaderOutFilterInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
+import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
+import org.apache.cxf.frontend.MethodDispatcher;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+
+//The service factorybean which just create the service for soap component
+public class WSDLSoapServiceFactoryBean extends ReflectionServiceFactoryBean {
+    private QName serviceName;
+    private QName endpointName;
+    
+    @Override
+    public Service create() {
+        
+        WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), getWsdlURL(), null);
+        setService(factory.create()); 
+        initializeSoapInterceptors(); 
+        //disable the date interceptors 
+        updateEndpointInfors();
+        createEndpoints();
+
+        return getService();
+    }
+    
+    
+    private void updateEndpointInfors() {
+        Service service = getService();
+    
+        for (ServiceInfo inf : service.getServiceInfos()) {
+            for (EndpointInfo ei : inf.getEndpoints()) {
+                //setup the endpoint address
+                ei.setAddress("local://" + ei.getService().getName().toString() + "/" + ei.getName().getLocalPart());
+                // working as the dispatch mode, the binding factory will not add interceptor
+                ei.getBinding().setProperty(AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
+            }
+        }    
+        
+    }
+
+
+    // do not handle any payload information here
+    private void initializeSoapInterceptors() {
+        getService().getInInterceptors().add(new DataInInterceptor());
+        getService().getInInterceptors().add(new ReadHeadersInterceptor(getBus()));
+        getService().getInInterceptors().add(new MustUnderstandInterceptor());
+        getService().getInInterceptors().add(new AttachmentInInterceptor());
+        
+       
+        getService().getInInterceptors().add(new StaxInInterceptor());
+        getService().getInInterceptors().add(new SoapActionInInterceptor());
+        
+        getService().getOutInterceptors().add(new DataOutInterceptor());
+        getService().getOutInterceptors().add(new SoapActionOutInterceptor());
+        getService().getOutInterceptors().add(new AttachmentOutInterceptor());
+        getService().getOutInterceptors().add(new StaxOutInterceptor());
+        getService().getOutInterceptors().add(new SoapHeaderOutFilterInterceptor());
+       
+        getService().getOutInterceptors().add(new SoapPreProtocolOutInterceptor());
+        getService().getOutInterceptors().add(new SoapOutInterceptor(getBus()));
+        getService().getOutFaultInterceptors().add(new SoapOutInterceptor(getBus()));
+    }
+    
+    public void setServiceName(QName name) {
+        serviceName = name;
+    }
+    
+    public String getServiceName() {
+        return serviceName.toString();
+    }
+    
+    public QName getServiceQName() {
+        return serviceName;
+    }
+    
+    public QName getEndpointName() {
+        // get the endpoint name if it is not set
+        if (endpointName == null) {
+            endpointName = getService().getEndpoints().keySet().iterator().next();
+        }
+        return endpointName;
+    }
+    
+    public void setEndpointName(QName name) {
+        endpointName = name;
+    }
+}

Modified: activemq/camel/trunk/components/camel-cxf/src/main/resources/org/apache/camel/component/cxf/util/Messages.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/resources/org/apache/camel/component/cxf/util/Messages.properties?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/resources/org/apache/camel/component/cxf/util/Messages.properties (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/resources/org/apache/camel/component/cxf/util/Messages.properties Sun Oct 21 00:56:26 2007
@@ -22,4 +22,5 @@
 CLASS_X_NOT_FOUND = Failed to load service class due to {0}.
 SVC_QNAME_NOT_FOUND_X = Service QName is not provided in the URI {0} nor in the endpoint's property.
 INVALID_MESSAGE_FORMAT_XXXX = {0} is an invalid value for messageFormat.  Please choose from: POJO, PAYLOAD, or MESSAGE. 
-SVC_CLASS_PROP_IS_REQUIRED_X = serviceClass property is expected for this endpoint {0}
+SVC_CLASS_PROP_IS_REQUIRED_X = Service Class property is expected for this endpoint {0}
+XMLSTREAM_EXCEPTION = XML stream exception: {0}.
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java?rev=586863&r1=586862&r2=586863&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapTest.java Sun Oct 21 00:56:26 2007
@@ -16,23 +16,77 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
 import org.apache.camel.CamelTemplate;
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.staxutils.StaxUtils;
 
 public class CxfSoapTest extends ContextTestSupport {
+    private static final String SOAP_STRING = 
+        "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" 
+        + "<soap:Body><testMethod xmlns=\"http://camel.apache.org/testService\" />"
+        + "</soap:Body></soap:Envelope>";
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("soap:direct:consumer?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl").to("mock:consumer");
+                //from("soap:direct:consumer?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl").to("mock:consumer");
+                from("soap:direct:consumer?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl").to("mock:consumer").process(new Processor() {
+                    public void process(Exchange e) {                        
+                        Object result = e.getIn().getBody();                        
+                        e.getOut().setBody(result);
+                    }
+                });
                 from("direct:provider").to("soap:mock:provider?soap.wsdl=classpath:hello/HelloWorld-DOC.wsdl");
             }
         };
     }
 
-    public void testSoap() throws Exception {
-        template.sendBody("direct:consumer", "<hello/>");
-
+    public void testSoapConsumer() throws Exception {        
+        // send out the request message
+        URL request = this.getClass().getResource("SoapRequest.xml");
+        File requestFile = new File(request.toURI());
+        FileInputStream inputStream = new FileInputStream(requestFile);        
+        Object result = template.sendBody("direct:consumer", inputStream);
+        assertFalse("The result should not be changed", inputStream.equals(result));
+        assertTrue("result should be a inputstream", result instanceof InputStream);
+        CachedOutputStream bos = new CachedOutputStream();
+        IOUtils.copy((InputStream) result, bos);
+        bos.flush();
+        ((InputStream)result).close();        
+        assertEquals("We should find the soap body string here", 
+                   SOAP_STRING, bos.getOut().toString());
+        
+        
+    }
+    
+    public void testSoapProvider() throws Exception {
+        // set out the source message
+        URL request = this.getClass().getResource("RequestBody.xml");
+        File requestFile = new File(request.toURI());
+        FileInputStream inputStream = new FileInputStream(requestFile);
+        XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
+        DOMSource source = new DOMSource(StaxUtils.read(xmlReader));        
+        Object result = template.sendBody("direct:provider", source);
+        assertFalse("The result should not be changed", source.equals(result));
+        assertTrue("The result should be the instance of DOMSource", result instanceof DOMSource);
+        assertEquals("The DOMSource should be equal", XMLUtils.toString(source), XMLUtils.toString((Source)result));
     }
 }

Added: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/RequestBody.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/RequestBody.xml?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/RequestBody.xml (added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/RequestBody.xml Sun Oct 21 00:56:26 2007
@@ -0,0 +1 @@
+<testMethod xmlns="http://camel.apache.org/testService" />
\ No newline at end of file

Added: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapRequest.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapRequest.xml?rev=586863&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapRequest.xml (added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapRequest.xml Sun Oct 21 00:56:26 2007
@@ -0,0 +1,27 @@
+<?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.
+-->
+<soapenv:Envelope xmlns="http://somenamespace.pl"
+	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<soapenv:Body>
+		<testMethod xmlns="http://camel.apache.org/testService" />	
+	</soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file