camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r917539 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/feature/ main/java/org/apache/camel/component/cxf/interceptors/ test/java/org/apache/camel/component/cxf/...
Date Mon, 01 Mar 2010 14:13:24 GMT
Author: wtam
Date: Mon Mar  1 14:13:23 2010
New Revision: 917539

URL: http://svn.apache.org/viewvc?rev=917539&view=rev
Log:
[CAMEL-2495] Application SOAP fault support in camel-cxf PAYLOAD mode

Added:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
  (with props)
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
Mon Mar  1 14:13:23 2010
@@ -93,24 +93,31 @@
                     throw new Fault(e);
                 }
                 
-                // check failure
-                if (camelExchange.isFailed()) {
-                    // either Fault or Exception
-                    Throwable t = (camelExchange.hasOut() && camelExchange.getOut().isFault())

-                        ? (Throwable)camelExchange.getOut().getBody() : camelExchange.getException();
-                    throw (t instanceof Fault) ? (Fault)t : new Fault(t);
-                }
-                
+                checkFailure(camelExchange);
+              
                 // bind the Camel response into a CXF response
                 if (camelExchange.getPattern().isOutCapable()) {
                     binding.populateCxfResponseFromExchange(camelExchange, cxfExchange);
                 }
                 
+                // check failure again as fault could be discovered by converter
+                checkFailure(camelExchange);
+
                 // copy the headers javax.xml.ws header back
                 binding.copyJaxWsContext(cxfExchange, context);
                 // response should have been set in outMessage's content
                 return null;
             }
+
+            private void checkFailure(org.apache.camel.Exchange camelExchange) throws Fault
{
+                if (camelExchange.isFailed()) {
+                    // either Fault or Exception
+                    Throwable t = (camelExchange.hasOut() && camelExchange.getOut().isFault())

+                        ? (Throwable)camelExchange.getOut().getBody() : camelExchange.getException();
+                    throw (t instanceof Fault) ? (Fault)t : new Fault(t);
+                }
+                                
+            }
             
         });
         server = svrBean.create();        

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfHeaderFilterStrategy.java
Mon Mar  1 14:13:23 2010
@@ -66,7 +66,8 @@
         // Since CXF can take the content-type from the protocol header
         // we need to filter this header of this name.
         getOutFilter().add("content-type");
-        
+        getOutFilter().add("Content-Type");
+
         // Filter out Content-Length since it can fool Jetty (HttpGenerator) to 
         // close response output stream prematurely.  (It occurs when the
         // message size (e.g. with attachment) is large and response content length 

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
Mon Mar  1 14:13:23 2010
@@ -21,6 +21,7 @@
 import org.apache.camel.component.cxf.interceptors.DOMInInterceptor;
 import org.apache.camel.component.cxf.interceptors.DOMOutInterceptor;
 import org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor;
+import org.apache.camel.component.cxf.interceptors.PayloadFaultInInterceptor;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
 import org.apache.cxf.common.logging.LogUtils;
@@ -46,7 +47,7 @@
         Phase.MARSHAL, Phase.MARSHAL_ENDING, Phase.PRE_LOGICAL, Phase.PRE_LOGICAL_ENDING,
Phase.POST_LOGICAL,
         Phase.POST_LOGICAL_ENDING
     };
-
+    
     @Override
     public void initialize(Client client, Bus bus) {
         removeInterceptorWhichIsInThePhases(client.getInInterceptors(), REMOVING_IN_PHASES);
@@ -58,7 +59,12 @@
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getService().getOutInterceptors(),
REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getOutInterceptors(), REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getBinding().getOutInterceptors(),
REMOVING_OUT_PHASES);
-
+        
+        removeInterceptorWhichIsInThePhases(client.getInFaultInterceptors(), REMOVING_IN_PHASES);
+        removeInterceptorWhichIsInThePhases(client.getEndpoint().getService().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        removeInterceptorWhichIsInThePhases(client.getEndpoint().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        removeInterceptorWhichIsInThePhases(client.getEndpoint().getBinding().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        
         addDataHandlingInterceptors(client.getEndpoint().getBinding());        
     }
 
@@ -72,7 +78,11 @@
         removeInterceptorWhichIsInThePhases(server.getEndpoint().getService().getOutInterceptors(),
REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(server.getEndpoint().getOutInterceptors(), REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(server.getEndpoint().getBinding().getOutInterceptors(),
REMOVING_OUT_PHASES);
-
+        
+        removeInterceptorWhichIsInThePhases(server.getEndpoint().getService().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        removeInterceptorWhichIsInThePhases(server.getEndpoint().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        removeInterceptorWhichIsInThePhases(server.getEndpoint().getBinding().getInFaultInterceptors(),
REMOVING_IN_PHASES);
+        
         addDataHandlingInterceptors(server.getEndpoint().getBinding());        
     }
 
@@ -80,6 +90,7 @@
         binding.getInInterceptors().add(new DOMInInterceptor());
         binding.getOutInterceptors().add(new DOMOutInterceptor());
         binding.getOutInterceptors().add(new PayloadContentRedirectInterceptor());
+        binding.getInFaultInterceptors().add(new PayloadFaultInInterceptor());
     }
 
     @Override

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
Mon Mar  1 14:13:23 2010
@@ -17,6 +17,8 @@
 package org.apache.camel.component.cxf.interceptors;
 
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -30,6 +32,7 @@
 import org.apache.cxf.staxutils.StaxUtils;
 
 public class PayloadContentRedirectInterceptor extends AbstractPhaseInterceptor<Message>
{
+    private static final Logger LOG = Logger.getLogger(PayloadContentRedirectInterceptor.class.getName());
 
     public PayloadContentRedirectInterceptor() {
         super(Phase.POST_STREAM);
@@ -37,18 +40,25 @@
 
     @SuppressWarnings("unchecked")
     public void handleMessage(Message message) throws Fault {
-        // check the fault from the message
-        Throwable ex = message.getContent(Throwable.class);
-        if (ex != null) {
-            if (ex instanceof Fault) {
-                throw (Fault)ex;
-            } else {
-                throw new Fault(ex);
+        
+        XMLStreamWriter out = message.getContent(XMLStreamWriter.class);
+
+        if (out == null) {
+            if (LOG.isLoggable(Level.FINEST)) {
+                LOG.finest("XMLStreamWriter is null");
             }
+            return;
         }
 
-        XMLStreamWriter out = message.getContent(XMLStreamWriter.class);
         List<Element> in = message.get(List.class);
+
+        if (in == null) {
+            if (LOG.isLoggable(Level.FINEST)) {
+                LOG.finest("Payload List is null");
+            }
+            return;
+        }
+
         try {
             for (Element el : in) {
                 StaxUtils.writeElement(el, out, false, true);
@@ -56,5 +66,6 @@
         } catch (XMLStreamException e) {
             throw new Fault(e);
         }
+        
     }
 }

Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java?rev=917539&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
(added)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
Mon Mar  1 14:13:23 2010
@@ -0,0 +1,96 @@
+/**
+ * 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.interceptors;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+
+/**
+ * Interceptor to create a Fault object from a CXF message
+ * 
+ * @version @Revision: 789534 $
+ */
+public class PayloadFaultInInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private static final Logger LOG = Logger.getLogger(PayloadFaultInInterceptor.class.getName());
+
+    public PayloadFaultInInterceptor() {
+        this(Phase.POST_PROTOCOL);
+    }
+
+    public PayloadFaultInInterceptor(String phase) {
+        super(phase);
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        XMLStreamReader reader = message.getContent(XMLStreamReader.class);
+        
+        if (message instanceof SoapMessage) {
+            message.setContent(Exception.class, createFault((SoapMessage)message, reader));
+        } else {       
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Message type '" + message.getClass().getName() + "' is not supported.");
+            }
+        }
+    }
+
+    public static SoapFault createFault(SoapMessage message, 
+                                           XMLStreamReader reader) {
+        String exMessage = null;
+        QName faultCode = null;
+        String role = null;
+        Element detail = null;
+        
+        try {
+            while (reader.nextTag() == XMLStreamReader.START_ELEMENT) {
+                if (reader.getLocalName().equals("faultcode")) {
+                    faultCode = StaxUtils.readQName(reader);
+                } else if (reader.getLocalName().equals("faultstring")) {
+                    exMessage = reader.getElementText();
+                } else if (reader.getLocalName().equals("faultactor")) {
+                    role = reader.getElementText();
+                } else if (reader.getLocalName().equals("detail")) {
+                    detail = StaxUtils.read(reader).getDocumentElement();
+                }
+            }
+        } catch (XMLStreamException e) {
+            throw new SoapFault("Could not parse message.",
+                                e,
+                                message.getVersion().getSender());
+        }
+
+        SoapFault fault = new SoapFault(exMessage, faultCode);
+        fault.setDetail(detail);
+        fault.setRole(role);
+        return fault;
+    }
+
+}

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
Mon Mar  1 14:13:23 2010
@@ -28,6 +28,10 @@
 import org.apache.camel.wsdl_first.PersonImpl;
 import org.apache.camel.wsdl_first.PersonService;
 import org.apache.camel.wsdl_first.UnknownPersonFault;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 
 import org.junit.After;
 import org.junit.Before;
@@ -74,6 +78,11 @@
         PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
 
         Person client = ss.getSoap();
+        
+        Client c = ClientProxy.getClient(client);
+        c.getInInterceptors().add(new LoggingInInterceptor());
+        c.getOutInterceptors().add(new LoggingOutInterceptor());
+        
         Holder<String> personId = new Holder<String>();
         personId.value = "hello";
         Holder<String> ssn = new Holder<String>();
@@ -83,4 +92,33 @@
 
     }
     
+    @Test
+    public void testApplicationFault() {
+        URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+        PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
+
+        Person client = ss.getSoap();
+        
+        Client c = ClientProxy.getClient(client);
+        c.getInInterceptors().add(new LoggingInInterceptor());
+        c.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Holder<String> personId = new Holder<String>();
+        personId.value = "";
+        Holder<String> ssn = new Holder<String>();
+        Holder<String> name = new Holder<String>();
+        Throwable t = null;
+        try {
+            client.getPerson(personId, ssn, name);
+            fail("expect UnknownPersonFault");
+        } catch (UnknownPersonFault e) {
+            t = e;
+        }
+        
+        assertNotNull(t);
+        assertTrue(t instanceof UnknownPersonFault);
+        
+    }
+    
+    
 }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
Mon Mar  1 14:13:23 2010
@@ -27,6 +27,7 @@
 import org.apache.camel.wsdl_first.Person;
 import org.apache.camel.wsdl_first.PersonImpl;
 import org.apache.camel.wsdl_first.PersonService;
+import org.apache.camel.wsdl_first.UnknownPersonFault;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -88,6 +89,41 @@
         client2.getPerson(personId2, ssn2, name2);
         assertEquals("Bonjour", name2.value);
     }
+    
+    @Test
+    public void testSoapFaultRoutes() {
+        URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+        PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first",
+                                                                "PersonService"));
+        // test message mode
+        Person client = ss.getSoap();
+        Holder<String> personId = new Holder<String>();
+        personId.value = "";
+        Holder<String> ssn = new Holder<String>();
+        Holder<String> name = new Holder<String>();
+        Throwable t = null;
+        try {
+            client.getPerson(personId, ssn, name);
+            fail("Expect exception");
+        } catch (UnknownPersonFault e) {
+            t = e;
+        }
+        assertTrue(t instanceof UnknownPersonFault);
+
+        // test PAYLOAD mode
+        Person client2 = ss.getSoap2();
+        Holder<String> personId2 = new Holder<String>();
+        personId2.value = "";
+        Holder<String> ssn2 = new Holder<String>();
+        Holder<String> name2 = new Holder<String>();
+        try {
+            client2.getPerson(personId2, ssn2, name2);
+            fail("Expect exception");
+        } catch (UnknownPersonFault e) {
+            t = e;
+        }
+        assertTrue(t instanceof UnknownPersonFault);
+    }
 
 
 }

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java?rev=917539&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
Mon Mar  1 14:13:23 2010
@@ -0,0 +1,105 @@
+/**
+ * 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.StringReader;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+
+import org.w3c.dom.Element;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.wsdl_first.Person;
+import org.apache.camel.wsdl_first.PersonService;
+import org.apache.camel.wsdl_first.UnknownPersonFault;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.junit.Test;
+
+/**
+ * Unit test to verify CxfConsumer to generate SOAP fault in PAYLOAD mode
+ * 
+ * @version @Revision: 789534 $
+ */
+public class CxfConsumerPayloadFaultTest extends CamelTestSupport {
+    protected static final String PORT_NAME_PROP = "portName={http://camel.apache.org/wsdl-first}soap";
+    protected static final String SERVICE_NAME = "{http://camel.apache.org/wsdl-first}PersonService";
+    protected static final String SERVICE_NAME_PROP =  "serviceName=" + SERVICE_NAME;
+    protected static final String WSDL_URL_PROP = "wsdlURL=classpath:person.wsdl";
+    protected static final String SERVICE_ADDRESS = "http://localhost:8092/PersonService";
+    
+    protected static String FROM_URI = "cxf://" + SERVICE_ADDRESS + "?" 
+        + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&dataFormat="
+ DataFormat.PAYLOAD;
+
+    protected static String DETAILS = "<detail><UnknownPersonFault xmlns=\"http://camel.apache.org/wsdl-first/types\">"
+        + "<personId></personId></UnknownPersonFault></detail>";
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from(FROM_URI).process(new Processor() {
+                    public void process(final Exchange exchange) throws Exception {
+                        QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/",
"Server");
+                        SoapFault fault = new SoapFault("Get the null value of person name",
faultCode);
+                        Element details = DOMUtils.readXml(new StringReader(DETAILS)).getDocumentElement();
+                        fault.setDetail(details);
+                        exchange.setException(fault);
+                        
+                    }
+                });
+            }
+        };
+    }
+    
+    @Test
+    public void testInvokingFromCxfClient() throws Exception {
+        URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+        PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
+
+        Person client = ss.getSoap();
+                
+        Client c = ClientProxy.getClient(client);
+        c.getInInterceptors().add(new LoggingInInterceptor());
+        c.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Holder<String> personId = new Holder<String>();
+        personId.value = "";
+        Holder<String> ssn = new Holder<String>();
+        Holder<String> name = new Holder<String>();
+        Throwable t = null;
+        try {
+            client.getPerson(personId, ssn, name);
+            fail("expect UnknownPersonFault");
+        } catch (UnknownPersonFault e) {
+            t = e;
+        }
+        
+        assertNotNull(t);
+        assertTrue(t instanceof UnknownPersonFault);
+
+    }
+}

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml?rev=917539&r1=917538&r2=917539&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml
(original)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml
Mon Mar  1 14:13:23 2010
@@ -56,15 +56,9 @@
                    xmlns:person="http://camel.apache.org/wsdl-first">
    </cxf:cxfEndpoint>
    
-
-    <!-- setup our error handler as the deal letter channel -->
-    <bean id="errorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
-        <property name="deadLetterUri" value="mock:error"/>
-    </bean>
-
    <bean id="processor" class="org.apache.camel.processor.Logger"/>
 
-   <camelContext errorHandlerRef="errorHandler" id="camel" xmlns="http://camel.apache.org/schema/spring">
+   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
       <route>
          <from uri="cxf:bean:routerEndpoint?dataFormat=MESSAGE" />
          <to uri="cxf:bean:serviceEndpoint?dataFormat=MESSAGE" />



Mime
View raw message