cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r519759 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/ rt/bindings/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/sa...
Date Mon, 19 Mar 2007 00:17:57 GMT
Author: dandiep
Date: Sun Mar 18 17:17:55 2007
New Revision: 519759

URL: http://svn.apache.org/viewvc?view=rev&rev=519759
Log:
o Refactored out SAAJ creation code into seperate interceptors. They reside
  in the SOAP module.
o Made SAAJ input logic more efficient by creating a document fragment
  from the incoming response which includes the Envelope, Headers, and
  Body element - but not the contents of the body. This then gets turned
  into a SAAJMessage.
o Refactored SAAJ logic so it doesn't require doInterceptInSubChain().
  An interceptor which writes the message is added to the end of the chain.
  This allows a more logical phase set up of putting the LOGIC handlers
  after the MARSHAL phase.
o Remove Phase definitions from cxf.xml as its confusing and unncessary to
  have the phase definitions in two places.
  

Added:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties   (with props)
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java   (with props)
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java   (with props)
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java   (with props)
Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/PartialXMLStreamReader.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    incubator/cxf/trunk/rt/bindings/soap/pom.xml
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/PortInfoImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.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/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JAXWSMethodInvokerTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBuilderTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalMessageImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/ValidationServer.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/PartialXMLStreamReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/PartialXMLStreamReader.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/PartialXMLStreamReader.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/PartialXMLStreamReader.java Sun Mar 18 17:17:55 2007
@@ -43,7 +43,7 @@
             if (currentEvent == START_ELEMENT && getName().equals(endTag)) {
                 foundEnd = true;
                 endDepth = getDepth();
-                return END_ELEMENT;
+                return START_ELEMENT;
             }
             
             return currentEvent;

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Sun Mar 18 17:17:55 2007
@@ -539,7 +539,7 @@
      * @param reader
      * @throws XMLStreamException
      */
-    private static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing)
+    public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing)
         throws XMLStreamException {
         Document doc = getDocument(parent);
 

Modified: incubator/cxf/trunk/rt/bindings/soap/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/pom.xml?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/pom.xml (original)
+++ incubator/cxf/trunk/rt/bindings/soap/pom.xml Sun Mar 18 17:17:55 2007
@@ -81,6 +81,11 @@
             <groupId>javax.xml.bind</groupId>
             <artifactId>jaxb-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.sun.xml.messaging.saaj</groupId>
+            <artifactId>saaj-impl</artifactId>
+            <optional>true</optional>
+        </dependency>
     </dependencies>
 
 

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=519759&r1=519758&r2=519759
==============================================================================
--- 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 Sun Mar 18 17:17:55 2007
@@ -30,6 +30,8 @@
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
@@ -60,7 +62,7 @@
             return;
         }
         XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
-        
+
         if (xmlReader == null) {
             InputStream in = (InputStream)message.getContent(InputStream.class);
             if (in == null) {
@@ -72,36 +74,33 @@
         try {
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
+                
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
                 if (soapVersion == null) {
-                    throw new SoapFault(new Message("INVALID_VERSION", LOG, ns), 
-                                        Soap11.getInstance().getSender());
+                    throw new SoapFault(new Message("INVALID_VERSION", LOG, ns), Soap11.getInstance()
+                        .getSender());
                 }
                 message.setVersion(soapVersion);
-                
-                QName qn = xmlReader.getName();
-                while (!qn.equals(message.getVersion().getBody())
-                    && !qn.equals(message.getVersion().getHeader())) {
-                    while (xmlReader.nextTag() != XMLStreamConstants.START_ELEMENT) {
-                        //nothing to do
-                    }
-                    qn = xmlReader.getName();
-                }
-                if (qn.equals(message.getVersion().getHeader())) {
-                    XMLStreamReader filteredReader = 
-                        new PartialXMLStreamReader(xmlReader, message.getVersion().getBody());
-                
-                    Document doc = StaxUtils.read(filteredReader);
 
-                    Element element = doc.getDocumentElement();
-                    message.setHeaders(Element.class, element);
-                    message.put(Element.class, element);                    
+                XMLStreamReader filteredReader = new PartialXMLStreamReader(xmlReader, message.getVersion()
+                    .getBody());
+
+                Document doc = StaxUtils.read(filteredReader);
+
+                message.setContent(Node.class, doc);
+
+                // Find header
+                Element element = doc.getDocumentElement();
+                QName header = soapVersion.getHeader();
+                NodeList headerEls = element.getElementsByTagNameNS(header.getNamespaceURI(), header
+                    .getLocalPart());
+                for (int i = 0; i < headerEls.getLength(); i++) {
+                    Node node = headerEls.item(i);
+                    message.setHeaders(Element.class, (Element)node);
                 }
+
                 // advance just past body.
                 xmlReader.nextTag();
-                if (xmlReader.getName().equals(message.getVersion().getBody())) {
-                    xmlReader.nextTag();
-                }                    
                 if (message.getVersion().getFault().equals(xmlReader.getName())) {
                     Endpoint ep = message.getExchange().get(Endpoint.class);
                     if (!isDecoupled(message)) {
@@ -115,13 +114,12 @@
                 }
             }
         } catch (XMLStreamException e) {
-            throw new SoapFault(new Message("XML_STREAM_EXC", BUNDLE), e, 
-                                message.getVersion().getSender());
+            throw new SoapFault(new Message("XML_STREAM_EXC", BUNDLE), e, message.getVersion().getSender());
         }
     }
 
     private boolean isDecoupled(SoapMessage message) {
         Boolean decoupled = (Boolean)message.get(DECOUPLED_CHANNEL_MESSAGE);
-        return decoupled != null && decoupled.booleanValue(); 
+        return decoupled != null && decoupled.booleanValue();
     }
 }

Added: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties?view=auto&rev=519759
==============================================================================
    (empty)

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?view=auto&rev=519759
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java Sun Mar 18 17:17:55 2007
@@ -0,0 +1,102 @@
+/**
+ * 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.binding.soap.saaj;
+
+
+import java.util.ResourceBundle;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+
+/**
+ * Builds a SAAJ tree from the Document fragment inside the message which contains
+ * the SOAP headers and from the XMLStreamReader.
+ */
+public class SAAJInInterceptor extends AbstractSoapInterceptor {
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJInInterceptor.class);
+
+    public SAAJInInterceptor() {
+        setPhase(Phase.PRE_PROTOCOL);
+    }
+    
+    public void handleMessage(SoapMessage message) throws Fault {
+        try {
+            MessageFactory factory = null;
+            if (message.getVersion() instanceof Soap11) {
+                factory = MessageFactory.newInstance();
+            } else {
+                factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+            }
+            
+            SOAPMessage soapMessage = factory.createMessage();
+            message.setContent(SOAPMessage.class, soapMessage);
+            
+            SOAPPart part = soapMessage.getSOAPPart();
+            
+            Document node = (Document) message.getContent(Node.class);
+            DOMSource source = new DOMSource(node);
+            part.setContent(source);
+            
+            // TODO: add attachments and mime headers
+            
+            //replace header element if necessary
+            if (message.hasHeaders(Element.class)) {
+                Element headerElements = soapMessage.getSOAPHeader();    
+                message.setHeaders(Element.class, headerElements);
+            }
+            
+            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+            StaxUtils.readDocElements(soapMessage.getSOAPBody(), xmlReader, true);
+            
+            DOMSource bodySource = new DOMSource(soapMessage.getSOAPBody());
+            xmlReader = StaxUtils.createXMLStreamReader(bodySource);
+            xmlReader.nextTag();
+            xmlReader.nextTag(); // move past body tag
+            message.setContent(XMLStreamReader.class, xmlReader);
+        } catch (SOAPException soape) {
+            throw new SoapFault(new org.apache.cxf.common.i18n.Message(
+                    "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), soape,
+                    message.getVersion().getSender());
+        } catch (XMLStreamException e) {
+            throw new SoapFault(new org.apache.cxf.common.i18n.Message(
+                    "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e, message
+                    .getVersion().getSender());
+        }
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?view=auto&rev=519759
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Sun Mar 18 17:17:55 2007
@@ -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.binding.soap.saaj;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ResourceBundle;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.SoapVersion;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+
+/**
+ * Sets up the outgoing chain to build a SAAJ tree instead of writing
+ * directly to the output stream. First it will replace the XMLStreamWriter
+ * with one which writes to a SOAPMessage. Then it will add an interceptor
+ * at the end of the chain in the SEND phase which writes the resulting
+ * SOAPMessage.
+ */
+public class SAAJOutInterceptor extends AbstractSoapInterceptor {
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJOutInterceptor.class);
+
+    public SAAJOutInterceptor() {
+        setPhase(Phase.PRE_PROTOCOL);
+    }
+    
+    public void handleMessage(SoapMessage cxfMessage) throws Fault {
+        SoapVersion version = cxfMessage.getVersion();
+        try {
+            MessageFactory factory = null;
+            if (version.getVersion() == 1.1) {
+                factory = MessageFactory.newInstance();
+            } else {
+                factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+            }
+            SOAPMessage message = factory.createMessage();
+
+            SOAPPart soapPart = message.getSOAPPart();
+            W3CDOMStreamWriter writer = new W3CDOMStreamWriter(soapPart);
+            // Replace stax writer with DomStreamWriter
+            cxfMessage.setContent(XMLStreamWriter.class, writer);
+            cxfMessage.setContent(SOAPMessage.class, message);
+        } catch (SOAPException e) {
+            throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, version.getSender());
+        }
+        
+        // Add a final interceptor to write the message
+        cxfMessage.getInterceptorChain().add(new AbstractSoapInterceptor() {
+
+            @Override
+            public String getPhase() {
+                return Phase.SEND;
+            }
+
+            public void handleMessage(SoapMessage message) throws Fault {
+                SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
+                
+                if (soapMessage != null) {
+                    OutputStream os = message.getContent(OutputStream.class);
+                    try {
+                        soapMessage.writeTo(os);
+                        os.flush();
+                    } catch (IOException e) {
+                        throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, 
+                                            message.getVersion().getSender());
+                    } catch (SOAPException e) {
+                        throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, 
+                                            message.getVersion().getSender());
+                    }
+                }
+            }
+            
+        });
+       
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java?view=auto&rev=519759
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java (added)
+++ incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java Sun Mar 18 17:17:55 2007
@@ -0,0 +1,94 @@
+/**
+ * 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.binding.soap.saaj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.binding.soap.Soap12;
+import org.apache.cxf.binding.soap.TestBase;
+import org.apache.cxf.binding.soap.TestUtil;
+import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+
+
+public class SAAJInInterceptorTest extends TestBase {
+
+    private ReadHeadersInterceptor rhi;
+    private StaxInInterceptor staxIntc = new StaxInInterceptor();
+    private SAAJInInterceptor saajIntc;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        rhi = new ReadHeadersInterceptor();
+        rhi.setPhase("phase1");
+        chain.add(rhi);
+
+        saajIntc = new SAAJInInterceptor();
+        saajIntc.setPhase("phase2");
+        chain.add(saajIntc);
+
+    }
+
+    public void testHandleHeader() {
+        try {
+            prepareSoapMessage("../test-soap-header.xml");
+        } catch (IOException ioe) {
+            fail("Failed in creating soap message");
+        }
+
+        staxIntc.handleMessage(soapMessage);
+        rhi.handleMessage(soapMessage);
+        saajIntc.handleMessage(soapMessage);
+
+        // check the xmlReader should be placed on the first entry of the body
+        // element
+        XMLStreamReader xmlReader = soapMessage.getContent(XMLStreamReader.class);
+        assertEquals("check the first entry of body", "itinerary", xmlReader.getLocalName());
+
+        Element eleHeaders = soapMessage.getHeaders(Element.class);
+        List<Element> headerChilds = new ArrayList<Element>();
+        for (int i = 0; i < eleHeaders.getChildNodes().getLength(); i++) {
+            if (eleHeaders.getChildNodes().item(i) instanceof Element) {
+                Element element = (Element)eleHeaders.getChildNodes().item(i);
+                headerChilds.add(element);
+            }
+        }
+
+        assertEquals(2, headerChilds.size());
+    }
+
+    private void prepareSoapMessage(String message) throws IOException {
+
+        soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
+        ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass().getResourceAsStream(message),
+                                                           "text/xml");
+        soapMessage.setContent(InputStream.class, bads.getInputStream());
+
+    }
+}

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java Sun Mar 18 17:17:55 2007
@@ -44,7 +44,8 @@
 
     public StaxOutInterceptor() {
         super();
-        setPhase(Phase.PRE_PROTOCOL);
+        setPhase(Phase.PRE_STREAM);
+        getAfter().add(AttachmentOutInterceptor.class.getName());
     }
 
     public void handleMessage(Message message) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java Sun Mar 18 17:17:55 2007
@@ -86,15 +86,14 @@
         outPhases.add(new Phase(Phase.PREPARE_SEND, ++i * 1000));
 
         outPhases.add(new Phase(Phase.PRE_STREAM, ++i * 1000));
-        
-        outPhases.add(new Phase(Phase.PRE_PROTOCOL, ++i * 1000));        
-
-        outPhases.add(new Phase(Phase.USER_PROTOCOL, ++i * 1000));
-        outPhases.add(new Phase(Phase.POST_PROTOCOL, ++i * 1000));
 
+        outPhases.add(new Phase(Phase.PRE_PROTOCOL, ++i * 1000));        
+        
         outPhases.add(new Phase(Phase.WRITE, ++i * 1000));
         outPhases.add(new Phase(Phase.MARSHAL, ++i * 1000));
         
+        outPhases.add(new Phase(Phase.USER_PROTOCOL, ++i * 1000));
+        outPhases.add(new Phase(Phase.POST_PROTOCOL, ++i * 1000));
         
         outPhases.add(new Phase(Phase.USER_STREAM, ++i * 1000));
         outPhases.add(new Phase(Phase.POST_STREAM, ++i * 1000));

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Sun Mar 18 17:17:55 2007
@@ -73,130 +73,7 @@
     </bean>
     
     <bean id="org.apache.cxf.phase.PhaseManager" class="org.apache.cxf.phase.PhaseManagerImpl">
-        <constructor-arg>
-            <list>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="receive"/>
-                    <property name="priority" value="1000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-stream"/>
-                    <property name="priority" value="2000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-stream"/>
-                    <property name="priority" value="3000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-stream"/>
-                    <property name="priority" value="4000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="read"/>
-                    <property name="priority" value="5000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-protocol"/>
-                    <property name="priority" value="6000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-protocol"/>
-                    <property name="priority" value="7000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-protocol"/>
-                    <property name="priority" value="8000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="unmarshal"/>
-                    <property name="priority" value="9000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-logical"/>
-                    <property name="priority" value="10000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-logical"/>
-                    <property name="priority" value="11000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-logical"/>
-                    <property name="priority" value="12000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-invoke"/>
-                    <property name="priority" value="13000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="invoke"/>
-                    <property name="priority" value="14000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-invoke"/>
-                    <property name="priority" value="15000"/>
-                </bean>
-            </list>
-        </constructor-arg>
-        <constructor-arg>
-            <list>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="setup"/>
-                    <property name="priority" value="1000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-logical"/>
-                    <property name="priority" value="2000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-logical"/>
-                    <property name="priority" value="3000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-logical"/>
-                    <property name="priority" value="4000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="prepare-send"/>
-                    <property name="priority" value="5000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-stream"/>
-                    <property name="priority" value="6000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="pre-protocol"/>
-                    <property name="priority" value="7000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-protocol"/>
-                    <property name="priority" value="8000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-protocol"/>
-                    <property name="priority" value="9000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="write"/>
-                    <property name="priority" value="10000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="marshal"/>
-                    <property name="priority" value="11000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="user-stream"/>
-                    <property name="priority" value="12000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="post-stream"/>
-                    <property name="priority" value="13000"/>
-                </bean>
-                <bean class="org.apache.cxf.phase.Phase">
-                    <property name="name" value="send"/>
-                    <property name="priority" value="14000"/>
-                </bean>
-            </list>
-        </constructor-arg>
+        
     </bean>
     
     <bean id="org.apache.cxf.workqueue.WorkQueueManager" class="org.apache.cxf.workqueue.WorkQueueManagerImpl">

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WebServiceContextImpl.java Sun Mar 18 17:17:55 2007
@@ -21,8 +21,6 @@
 
 import java.security.Principal;
 
-//  TODO JAX-WS 2.1
-//import javax.xml.ws.EndpointReference;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/PortInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/PortInfoImpl.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/PortInfoImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/PortInfoImpl.java Sun Mar 18 17:17:55 2007
@@ -20,7 +20,6 @@
 package org.apache.cxf.jaxws.handler;
 
 import javax.xml.namespace.QName;
-
 import javax.xml.ws.handler.PortInfo;
 
 public class PortInfoImpl implements PortInfo {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java Sun Mar 18 17:17:55 2007
@@ -19,56 +19,38 @@
 
 package org.apache.cxf.jaxws.handler.soap;
 
-import java.io.IOException;
-import java.io.OutputStream;
 import java.net.URI;
 import java.util.HashSet;
-import java.util.ResourceBundle;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
 import javax.xml.ws.Binding;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPHandler;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
-import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
-import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
 public class SOAPHandlerInterceptor extends
         AbstractProtocolHandlerInterceptor<SoapMessage> implements
         SoapInterceptor {
-    public static final String SAAJ_ENABLED = "saaj.enabled";
-    private static final ResourceBundle BUNDLE = BundleUtils
-            .getBundle(SOAPHandlerInterceptor.class);
-
+    private static final SAAJOutInterceptor SAAJ_OUT = new SAAJOutInterceptor();
+    
     public SOAPHandlerInterceptor(Binding binding) {
         super(binding);
         setPhase(Phase.PRE_PROTOCOL);
-        addAfter((new StaxOutInterceptor()).getId());
+        addAfter(StaxOutInterceptor.class.getName());
+        addAfter(SAAJOutInterceptor.class.getName());
     }
 
     public Set<URI> getRoles() {
@@ -91,115 +73,37 @@
     }
 
     public void handleMessage(SoapMessage message) {
-
-        boolean saajEnabled = Boolean.TRUE.equals(message.getContextualProperty(SAAJ_ENABLED));
-        if (getInvoker(message).getProtocolHandlers().isEmpty() && !saajEnabled) {
+        if (getInvoker(message).getProtocolHandlers().isEmpty()) {
             return;
         }
         
         if (getInvoker(message).isOutbound()) {
-            XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
-            
-            try {
-                // Replace stax writer with DomStreamWriter
-                W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
-                message.setContent(XMLStreamWriter.class, writer);
-            } catch (ParserConfigurationException e) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                    "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e,
-                    message.getVersion().getSender());
+            SOAPMessage saaj = message.getContent(SOAPMessage.class); 
+            if (saaj == null) {
+                SAAJ_OUT.handleMessage(message);
             }
             
-            message.getInterceptorChain().doInterceptInSubChain(message);
+            final SOAPHandlerInterceptor handlerInterceptor = this;
+            message.getInterceptorChain().add(new AbstractSoapInterceptor() {
 
-            super.handleMessage(message);
+                @Override
+                public String getPhase() {
+                    return Phase.USER_PROTOCOL;
+                }
 
-            try {
-                // Stream SOAPMessage back to output stream if necessary
-                SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
-
-                if (soapMessage != null) {
-                    OutputStream os = message.getContent(OutputStream.class);
-                    soapMessage.writeTo(os);
-                    os.flush();
-                } else {
-                    XMLStreamWriter xtw = message.getContent(XMLStreamWriter.class);
-                    Document doc = ((W3CDOMStreamWriter)xtw).getDocument();
-                    StaxUtils.writeDocument(doc, origWriter, false);
+                public void handleMessage(SoapMessage message) throws Fault {
+                    handlerInterceptor.invokeSOAPHandlerInterceptors(message);
                 }
-                
-            } catch (IOException ioe) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), ioe,
-                        message.getVersion().getSender());
-            } catch (SOAPException soape) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), soape,
-                        message.getVersion().getSender());
-            } catch (XMLStreamException e) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e,
-                        message.getVersion().getSender());
-            }
+            });
         } else {
             super.handleMessage(message);
-
-            //SOAPMessageContextImpl ctx = (SOAPMessageContextImpl) createProtocolMessageContext(message);
-            //ctx.getMessage();
-
-            try {
-                SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
-
-                if (soapMessage == null) {
-                    if (saajEnabled) {
-                        soapMessage = new SOAPMessageContextImpl(message).getMessage();
-                        message.setContent(SOAPMessage.class, soapMessage);
-                    } else {
-                        return;
-                    }
-                }
-
-                // soapMessage is not null means stax reader has been consumed
-                // by SAAJ, we need to replace stax reader with a new stax reader
-                // built from the content streamed from SAAJ SOAPBody.
-                SOAPBody body = soapMessage.getSOAPBody();
-
-                CachedStream outStream = new CachedStream();
-                XMLUtils.writeTo(body, outStream);
-
-                XMLStreamReader reader = null;
-                reader = XMLInputFactory.newInstance().createXMLStreamReader(
-                        outStream.getInputStream());
-                // skip the start element of soap body.
-                if (reader.nextTag() == XMLStreamConstants.START_ELEMENT) {
-                    reader.getName();
-                }
-                reader.next();
-                message.setContent(XMLStreamReader.class, reader);
-                
-                //replace header element if necessary
-                if (message.hasHeaders(Element.class)) {
-                    Element headerElements = message.getHeaders(Element.class);
-                    headerElements = soapMessage.getSOAPHeader();    
-                    message.setHeaders(Element.class, headerElements);
-                }
-            } catch (IOException ioe) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), ioe,
-                        message.getVersion().getSender());
-            } catch (SOAPException soape) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), soape,
-                        message.getVersion().getSender());
-            } catch (XMLStreamException e) {
-                throw new SoapFault(new org.apache.cxf.common.i18n.Message(
-                        "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e, message
-                        .getVersion().getSender());
-            }
-
         }
     }
 
+    protected void invokeSOAPHandlerInterceptors(SoapMessage message) {
+        super.handleMessage(message);
+    }
+    
     @Override
     protected MessageContext createProtocolMessageContext(Message message) {
         return new SOAPMessageContextImpl(message);
@@ -207,17 +111,4 @@
 
     public void handleFault(SoapMessage message) {
     }
-
-    private class CachedStream extends AbstractCachedOutputStream {
-        protected void doFlush() throws IOException {
-            currentStream.flush();
-        }
-
-        protected void doClose() throws IOException {
-        }
-
-        protected void onWrite() throws IOException {
-        }
-    }
-
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPMessageContextImpl.java Sun Mar 18 17:17:55 2007
@@ -19,49 +19,29 @@
 
 package org.apache.cxf.jaxws.handler.soap;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.ResourceBundle;
 import java.util.Set;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConstants;
-import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPPart;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-
-import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapMessage;
-import org.apache.cxf.binding.soap.SoapVersion;
-import org.apache.cxf.common.i18n.BundleUtils;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.io.AbstractCachedOutputStream;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.XMLMessage;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
 public class SOAPMessageContextImpl extends WrappedMessageContext implements SOAPMessageContext {
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SOAPMessageContextImpl.class);
-
+    private static final SAAJInInterceptor SAAJ_IN = new SAAJInInterceptor();
+    
     SOAPMessageContextImpl(Message m) {
         super(m);
     }
@@ -73,107 +53,26 @@
     public SOAPMessage getMessage() {
         SOAPMessage message = getWrappedMessage().getContent(SOAPMessage.class);
         if (null == message) {
+            Boolean outboundProperty = (Boolean)get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
 
-            try {
-                Boolean outboundProperty = (Boolean)get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-                if (outboundProperty) {
-                    SoapVersion soapVersion = ((SoapMessage)getWrappedMessage()).getVersion();
-                    
-                    if (soapVersion == null) {
-                        soapVersion = Soap11.getInstance();
-                    }
-                    soapVersion = ((SoapMessage)getWrappedMessage()).getVersion();
-                 
-                    XMLStreamWriter xtw = getWrappedMessage().getContent(XMLStreamWriter.class);
-                    Document doc = ((W3CDOMStreamWriter)xtw).getDocument();
-                                  
-                    MessageFactory factory = null;
-                    if (soapVersion.getVersion() == 1.1) {
-                        factory = MessageFactory.newInstance();
-                    } else {
-                        factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+            // No SOAPMessage exists yet, so lets create one
+            if (!outboundProperty) {
+                if (getWrappedMessage().getContent(Object.class) != null) {
+                    //The Dispatch/Provider case:
+                    Object obj = getWrappedMessage().getContent(Object.class);
+                    if (obj instanceof SOAPMessage) {
+                        message = (SOAPMessage)obj;
+                    } else if (obj instanceof SOAPBody) {
+                        // what to do
+                    } else if (obj instanceof XMLMessage) {
+                        // what to do
                     }
-                    message = factory.createMessage();
-
-                    SOAPPart soapPart = message.getSOAPPart();
-                    DOMSource preppedMsgSrc = new DOMSource(doc.getDocumentElement());
-                    soapPart.setContent(preppedMsgSrc);
-                    message.saveChanges();
-
                 } else {
-                    
-                    if (getWrappedMessage().getContent(Object.class) != null) {
-                        //The Dispatch/Provider case:
-                        Object obj = getWrappedMessage().getContent(Object.class);
-                        if (obj instanceof SOAPMessage) {
-                            message = (SOAPMessage)obj;
-                        } else if (obj instanceof SOAPBody) {
-                            // what to do
-                        } else if (obj instanceof XMLMessage) {
-                            // what to do
-                        }
-
-                    } else {
-                        CachedStream cs = new CachedStream();
-                        XMLStreamWriter writer = StaxUtils.getXMLOutputFactory().createXMLStreamWriter(cs);
-                        XMLStreamReader xmlReader = getWrappedMessage().getContent(XMLStreamReader.class);
-
-                        // Create a mocked inputStream to feed SAAJ,
-                        // only SOAPBody is from real data
-                        // REVISIT: soap version here is not important, we just
-                        // use soap11.
-                        SoapVersion soapVersion = Soap11.getInstance();
-                        writer.setPrefix(soapVersion.getPrefix(), soapVersion.getNamespace());
-                        writer.writeStartElement(soapVersion.getPrefix(), soapVersion.getEnvelope()
-                            .getLocalPart(), soapVersion.getNamespace());
-                        writer.writeNamespace(soapVersion.getPrefix(), soapVersion.getNamespace());
-
-                        // Write headers
-                        if (getWrappedSoapMessage().hasHeaders(Element.class)) {
-                            Element headerElements = getWrappedSoapMessage().getHeaders(Element.class);
-                            StaxUtils.writeElement(headerElements, writer, true);
-                        }
-
-                        writer.writeStartElement(soapVersion.getPrefix(), soapVersion.getBody()
-                            .getLocalPart(), soapVersion.getNamespace());
-
-                        // Write soap body
-                        StaxUtils.copy(xmlReader, writer);
-
-                        xmlReader.close();
-                        writer.close();
-                        cs.doFlush();
-
-                        InputStream newIs = cs.getInputStream();
-                        MessageFactory factory = MessageFactory.newInstance();
-                        MimeHeaders mhs = null;
-                        message = factory.createMessage(mhs, newIs);
-                        
-                        getWrappedMessage().setContent(SOAPMessage.class, message);
-                    }
+                    SAAJ_IN.handleMessage(getWrappedSoapMessage());
+                    message = getWrappedSoapMessage().getContent(SOAPMessage.class);
                 }
-
-                
-/*                System.out.println("11111------------------");
-                PrintStream out = System.out;
-                message.writeTo(out);
-                out.println();
-                System.out.println("11111------------------");
-*/
-                getWrappedMessage().setContent(SOAPMessage.class, message);
-
-            } catch (IOException ioe) {
-                throw new Fault(new org.apache.cxf.common.i18n.Message("SOAPHANDLERINTERCEPTOR_EXCEPTION",
-                                                                       BUNDLE), ioe);
-            } catch (SOAPException soape) {
-                throw new Fault(new org.apache.cxf.common.i18n.Message("SOAPHANDLERINTERCEPTOR_EXCEPTION",
-                                                                       BUNDLE), soape);
-            } catch (XMLStreamException e) {
-                e.printStackTrace();
-                throw new Fault(new org.apache.cxf.common.i18n.Message("SOAPHANDLERINTERCEPTOR_EXCEPTION",
-                                                                       BUNDLE), e);
             }
+           
         }
 
         return message;
@@ -203,24 +102,10 @@
     }
 
     public Set<String> getRoles() {
-        // TODO Auto-generated method stub
         return null;
     }
 
     private SoapMessage getWrappedSoapMessage() {
         return (SoapMessage)getWrappedMessage();
-    }
-
-    private class CachedStream extends AbstractCachedOutputStream {
-        protected void doFlush() throws IOException {
-            currentStream.flush();
-        }
-
-        protected void doClose() throws IOException {
-            currentStream.close();
-        }
-
-        protected void onWrite() throws IOException {
-        }
     }
 }

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=519759&r1=519758&r2=519759
==============================================================================
--- 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 Sun Mar 18 17:17:55 2007
@@ -68,8 +68,7 @@
         } else {
              // TODO: what for non soap bindings?
         }
-//        handlerInterceptors.add(new StreamHandlerInterceptor(binding));
-        
+
         List<Interceptor> fault = super.getOutFaultInterceptors();
         fault.addAll(handlerInterceptors);
         List<Interceptor> in = super.getInInterceptors();

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=519759&r1=519758&r2=519759
==============================================================================
--- 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 Sun Mar 18 17:17:55 2007
@@ -35,6 +35,8 @@
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -112,7 +114,8 @@
                 out.addBefore(SOAPHandlerInterceptor.class.getName());
                 getService().getOutInterceptors().add(out);
                 
-                getService().put(SOAPHandlerInterceptor.SAAJ_ENABLED, Boolean.TRUE);
+                getService().getInInterceptors().add(new SAAJInInterceptor());
+                getService().getOutInterceptors().add(new SAAJOutInterceptor());
             } else {
                 getService().getInInterceptors().add(new ProviderInDatabindingInterceptor(type));
                 getService().getOutInterceptors().add(new ProviderOutDatabindingInterceptor());

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java Sun Mar 18 17:17:55 2007
@@ -24,7 +24,6 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
-
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxws.service.Hello2;
 import org.apache.cxf.jaxws.service.Hello3;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JAXWSMethodInvokerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JAXWSMethodInvokerTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JAXWSMethodInvokerTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JAXWSMethodInvokerTest.java Sun Mar 18 17:17:55 2007
@@ -22,7 +22,6 @@
 import org.apache.cxf.common.util.factory.Factory;
 import org.apache.cxf.jaxws.service.Hello;
 import org.apache.cxf.message.Exchange;
-
 import org.apache.cxf.service.invoker.ScopePolicy;
 import org.easymock.classextension.EasyMock;
 import org.junit.Assert;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/MessageReplayObserver.java Sun Mar 18 17:17:55 2007
@@ -23,7 +23,6 @@
 import java.io.OutputStream;
 
 import junit.framework.Assert;
-
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.transport.Conduit;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java Sun Mar 18 17:17:55 2007
@@ -24,7 +24,6 @@
 import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.message.MessageImpl;
 
 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/AbstractProtocolHandlerInterceptorTest.java Sun Mar 18 17:17:55 2007
@@ -24,7 +24,6 @@
 import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.message.AbstractWrappedMessage;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBuilderTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBuilderTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBuilderTest.java Sun Mar 18 17:17:55 2007
@@ -29,7 +29,6 @@
 import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.jaxws.javaee.FullyQualifiedClassType;
 import org.apache.cxf.jaxws.javaee.HandlerChainType;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainInvokerTest.java Sun Mar 18 17:17:55 2007
@@ -33,7 +33,6 @@
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java Sun Mar 18 17:17:55 2007
@@ -30,7 +30,6 @@
 import javax.xml.ws.handler.MessageContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.message.Exchange;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalMessageImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalMessageImplTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalMessageImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalMessageImplTest.java Sun Mar 18 17:17:55 2007
@@ -25,7 +25,6 @@
 import javax.xml.bind.JAXBContext;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.handlers.types.AddNumbers;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptorTest.java Sun Mar 18 17:17:55 2007
@@ -54,7 +54,6 @@
 import org.w3c.dom.NodeList;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
@@ -66,13 +65,14 @@
 import org.apache.cxf.jaxws.handler.HandlerChainInvoker;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManagerImpl;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
-
 import org.easymock.classextension.IMocksControl;
 
+
 import static org.easymock.EasyMock.expect;
 import static org.easymock.classextension.EasyMock.createNiceControl;
 
@@ -93,8 +93,6 @@
                 Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
                 if (outboundProperty.booleanValue()) {
                     try {
-                        //SOAPMessage message = smc.getMessage();
-                        //message.getSOAPBody();                                               
                         smc.setMessage(preparemSOAPMessage("resources/greetMeRpcLitRespChanged.xml"));
                     } catch (Exception e) {
                         throw new Fault(e);
@@ -130,9 +128,15 @@
         InterceptorChain chain = new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases());
         //Interceptors after SOAPHandlerInterceptor DOMXMLStreamWriter to write
         chain.add(new AbstractProtocolHandlerInterceptor<SoapMessage>(binding) {
+            
+            @Override
+            public String getPhase() {
+                return Phase.MARSHAL;
+            }
+
             public void handleMessage(SoapMessage message) throws Fault {
                 try {
-                    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class); 
+                    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
                     SoapVersion soapVersion = Soap11.getInstance();
                     writer.setPrefix(soapVersion.getPrefix(), soapVersion.getNamespace());
                     writer.writeStartElement(soapVersion.getPrefix(), 
@@ -142,21 +146,24 @@
                     writer.writeEndElement();
                     
                     writer.flush();
+                    message.getInterceptorChain().finishSubChain();
                 } catch (Exception e) {
                     // do nothing
                 }
             }
 
         });
+        chain.add(new SOAPHandlerInterceptor(binding));
         message.setInterceptorChain(chain);
         control.replay();
 
-        SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
-        li.handleMessage(message);
+        chain.doIntercept(message);
+        
         control.verify();
 
         // Verify outputStream
         CachedStream expectedOs = prepareOutputStreamFromResource("resources/greetMeRpcLitRespChanged.xml");
+
         assertTrue("The content of outputStream should remain unchanged", compareInputStream(expectedOs
             .getInputStream(), originalEmptyOs.getInputStream()));
 
@@ -219,14 +226,14 @@
         expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker).anyTimes();
         // This is to set direction to inbound
         expect(exchange.getOutMessage()).andReturn(null);
+        
         SoapMessage message = new SoapMessage(new MessageImpl());
         message.setExchange(exchange);
         XMLStreamReader reader = preparemXMLStreamReader("resources/greetMeRpcLitReq.xml");
         message.setContent(XMLStreamReader.class, reader);
-        Element headerElement = preparemSOAPHeader();
-        message.setHeaders(Element.class, headerElement);
-        message.put(Element.class, headerElement);
-
+        Object[] headerInfo = preparemSOAPHeader();
+        message.setHeaders(Element.class, (Element) headerInfo[1]);
+        message.setContent(Node.class, (Document) headerInfo[0]);
         control.replay();
 
         SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
@@ -306,6 +313,12 @@
         InterceptorChain chain = new PhaseInterceptorChain((new PhaseManagerImpl()).getOutPhases());
         //Interceptors after SOAPHandlerInterceptor DOMXMLStreamWriter to write
         chain.add(new AbstractProtocolHandlerInterceptor<SoapMessage>(binding) {
+
+            @Override
+            public String getPhase() {
+                return Phase.MARSHAL;
+            }
+
             public void handleMessage(SoapMessage message) throws Fault {
                 try {
                     XMLStreamWriter writer = message.getContent(XMLStreamWriter.class); 
@@ -316,23 +329,25 @@
                                           soapVersion.getNamespace());
                     writer.writeNamespace(soapVersion.getPrefix(), soapVersion.getNamespace());
                     
-                    Element headerElement = preparemSOAPHeader();
-                    StaxUtils.writeElement(headerElement, writer, true, false);
+                    Object[] headerInfo = preparemSOAPHeader();
+                    StaxUtils.writeElement((Element) headerInfo[1], writer, true, false);
                     
                     writer.writeEndElement();
                     
                     writer.flush();
+                    message.getInterceptorChain().finishSubChain();
                 } catch (Exception e) {
                     // do nothing
                 }
             }
 
         });
+        chain.add(new SOAPHandlerInterceptor(binding));
         message.setInterceptorChain(chain);
         control.replay();
 
-        SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
-        li.handleMessage(message);
+        chain.doIntercept(message);
+        
         control.verify();
 
         // Verify SOAPMessage header
@@ -482,17 +497,28 @@
         return xmlReader;
     }
 
-    private Element preparemSOAPHeader() throws Exception {
+    private Object[] preparemSOAPHeader() throws Exception {
         Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
         SoapVersion soapVersion = Soap11.getInstance();
-        Element headerElement = doc.createElementNS(soapVersion.getNamespace(), "SOAP-ENV:"
-                                                                                + soapVersion.getHeader()
-                                                                                    .getLocalPart());
+        Element envElement = doc.createElementNS(soapVersion.getEnvelope().getNamespaceURI(),
+                                                 soapVersion.getEnvelope().getLocalPart());
+        
+        Element headerElement = doc.createElementNS(soapVersion.getNamespace(), 
+                                                    soapVersion.getHeader().getLocalPart());
+        
+        Element bodyElement = doc.createElementNS(soapVersion.getBody().getNamespaceURI(),
+                                                  soapVersion.getBody().getLocalPart());
+        
         Element childElement = doc.createElementNS("http://apache.org/hello_world_rpclit/types",
                                                    "ns2:header1");
+        
         childElement.setAttributeNS(soapVersion.getNamespace(), "SOAP-ENV:mustUnderstand", "true");
         headerElement.appendChild(childElement);
-        return headerElement;
+        envElement.appendChild(headerElement);
+        envElement.appendChild(bodyElement);
+        doc.appendChild(envElement);
+        
+        return new Object[] {doc, headerElement};
     }
 
     private SOAPMessage preparemSOAPMessage(String resouceName) throws Exception {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/ValidationServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/ValidationServer.java?view=diff&rev=519759&r1=519758&r2=519759
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/ValidationServer.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/schema_validation/ValidationServer.java Sun Mar 18 17:17:55 2007
@@ -44,7 +44,9 @@
     }
 
     public boolean stopInProcess() throws Exception {
-        System.setProperty("cxf.config.file.url", oldConfig);
+        if (oldConfig != null) {
+            System.setProperty("cxf.config.file.url", oldConfig);
+        }
         return super.stopInProcess();
     }
 



Mime
View raw message