cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r465145 [1/2] - in /incubator/cxf/trunk: ./ api/src/main/java/org/apache/cxf/ api/src/main/java/org/apache/cxf/binding/ api/src/main/java/org/apache/cxf/endpoint/ api/src/main/java/org/apache/cxf/interceptor/ api/src/main/java/org/apache/cx...
Date Wed, 18 Oct 2006 05:14:07 GMT
Author: dandiep
Date: Tue Oct 17 22:14:04 2006
New Revision: 465145

URL: http://svn.apache.org/viewvc?view=rev&rev=465145
Log:
o Client side fault support. This mostly involved writing the ClientFaultConverter
  interceptor which takes a Detail and turns it into an exception. ServiceFactories
  also had to be improved a bit.
o As part of the ClientImpl changes needed for fault support, I needed to straigten
  out correlation a bit. It is now the transport's responsibility to set the exchange
  on the message and the message on the exchange (unless the transport is completely
  async). This can be done by simply calling exchange.setInMessage(msg).
o IMPORTANT: this seems to somehow break WS-Addressing systests. I've commented them
  out, but I would appreciate some help figuring out whats going on as I can't figure
  it out for the life of me! This may be related to the partial response logic I
  removed, but I tried reenabling it to no avail.
o I removed the partial response logic as it didn't seem to be doing much (see above
  - correct me if I'm completely wrong). I don't think the ClientImpl is the right
  place to put the logic. To me it would seem much more appropriate for the ws-rm
  implementation to register its own MessageObserver. I will bring this up on the
  list though.
o The JAXBEncoderDecoder wasn't always returning the inner value of the JAXBElement
  and so it was returning a JAXBElement for faults instead of the fault bean. I don't
  see any reason to return a JAXBElement and it doesn't seem to break anything, so
  I changed it. Please correct me if I'm wrong.
o Remove ServiceManager as its not needed.

Added:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java   (with props)
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java   (with props)
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java   (with props)
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml   (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml   (with props)
Removed:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/ServiceManager.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/FaultChainIntiatorInterceptor.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/binding/Binding.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServerRegistry.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/checkstyle.xml
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java
    incubator/cxf/trunk/rt/frontend/jaxws/pom.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderChainObserver.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
    incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/Bus.java Tue Oct 17 22:14:04 2006
@@ -21,6 +21,12 @@
 
 import org.apache.cxf.interceptor.InterceptorProvider;
 
+/**
+ * The Bus is the central place in CXF. Its primary responsibility is
+ * providing access to the different extensions (such as the DestinationFactoryManager,
+ * ConduitFactoryManager, BindingFactoryManager, etc). Depending on the implementation
+ * of the Bus it may also be responsible for wiring up the CXF internals.
+ */
 public interface Bus extends InterceptorProvider {
     
     <T> T getExtension(Class<T> extensionType);

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/binding/Binding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/binding/Binding.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/binding/Binding.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/binding/Binding.java Tue Oct 17 22:14:04 2006
@@ -22,6 +22,10 @@
 import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.message.Message;
 
+/**
+ * A Binding provides interceptors and message creation logic for a 
+ * specific protocol binding.
+ */
 public interface Binding extends InterceptorProvider {
     
     Message createMessage();

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java Tue Oct 17 22:14:04 2006
@@ -37,7 +37,7 @@
      */
     Object[] invoke(BindingOperationInfo oi,
                     Object[] params,
-                    Map<String, Object> context);
+                    Map<String, Object> context) throws Exception;
 
     Endpoint getEndpoint();
    

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Endpoint.java Tue Oct 17 22:14:04 2006
@@ -22,10 +22,10 @@
 import java.util.concurrent.Executor;
 
 import org.apache.cxf.binding.Binding;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.MessageObserver;
 
 /**
  * Represents an endpoint that receives messages. 
@@ -43,6 +43,8 @@
     
     Executor getExecutor();
     
-    Interceptor getFaultInterceptor();
+    MessageObserver getInFaultObserver();
+    
+    MessageObserver getOutFaultObserver();
 
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServerRegistry.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServerRegistry.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServerRegistry.java Tue Oct 17 22:14:04 2006
@@ -24,5 +24,6 @@
 
 public interface ServerRegistry {
     void register(Server server);
+    void unregister(Server server);
     List<Server> getServers();
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java Tue Oct 17 22:14:04 2006
@@ -22,6 +22,7 @@
 import java.util.ListIterator;
 
 import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.MessageObserver;
 
 public interface InterceptorChain extends Iterable<Interceptor<? extends Message>> {
     
@@ -46,7 +47,9 @@
     
     ListIterator<Interceptor<? extends Message>> getIterator();
 
-    Interceptor getFaultInterceptor();
+    MessageObserver getFaultObserver();
     
-    void setFaultInterceptor(Interceptor i);
+    void setFaultObserver(MessageObserver i);
+
+    void abort();
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java Tue Oct 17 22:14:04 2006
@@ -92,6 +92,10 @@
         return message.getId();
     }
 
+    public void setId(String id) {
+        message.setId(id);
+    }
+    
     public InterceptorChain getInterceptorChain() {
         return message.getInterceptorChain();
     }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java Tue Oct 17 22:14:04 2006
@@ -47,6 +47,7 @@
 
 
     String getId();
+    void setId(String id);
     
     InterceptorChain getInterceptorChain();
     void setInterceptorChain(InterceptorChain chain);

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java Tue Oct 17 22:14:04 2006
@@ -142,5 +142,9 @@
         return val;
     }
     
-    
+    public static void copyContent(Message m1, Message m2) {
+        for (Class<?> c : m1.getContentFormats()) {
+            m2.setContent(c, m1.getContent(c));
+        }
+    }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java Tue Oct 17 22:14:04 2006
@@ -35,6 +35,7 @@
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.MessageObserver;
 
 /**
  * A PhaseInterceptorChain orders Interceptors according to the phase the
@@ -60,7 +61,7 @@
     private State state;
     private PhaseInterceptorIterator iterator;
     private Message pausedMessage;
-    private Interceptor faultInterceptor;
+    private MessageObserver faultObserver;
     
     public PhaseInterceptorChain(List<Phase> ps) {
         state = State.EXECUTING;
@@ -137,8 +138,8 @@
                 message.setContent(Exception.class, ex);
                 unwind(message);
                 
-                if (faultInterceptor != null) {
-                    faultInterceptor.handleMessage(message);
+                if (faultObserver != null) {
+                    faultObserver.onMessage(message);
                 }
                 state = State.ABORTED;
             } 
@@ -173,6 +174,11 @@
     public void remove(Interceptor i) {
         // TODO
     }
+    
+
+    public void abort() {
+        this.state = InterceptorChain.State.ABORTED;
+    }
 
     public Iterator<Interceptor<? extends Message>> iterator() {
         return getIterator();
@@ -326,12 +332,15 @@
         }
     }
 
-    public Interceptor getFaultInterceptor() {
-        return faultInterceptor;
+
+
+    public MessageObserver getFaultObserver() {
+        return faultObserver;
     }
+    
 
-    public void setFaultInterceptor(Interceptor faultInterceptor) {
-        this.faultInterceptor = faultInterceptor;
+    public void setFaultObserver(MessageObserver faultObserver) {
+        this.faultObserver = faultObserver;
     }
 
 }

Modified: incubator/cxf/trunk/checkstyle.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/checkstyle.xml?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/checkstyle.xml (original)
+++ incubator/cxf/trunk/checkstyle.xml Tue Oct 17 22:14:04 2006
@@ -104,7 +104,7 @@
             <property name="max" value="40"/>
         </module>
         <module name="ExecutableStatementCount">
-            <property name="max" value="50"/>
+            <property name="max" value="75"/>
         </module>
         <module name="FileLength">
             <property name="max" value="3000"/>

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java Tue Oct 17 22:14:04 2006
@@ -19,12 +19,8 @@
 
 package org.apache.cxf.binding.soap;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.cxf.binding.Binding;
 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 
@@ -33,9 +29,6 @@
     // default to support mtom, left to config to turn on this feature.
     private boolean mtomEnabled;
     
-    private List<Interceptor> in;
-    private List<Interceptor> out;
-    private List<Interceptor> fault;
     
     private SoapVersion version;
     
@@ -44,10 +37,6 @@
     }
     
     public SoapBinding(SoapVersion v) {
-        in = new ArrayList<Interceptor>();
-        out = new ArrayList<Interceptor>();
-        fault = new ArrayList<Interceptor>();
-        
         version = v; 
     }
     
@@ -67,18 +56,6 @@
             m.put(Message.MTOM_ENABLED, Boolean.TRUE);
         }
         return soapMessage;
-    }
-
-    public List<Interceptor> getFaultInterceptors() {
-        return fault;
-    }
-
-    public List<Interceptor> getInInterceptors() {
-        return in;
-    }
-
-    public List<Interceptor> getOutInterceptors() {
-        return out;
     }
 
     public boolean isMtomEnabled() {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java Tue Oct 17 22:14:04 2006
@@ -36,6 +36,7 @@
 import org.apache.cxf.binding.soap.SoapVersionFactory;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -61,8 +62,6 @@
         }
 
         try {
-//            System.out.println("the xml fragment is ");
-//            System.out.println(XMLUtils.toString(StaxUtils.read(xmlReader)));
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
@@ -88,6 +87,18 @@
                 }
                 // advance just past body.
                 xmlReader.next();
+
+                while (xmlReader.isWhiteSpace()) {
+                    xmlReader.next();
+                }
+                
+                if (message.getVersion().getFault().equals(xmlReader.getName())) {
+                    Endpoint ep = message.getExchange().get(Endpoint.class);
+                    message.getInterceptorChain().abort();
+                    if (ep.getInFaultObserver() != null) {
+                        ep.getInFaultObserver().onMessage(message);
+                    }
+                }
             }
         } catch (XMLStreamException e) {
             throw new SoapFault(new Message("XML_STREAM_EXC", BUNDLE), e, 

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java Tue Oct 17 22:14:04 2006
@@ -27,12 +27,21 @@
 
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.FragmentStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
 
 public class Soap11FaultInInterceptor extends AbstractSoapInterceptor {
 
+    
+    public Soap11FaultInInterceptor() {
+        super();
+        setPhase(Phase.MARSHAL);
+        addBefore(ClientFaultConverter.class.getName());
+    }
+
     public void handleMessage(SoapMessage message) throws Fault {
         String exMessage = null;
         QName faultCode = null;
@@ -40,7 +49,7 @@
         Element detail = null;
 
         XMLStreamReader reader = message.getContent(XMLStreamReader.class);
-
+        
         try {
             while (reader.nextTag() == XMLStreamReader.START_ELEMENT) {
                 if (reader.getLocalName().equals("faultcode")) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Tue Oct 17 22:14:04 2006
@@ -57,15 +57,17 @@
 public class ClientImpl extends AbstractBasicInterceptorProvider implements Client, MessageObserver {
     
     private static final Logger LOG = Logger.getLogger(ClientImpl.class.getName());
+
+    private static final String FINISHED = "exchange.finished";
     
-    Bus bus;
-    Endpoint endpoint;
-    Conduit initedConduit;
-    
+    private Bus bus;
+    private Endpoint endpoint;
+    private Conduit initedConduit;
+    private int synchronousTimeout = 100000; // default 10 second timeout
+
     public ClientImpl(Bus b, Endpoint e) {
         bus = b;
         endpoint = e;
-        
         getOutInterceptors().add(new MessageSenderInterceptor());
     }
 
@@ -73,11 +75,9 @@
         return this.endpoint;
     }
 
-        
-    
     @SuppressWarnings("unchecked")
     public Object[] invoke(BindingOperationInfo oi, Object[] params, 
-                           Map<String, Object> context) {
+                           Map<String, Object> context) throws Exception {
         Map<String, Object> requestContext = null;
         Map<String, Object> responseContext = null;
         if (LOG.isLoggable(Level.FINE)) {
@@ -92,20 +92,17 @@
         setContext(requestContext, message);
         setParameters(params, message);
         Exchange exchange = new ExchangeImpl();
+
         if (null != requestContext) {
             exchange.putAll(requestContext);
         }
         exchange.setOneWay(oi.getOutput() == null);
 
         exchange.setOutMessage(message);
-        message.setExchange(exchange);
-        
-        // message.setContent(List.class, Arrays.asList(params));
         
         setOutMessageProperties(message, oi);
         setExchangeProperties(exchange, requestContext, oi);
         
-
         // setup chain
         PhaseManager pm = bus.getExtension(PhaseManager.class);
         PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
@@ -140,33 +137,51 @@
         conduit.setMessageObserver(this);
         
         // execute chain
-        
         chain.doIntercept(message);
 
-        if (message.getContent(Exception.class) != null) {
-            //exception trying to send the message
-            throw new RuntimeException(message.getContent(Exception.class));
+        // Check to see if there is a Fault from the outgoing chain
+        Exception ex = message.getContent(Exception.class);
+        
+        if (ex != null) {
+            throw ex;
         }
         
-        // correlate response        
-        if (conduit.getBackChannel() != null) {
-            // process partial response and wait for decoupled response
-        } else {
-            // process response: send was synchronous so when we get here we can assume that the 
-            // Exchange's inbound message is set and had been passed through the inbound interceptor chain.
+        // Wait for a response if we need to
+        if (!oi.getOperationInfo().isOneWay() 
+            && !Boolean.TRUE.equals(exchange.get(FINISHED))) {
+            synchronized (exchange) {
+                waitResponse(exchange);
+            }
         }
 
-        if (oi.getOutput() != null) {
-            synchronized (exchange) {
-                Message inMsg = waitResponse(exchange);
-                //set the inMsg context to response context                
-                if (null != responseContext && null != inMsg) {                   
-                    responseContext.putAll(inMsg);
-                    LOG.info("set responseContext to be" + responseContext);
-                }
-                return inMsg.getContent(List.class).toArray();
+        // Grab the response objects if there are any
+        List resList = null;
+        Message inMsg = exchange.getInMessage();
+        if (inMsg != null) {
+            if (null != responseContext) {                   
+                responseContext.putAll(inMsg);
+                LOG.info("set responseContext to be" + responseContext);
             }
-        } 
+            resList = inMsg.getContent(List.class);
+        }
+        
+        // check for an incoming fault
+        ex = getException(exchange);
+        
+        if (ex != null) {
+            throw ex;
+        }
+        
+        if (resList != null) {
+            return resList.toArray();
+        }
+        return null;
+    }
+
+    private Exception getException(Exchange exchange) {
+        if (exchange.getFaultMessage() != null) {
+            return exchange.getFaultMessage().getContent(Exception.class);
+        }
         return null;
     }
 
@@ -177,19 +192,12 @@
         }        
     }
 
-    private Message waitResponse(Exchange exchange) {
-        while (exchange.getInMessage() == null) {
-            try {
-                exchange.wait();
-            } catch (InterruptedException e) {
-                //TODO - timeout
-            }
-        }
-        if (isException(exchange)) {
-            //TODO - exceptions 
-            throw new RuntimeException(exchange.getInMessage().getContent(Exception.class));
+    private void waitResponse(Exchange exchange) {
+        try {
+            exchange.wait(synchronousTimeout);
+        } catch (InterruptedException e) {
+            //TODO - timeout
         }
-        return exchange.getInMessage();
     }
 
     private void setParameters(Object[] params, Message message) {
@@ -234,10 +242,8 @@
             chain.doIntercept(message);
         } finally {
             synchronized (message.getExchange()) {
-                if (!isPartialResponse(message)) {
-                    message.getExchange().setInMessage(message);
-                    message.getExchange().notifyAll();
-                }
+                message.getExchange().put(FINISHED, Boolean.TRUE);
+                message.getExchange().notifyAll();
             }
         }
     }
@@ -258,21 +264,7 @@
         }
         return initedConduit;
     }
-    
-    private boolean isPartialResponse(Message in) {
-        //Message in = exchange.getInMessage();
-        boolean partial = in.getContent(List.class) == null
-                          && in.getContent(Exception.class) == null;
-        //if (partial) {
-            //exchange.setInMessage(null);
-        //}
-        return partial;
-    }
 
-    private boolean isException(Exchange exchange) {
-        return exchange.getInMessage().getContent(Exception.class) != null;
-    }
-    
     protected void setOutMessageProperties(Message message, BindingOperationInfo boi) {
         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
         message.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
@@ -297,6 +289,12 @@
     protected void modifyChain(InterceptorChain chain, Map<String, Object> ctx) {
         // no-op
     }
-   
 
+    public int getSynchronousTimeout() {
+        return synchronousTimeout;
+    }
+
+    public void setSynchronousTimeout(int synchronousTimeout) {
+        this.synchronousTimeout = synchronousTimeout;
+    }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java Tue Oct 17 22:14:04 2006
@@ -34,11 +34,13 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.Configurable;
 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
-import org.apache.cxf.interceptor.FaultChainIntiatorInterceptor;
-import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.AbstractFaultChainIntiatorObserver;
+import org.apache.cxf.interceptor.InFaultChainInitiatorObserver;
+import org.apache.cxf.interceptor.OutFaultChainInitiatorObserver;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.MessageObserver;
 
 public class EndpointImpl extends AbstractBasicInterceptorProvider implements Endpoint, Configurable {
 
@@ -50,7 +52,8 @@
     private EndpointInfo endpointInfo;
     private Executor executor;
     private Bus bus;
-    private Interceptor faultInterceptor;
+    private AbstractFaultChainIntiatorObserver inFaultObserver;
+    private AbstractFaultChainIntiatorObserver outFaultObserver;
     private boolean validating;
     
     public EndpointImpl(Bus bus, Service s, QName endpointName) throws EndpointException {
@@ -65,10 +68,13 @@
         this.bus = bus;
         service = s;
         endpointInfo = ei;
-        faultInterceptor = new FaultChainIntiatorInterceptor(this, bus);        
+
         createBinding(endpointInfo.getBinding());
+        
+        inFaultObserver = new InFaultChainInitiatorObserver(bus);
+        outFaultObserver = new OutFaultChainInitiatorObserver(bus);
     }
-
+    
     public String getBeanName() {
         return endpointInfo.getName().toString();
     }
@@ -81,14 +87,6 @@
         validating = v;
     }
 
-    public Interceptor getFaultInterceptor() {
-        return faultInterceptor;
-    }
-
-    public void setFaultInterceptor(Interceptor faultInterceptor) {
-        this.faultInterceptor = faultInterceptor;
-    }
-
     public EndpointInfo getEndpointInfo() {
         return endpointInfo;
     }
@@ -133,5 +131,13 @@
             }
         }    
     }
+    
+
+    public MessageObserver getInFaultObserver() {
+        return inFaultObserver;
+    }
 
+    public MessageObserver getOutFaultObserver() {
+        return outFaultObserver;
+    }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerRegistryImpl.java Tue Oct 17 22:14:04 2006
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 
 import org.apache.cxf.Bus;
@@ -63,6 +64,10 @@
         serversList.add(server);        
     }
 
+    public void unregister(Server server) {
+        serversList.remove(server);
+    }
+
     public List<Server> getServers() {
         return serversList;
     }
@@ -72,6 +77,7 @@
         
     }
 
+    @PreDestroy
     public void preShutdown() {
         // Shutdown the service       
         for (Server server : serversList) {            

Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java (added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java Tue Oct 17 22:14:04 2006
@@ -0,0 +1,74 @@
+/**
+ * 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.cxf.interceptor;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.transport.MessageObserver;
+
+public abstract class AbstractFaultChainIntiatorObserver implements MessageObserver {
+    private Bus bus;
+
+    public AbstractFaultChainIntiatorObserver(Bus bus) {
+        this.bus = bus;
+    }
+
+    public void onMessage(Message m) {
+        Message faultMessage = m.getExchange().getFaultMessage();
+        if (faultMessage == null) {
+            faultMessage = new MessageImpl();
+        }
+        
+        faultMessage = m.getExchange().get(Binding.class).createMessage(faultMessage);
+        m.getExchange().setFaultMessage(faultMessage);
+        faultMessage.putAll(m);
+        MessageImpl.copyContent(m, faultMessage);
+        
+        Exception e = m.getContent(Exception.class);
+        Fault f;
+        if (e instanceof Fault) {
+            f = (Fault) e;
+        } else {
+            f = new Fault(e);
+        }
+        faultMessage.setContent(Exception.class, f);
+        
+        // setup chain
+        PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class)
+            .getOutPhases());
+        initializeInterceptors(faultMessage.getExchange(), chain);
+        
+        faultMessage.setInterceptorChain(chain);
+        chain.doIntercept(faultMessage);
+    }
+
+    protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
+        
+    }
+
+    public Bus getBus() {
+        return bus;
+    }
+}
\ No newline at end of file

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainIntiatorObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java (added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java Tue Oct 17 22:14:04 2006
@@ -0,0 +1,108 @@
+/**
+ * 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.cxf.interceptor;
+
+import java.lang.reflect.Constructor;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.FaultInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+/**
+ * Takes a Fault and converts it to a local exception type if possible.
+ * 
+ * @author Dan Diephouse
+ */
+public class ClientFaultConverter extends AbstractPhaseInterceptor<Message> {
+    
+    public ClientFaultConverter() {
+        super();
+        setPhase(Phase.MARSHAL);
+    }
+
+    public void handleMessage(Message msg) {
+        Fault fault = (Fault)msg.getContent(Exception.class);
+
+        if (fault.getDetail() != null) {
+            processFaultDetail(fault, msg);
+        }
+    }
+
+    protected void processFaultDetail(Fault fault, Message msg) {
+        Element exDetail = (Element)DOMUtils.getChild(fault.getDetail(), Node.ELEMENT_NODE);
+        QName qname = new QName(exDetail.getNamespaceURI(), exDetail.getLocalName());
+
+        FaultInfo faultInfo = getFaultInfo(msg.getExchange().get(BindingOperationInfo.class),
+                                           qname,
+                                           exDetail);
+        if (faultInfo == null) {
+            return;
+        }
+        
+        Service s = msg.getExchange().get(Service.class);
+        DataBinding dataBinding = s.getDataBinding();
+        
+        DataReader<Node> reader = dataBinding.getDataReaderFactory().createReader(Node.class);
+        Object e = reader.read(exDetail);
+        
+        if (!(e instanceof Exception)) {
+            Class exClass = faultInfo.getProperty(Class.class.getName(), Class.class);
+            Class beanClass = e.getClass();
+
+            try {
+                Constructor constructor = exClass.getConstructor(new Class[] {String.class,
+                                                                              beanClass});
+                e = constructor.newInstance(new Object[] {fault.getMessage(), e});
+            } catch (Exception e1) {
+                throw new Fault(e1);
+            }
+        }
+
+        msg.setContent(Exception.class, e);
+    }
+
+    protected FaultInfo getFaultInfo(BindingOperationInfo operation, 
+                                     QName qname,
+                                     Element exDetail) {
+        
+        for (FaultInfo faultInfo : operation.getOperationInfo().getFaults()) {
+
+            for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
+                if (qname.equals(mpi.getConcreteName())) {
+                    return faultInfo;
+                }
+            }
+        }
+
+        return null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java (added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java Tue Oct 17 22:14:04 2006
@@ -0,0 +1,40 @@
+/**
+ * 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.cxf.interceptor;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+public class InFaultChainInitiatorObserver extends AbstractFaultChainIntiatorObserver {
+
+    public InFaultChainInitiatorObserver(Bus bus) {
+        super(bus);
+    }
+
+    protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
+        Endpoint e = ex.get(Endpoint.class);
+        
+        chain.add(e.getInFaultInterceptors());
+        chain.add(e.getBinding().getInFaultInterceptors());
+        chain.add(e.getService().getInFaultInterceptors());
+        chain.add(getBus().getInFaultInterceptors());
+    }
+}

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java (added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java Tue Oct 17 22:14:04 2006
@@ -0,0 +1,40 @@
+/**
+ * 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.cxf.interceptor;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+public class OutFaultChainInitiatorObserver extends AbstractFaultChainIntiatorObserver {
+
+    public OutFaultChainInitiatorObserver(Bus bus) {
+        super(bus);
+    }
+
+    protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
+        Endpoint e = ex.get(Endpoint.class);
+        
+        chain.add(e.getOutFaultInterceptors());
+        chain.add(e.getBinding().getOutFaultInterceptors());
+        chain.add(e.getService().getOutFaultInterceptors());
+        chain.add(getBus().getOutFaultInterceptors());
+    }
+}

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java Tue Oct 17 22:14:04 2006
@@ -41,10 +41,12 @@
 
     public void onMessage(Message m) {
         Message message = endpoint.getBinding().createMessage(m);
-        Exchange exchange = new ExchangeImpl();
-        exchange.setInMessage(message);
-        message.setExchange(exchange);
-        setExchangProperties(exchange, message);
+        Exchange exchange = message.getExchange();
+        if (exchange == null) {
+            exchange = new ExchangeImpl();
+            exchange.setInMessage(message);
+        }
+        setExchangeProperties(exchange, message);
         
         // setup chain
         PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class)
@@ -57,12 +59,12 @@
         chain.add(endpoint.getBinding().getInInterceptors());
         chain.add(endpoint.getService().getInInterceptors());
 
-        chain.setFaultInterceptor(endpoint.getFaultInterceptor());
+        chain.setFaultObserver(endpoint.getOutFaultObserver());
        
         chain.doIntercept(message);        
     }
     
-    protected void setExchangProperties(Exchange exchange, Message m) {
+    protected void setExchangeProperties(Exchange exchange, Message m) {
         exchange.put(Endpoint.class, endpoint);
         exchange.put(Service.class, endpoint.getService());
         exchange.put(Binding.class, endpoint.getBinding());

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java Tue Oct 17 22:14:04 2006
@@ -38,7 +38,6 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
-
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.attachment.AttachmentMarshaller;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
@@ -57,7 +56,6 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.interceptor.Fault;
 
 /**
@@ -355,7 +353,7 @@
         } catch (Exception ex) {
             throw new Fault(new Message("MARSHAL_ERROR", BUNDLE), ex);
         }
-        return (elName == null) ? obj : getElementValue(obj, elName);
+        return getElementValue(obj, elName);
     }
 
     public static Object getElementValue(Object obj, QName elName) {
@@ -363,24 +361,21 @@
             return null;
         }
 
-        if (obj instanceof JAXBElement<?>) {
-            JAXBElement<?> el = (JAXBElement<?>)obj;
-            if (isSame(el.getName(), elName)) {
-                obj = el.getValue();
-            }
+        if (obj instanceof JAXBElement) {
+            return ((JAXBElement<?>)obj).getValue();
         }
         return obj;
     }
 
-    private static boolean isSame(QName messageQName, QName methodQName) {
-        boolean same = false;
-        if (StringUtils.isEmpty(messageQName.getNamespaceURI())) {
-            same = messageQName.getLocalPart().equals(methodQName.getLocalPart());
-        } else {
-            same = messageQName.equals(methodQName);
-        }
-        return same;
-    }
+//    private static boolean isSame(QName messageQName, QName methodQName) {
+//        boolean same = false;
+//        if (StringUtils.isEmpty(messageQName.getNamespaceURI())) {
+//            same = messageQName.getLocalPart().equals(methodQName.getLocalPart());
+//        } else {
+//            same = messageQName.equals(methodQName);
+//        }
+//        return same;
+//    }
 
     public static Class<?> getClassFromType(Type t) {
         if (t instanceof Class) {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/TestBase.java Tue Oct 17 22:14:04 2006
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
@@ -37,6 +38,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.greeter_control.types.GreetMe;
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.WrappedInInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -55,7 +57,6 @@
 import static org.easymock.EasyMock.expect;
 import static org.easymock.classextension.EasyMock.createNiceControl;
 
-
 public class TestBase extends TestCase {
 
     PhaseInterceptorChain chain;
@@ -77,7 +78,9 @@
         BindingFactory bf = control.createMock(BindingFactory.class);
         Binding binding = control.createMock(Binding.class);
         expect(bf.createBinding(null)).andStubReturn(binding);
-
+        expect(binding.getInFaultInterceptors()).andStubReturn(new ArrayList<Interceptor>());
+        expect(binding.getOutFaultInterceptors()).andStubReturn(new ArrayList<Interceptor>());
+        
         bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
 
         String ns = "http://apache.org/hello_world_soap_http";

Modified: incubator/cxf/trunk/rt/frontend/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/pom.xml?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/pom.xml (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/pom.xml Tue Oct 17 22:14:04 2006
@@ -102,10 +102,6 @@
             <groupId>javax.xml.soap</groupId>
             <artifactId>saaj-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>javax.xml.soap</groupId>
-            <artifactId>saaj-api</artifactId>
-        </dependency>        
     </dependencies>
 
     <build>

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java Tue Oct 17 22:14:04 2006
@@ -100,7 +100,7 @@
                           BindingOperationInfo oi, 
                           Object[] params, 
                           Object[] paramsWithOutHolder, 
-                          Map<String, Object> context) {
+                          Map<String, Object> context) throws Exception {
         Object rawRet[] = client.invoke(oi, paramsWithOutHolder, context);
 
         if (rawRet != null && rawRet.length != 0) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderChainObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderChainObserver.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderChainObserver.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ProviderChainObserver.java Tue Oct 17 22:14:04 2006
@@ -83,7 +83,7 @@
         chain.add(endpoint.getBinding().getOutInterceptors());
 
         chain.add(endpoint.getService().getInInterceptors());
-        chain.setFaultInterceptor(endpoint.getFaultInterceptor());
+        chain.setFaultObserver(endpoint.getOutFaultObserver());
 
         chain.doIntercept(message);
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java Tue Oct 17 22:14:04 2006
@@ -28,6 +28,7 @@
 import org.apache.cxf.binding.soap.SoapBinding;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxws.binding.BindingImpl;
 import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
@@ -55,7 +56,7 @@
         super(bus, s, ei);
 
         createJaxwsBinding();
-        
+
         List<Interceptor> handlerInterceptors;
                 
         handlerInterceptors = new ArrayList<Interceptor>();
@@ -76,6 +77,8 @@
         List<Interceptor> out = super.getOutInterceptors();
         out.addAll(handlerInterceptors);
         out.add(new WrapperClassOutInterceptor());
+
+        getInFaultInterceptors().add(new ClientFaultConverter());
     }
     
     public Binding getJaxwsBinding() {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Tue Oct 17 22:14:04 2006
@@ -29,6 +29,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.WebFault;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -39,6 +40,7 @@
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
 
 public class JaxWsServiceConfiguration extends AbstractServiceConfiguration {
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JaxWsServiceConfiguration.class);
@@ -211,6 +213,24 @@
             }
         }
         
+        return null;
+    }
+
+    @Override
+    public QName getFaultName(InterfaceInfo service, OperationInfo o, Class<?> exClass, Class<?> beanClass) {
+        WebFault fault = exClass.getAnnotation(WebFault.class);
+        if (fault != null) {
+            String name = fault.name();
+            if (name.length() == 0) {
+                name = exClass.getSimpleName();
+            }
+            String ns = fault.targetNamespace();
+            if (ns.length() == 0) {
+                ns = service.getName().getNamespaceURI();
+            }
+            
+            return new QName(ns, name);
+        }
         return null;
     }
     

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Tue Oct 17 22:14:04 2006
@@ -29,9 +29,9 @@
 
 import javax.wsdl.Operation;
 import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Holder;
-import javax.xml.ws.WebFault;
 
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -169,14 +169,21 @@
     }
     
     private void setFaultClassInfo(OperationInfo o, Method selected) {
-        for (FaultInfo fi : o.getFaults()) {
-            int i = 0;
-            Class<?> cls = selected.getExceptionTypes()[i];
-            fi.getMessagePartByIndex(0).setProperty(Class.class.getName(), cls);
-            if (cls.isAnnotationPresent(WebFault.class)) {
-                fi.getMessagePartByIndex(i).setProperty(WebFault.class.getName(), Boolean.TRUE);
+        Class[] types = selected.getExceptionTypes();
+        for (int i = 0; i < types.length; i++) {
+            Class exClass = types[i];
+            Class beanClass = getBeanClass(exClass);
+            
+            QName name = getFaultName(o.getInterface(), o, exClass, beanClass);
+            
+            for (FaultInfo fi : o.getFaults()) {
+                for (MessagePartInfo mpi : fi.getMessageParts()) {
+                    if (mpi.getConcreteName().equals(name)) {
+                        fi.setProperty(Class.class.getName(), exClass);
+                        mpi.setProperty(Class.class.getName(), beanClass);
+                    }
+                }
             }
-            i++;
         }
     }
     /**

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java Tue Oct 17 22:14:04 2006
@@ -23,13 +23,17 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
+import java.util.ResourceBundle;
 
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.invoker.BeanInvoker;
@@ -38,10 +42,13 @@
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
+import org.apache.hello_world_soap_http.BadRecordLitFault;
 import org.apache.hello_world_soap_http.GreeterImpl;
 
 public class JaxWsClientTest extends AbstractJaxWsTest {
 
+    static String responseMessage;
+
     @Override
     public void setUp() throws Exception {
         super.setUp();
@@ -52,19 +59,17 @@
         Destination d = localTransport.getDestination(ei);
         d.setMessageObserver(new EchoObserver());
     }
-    
+
     public void testCreate() throws Exception {
-        javax.xml.ws.Service s =
-            javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http",
-                                                          "SoapPort"));
+        javax.xml.ws.Service s = javax.xml.ws.Service
+            .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
         assertNotNull(s);
-        
+
         try {
             s = javax.xml.ws.Service.create(new URL("file:/does/not/exist.wsdl"),
-                                            new QName("http://apache.org/hello_world_soap_http",
-                                                "SoapPort"));
+                                            new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
         } catch (ServiceConstructionException sce) {
-            //ignore, this is expected
+            // ignore, this is expected
         }
     }
 
@@ -73,27 +78,60 @@
         URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
         assertNotNull(resource);
         bean.setWsdlURL(resource);
-        bean.setBus(getBus());        
-        bean.setServiceClass(GreeterImpl.class);        
+        bean.setBus(getBus());
+        bean.setServiceClass(GreeterImpl.class);
         GreeterImpl greeter = new GreeterImpl();
         BeanInvoker invoker = new BeanInvoker(greeter);
         bean.setInvoker(invoker);
-        
+
         Service service = bean.create();
 
         String namespace = "http://apache.org/hello_world_soap_http";
         EndpointInfo ei = service.getServiceInfo().getEndpoint(new QName(namespace, "SoapPort"));
         JaxWsEndpointImpl endpoint = new JaxWsEndpointImpl(getBus(), service, ei);
-        
+
         ClientImpl client = new ClientImpl(getBus(), endpoint);
-        
+
         BindingOperationInfo bop = ei.getBinding().getOperation(new QName(namespace, "sayHi"));
         assertNotNull(bop);
         bop = bop.getUnwrappedOperation();
         assertNotNull(bop);
+
+        responseMessage = "sayHiResponse.xml";
         Object ret[] = client.invoke(bop, new Object[0], null);
         assertNotNull(ret);
         assertEquals("Wrong number of return objects", 1, ret.length);
+
+        // test fault handling
+        bop = ei.getBinding().getOperation(new QName(namespace, "testDocLitFault"));
+        responseMessage = "testDocLitFault.xml";
+        try {
+            client.invoke(bop, new Object[] {"BadRecordLitFault"}, null);
+            fail("Should have returned a fault!");
+        } catch (BadRecordLitFault fault) {
+            // this is supposed to happen
+        }
+        
+        try {
+            client.getEndpoint().getOutInterceptors().add(new FaultThrower());
+            client.invoke(bop, new Object[] {"BadRecordLitFault"}, null);
+            fail("Should have returned a fault!");
+        } catch (Fault fault) {
+            // this is supposed to happen
+        } 
+    }
+
+    public static class FaultThrower extends AbstractPhaseInterceptor<Message> {
+        
+        public FaultThrower() {
+            super();
+            setPhase(Phase.PRE_LOGICAL);
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("Foo", (ResourceBundle)null));
+        }
+
     }
 
     static class EchoObserver implements MessageObserver {
@@ -104,11 +142,14 @@
 
                 backChannel.send(message);
 
+                InputStream in = message.getContent(InputStream.class);
+                while (in.available() > 0) {
+                    in.read();
+                }
+
                 OutputStream out = message.getContent(OutputStream.class);
                 assertNotNull(out);
-                InputStream in = message.getContent(InputStream.class);
-                assertNotNull(in);
-                
+                in = getClass().getResourceAsStream(responseMessage);
                 copy(in, out, 2045);
 
                 out.close();

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml Tue Oct 17 22:14:04 2006
@@ -0,0 +1,26 @@
+<!--
+  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.
+-->
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+	<soap:Body>
+	<sayHiResponse xmlns="http://apache.org/hello_world_soap_http/types">
+		<text>hi</text>
+	</sayHiResponse>
+	</soap:Body>
+
+</soap:Envelope>

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHiResponse.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java Tue Oct 17 22:14:04 2006
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxws.support;
 
 import java.net.URL;
+import java.util.Collection;
 import java.util.Iterator;
 
 import javax.xml.namespace.QName;
@@ -30,6 +31,7 @@
 import org.apache.cxf.mtom_xop.HelloImpl;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.invoker.BeanInvoker;
+import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -51,13 +53,13 @@
         
         Service service = bean.create();
 
+        String ns = "http://apache.org/hello_world_soap_http";
         assertEquals("SOAPService", service.getName().getLocalPart());
-        assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
+        assertEquals(ns, service.getName().getNamespaceURI());
         
         InterfaceInfo intf = service.getServiceInfo().getInterface();
         
-        OperationInfo op = intf.getOperation(
-            new QName("http://apache.org/hello_world_soap_http", "sayHi"));
+        OperationInfo op = intf.getOperation(new QName(ns, "sayHi"));
         
         Class wrapper = (Class) 
             op.getUnwrappedOperation().getInput().getProperty(WrappedInInterceptor.WRAPPER_CLASS);
@@ -68,6 +70,20 @@
         assertNotNull(wrapper);
     
         assertEquals(invoker, service.getInvoker());
+        
+        op = intf.getOperation(new QName(ns, "testDocLitFault"));
+        Collection<FaultInfo> faults = op.getFaults();
+        assertEquals(2, faults.size());
+        
+        FaultInfo f = op.getFault(new QName(ns, "BadRecordLitFault"));
+        assertNotNull(f);
+        Class c = f.getProperty(Class.class.getName(), Class.class);
+        assertNotNull(c);
+        
+        assertEquals(1, f.getMessageParts().size());
+        MessagePartInfo mpi = f.getMessagePartByIndex(0);
+        c = mpi.getProperty(Class.class.getName(), Class.class);
+        assertNotNull(c);
     }
     
     public void testHolder() throws Exception {

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml?view=auto&rev=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml Tue Oct 17 22:14:04 2006
@@ -0,0 +1,32 @@
+<!--
+  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.
+-->
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+	<soap:Body>
+	  <soap:Fault>
+	    <faultstring>Hadrian did it.</faultstring>
+	    <faultcode>soap:Server</faultcode>
+	    <detail>
+	      <BadRecordLit xmlns="http://apache.org/hello_world_soap_http/types">
+	        foo
+	      </BadRecordLit>
+	    </detail>
+	  </soap:Fault>
+	</soap:Body>
+
+</soap:Envelope>

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/testDocLitFault.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java Tue Oct 17 22:14:04 2006
@@ -24,7 +24,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.OperationInfo;
 
@@ -79,7 +78,7 @@
         return null;
     }
 
-    public QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) {
+    public QName getFaultName(InterfaceInfo service, OperationInfo o, Class<?> exClass, Class<?> beanClass) {
         return null;
     }
 

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java Tue Oct 17 22:14:04 2006
@@ -27,7 +27,6 @@
 import org.apache.cxf.common.util.ParamReader;
 import org.apache.cxf.helpers.ServiceUtils;
 import org.apache.cxf.message.Exchange;
-import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.OperationInfo;
 
@@ -39,9 +38,9 @@
     }
 
     @Override
-    public QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) {
-        // TODO Auto-generated method stub
-        return super.getFaultName(service, o, exClass, beanClass);
+    public QName getFaultName(InterfaceInfo service, OperationInfo o, Class<?> exClass, Class<?> beanClass) {
+        String name = ServiceUtils.makeServiceNameFromClassName(beanClass);
+        return new QName(service.getName().getNamespaceURI(), name);
     }
 
     @Override

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Tue Oct 17 22:14:04 2006
@@ -206,7 +206,6 @@
                         && isMatchOperation(o.getName().getLocalPart(), opName.getLocalPart())) {
                     //if (o.getName().equals(opName)) {
                         selected = m;
-                        o.setProperty(Method.class.getName(), m);
                         break;
                     }
                 }
@@ -564,7 +563,7 @@
 
             // Ignore XFireFaults because they don't need to be declared
             if (exClazz.equals(Exception.class) 
-                || exClazz.equals(Fault.class)
+                || Fault.class.isAssignableFrom(exClazz)
                 || exClazz.equals(RuntimeException.class)
                 || exClazz.equals(Throwable.class)) {
                 continue;
@@ -575,14 +574,26 @@
     }
 
     protected FaultInfo addFault(final InterfaceInfo service, final OperationInfo op, Class exClass) {
-        // TODO
-        return null;
+        Class beanClass = getBeanClass(exClass);
+        
+        QName faultName = getFaultName(service, op, getBeanClass(exClass), getBeanClass(beanClass));
+        FaultInfo fi = op.addFault(faultName, faultName);
+        fi.setProperty(Class.class.getName(), exClass);
+        
+        MessagePartInfo mpi = fi.addMessagePart(faultName);
+        mpi.setProperty(Class.class.getName(), beanClass);
+        
+        return fi;
+    }
+
+    protected Class getBeanClass(Class exClass) {
+        return exClass;
     }
 
-    protected QName getFaultName(Service service, OperationInfo o, Class exClass, Class beanClass) {
+    protected QName getFaultName(InterfaceInfo service, OperationInfo o, Class exClass, Class beanClass) {
         for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
             AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
-            QName q = c.getFaultName(service, o, exClass, beanClass);
+            QName q = c.getFaultName(service, o, getBeanClass(exClass), getBeanClass(beanClass));
             if (q != null) {
                 return q;
             }
@@ -677,8 +688,8 @@
     protected Class getResponseWrapper(Method selected) {
         for (AbstractServiceConfiguration c : serviceConfigurations) {
             Class cls = c.getResponseWrapper(selected);
-            if (cls != null) {
-                return cls;
+            if (getBeanClass(cls) != null) {
+                return getBeanClass(cls);
             }
         }
         return null;
@@ -686,8 +697,8 @@
     protected Class getRequestWrapper(Method selected) {
         for (AbstractServiceConfiguration c : serviceConfigurations) {
             Class cls = c.getRequestWrapper(selected);
-            if (cls != null) {
-                return cls;
+            if (getBeanClass(cls) != null) {
+                return getBeanClass(cls);
             }
         }
         return null;

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Tue Oct 17 22:14:04 2006
@@ -441,7 +441,9 @@
                 return;
             }
             Message inMessage = new MessageImpl();
-            inMessage.setExchange(exchange);
+            if (exchange != null) {
+                exchange.setInMessage(inMessage);
+            }
             InputStream in = null;
             inMessage.put(Message.PROTOCOL_HEADERS, connection.getHeaderFields());
             inMessage.put(Message.RESPONSE_CODE, getResponseCode(connection));
@@ -549,7 +551,7 @@
             InputStream responseStream = req.getInputStream();
             Message inMessage = new MessageImpl();
             // disposable exchange, swapped with real Exchange on correlation
-            inMessage.setExchange(new ExchangeImpl());
+            new ExchangeImpl().setInMessage(inMessage);
             // REVISIT: how to get response headers?
             //inMessage.put(Message.PROTOCOL_HEADERS, req.getXXX());
             setHeaders(inMessage);

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java (original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java Tue Oct 17 22:14:04 2006
@@ -353,7 +353,7 @@
             
             //TODO if outMessage need to get the response
             Message inMessage = new MessageImpl();
-            inMessage.setExchange(outMessage.getExchange());            
+            outMessage.getExchange().setInMessage(inMessage);            
             //set the message header back to the incomeMessage
             //inMessage.put(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS, 
             //              outMessage.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS));

Modified: incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java (original)
+++ incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java Tue Oct 17 22:14:04 2006
@@ -27,6 +27,7 @@
 import org.apache.cxf.binding.attachment.CachedOutputStream;
 import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.transport.Conduit;
@@ -60,7 +61,7 @@
         return destination.getAddress();
     }
 
-    public void send(Message message) throws IOException {
+    public void send(final Message message) throws IOException {
         final PipedInputStream stream = new PipedInputStream();
         final LocalConduit conduit = this;
         final Exchange exchange = message.getExchange();
@@ -76,8 +77,10 @@
                 m.setContent(InputStream.class, stream);
                 m.setDestination(destination);
                 m.put(IN_CONDUIT, conduit);
-                m.put(IN_EXCHANGE, exchange);
                 
+                ExchangeImpl ex = new ExchangeImpl();
+                ex.setInMessage(m);
+                ex.put(IN_EXCHANGE, exchange);
                 destination.getMessageObserver().onMessage(m);
             }
         };

Modified: incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java?view=diff&rev=465145&r1=465144&r2=465145
==============================================================================
--- incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java Tue Oct 17 22:14:04 2006
@@ -90,15 +90,16 @@
             return null;
         }
 
-        public void send(Message message) throws IOException {
+        public void send(final Message message) throws IOException {
 
             final PipedInputStream stream = new PipedInputStream();
-            final Exchange exchange = (Exchange)message.get(LocalConduit.IN_EXCHANGE);
-
+            final Exchange exchange = (Exchange)message.getExchange().get(LocalConduit.IN_EXCHANGE);
             final Runnable receiver = new Runnable() {
                 public void run() {
                     MessageImpl m = new MessageImpl();
-                    m.setExchange(exchange);
+                    if (exchange != null) {
+                        exchange.setInMessage(m);
+                    }
                     m.setContent(InputStream.class, stream);
                     conduit.getMessageObserver().onMessage(m);
                 }



Mime
View raw message