cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1299524 - in /cxf/trunk: api/src/main/java/org/apache/cxf/staxutils/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ rt/frontend/jaxws/src/main/java/o...
Date Mon, 12 Mar 2012 02:20:16 GMT
Author: dkulp
Date: Mon Mar 12 02:20:16 2012
New Revision: 1299524

URL: http://svn.apache.org/viewvc?rev=1299524&view=rev
Log:
Enhance SAAJ usage to better work with other SAAJ implementations

Added:
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
  (with props)
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
  (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestMustUnderstandHandler.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Mon Mar 12 02:20:16
2012
@@ -531,7 +531,10 @@ public final class StaxUtils {
                 }
                 break;
             case XMLStreamConstants.CHARACTERS:
-                writer.writeCharacters(reader.getText());
+                String s = reader.getText();
+                if (s != null) {
+                    writer.writeCharacters(s);
+                }
                 break;
             case XMLStreamConstants.COMMENT:
                 writer.writeComment(reader.getText());

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java Mon Mar 12
02:20:16 2012
@@ -413,6 +413,23 @@ public class W3CDOMStreamReader extends 
         }
         return super.getLocation();
     }
+    
+    public String toString() {
+        if (document == null) {
+            return "<null>";
+        }
+        if (document.getDocumentElement() == null) {
+            return "<null document element>";
+        }
+        try {
+            return StaxUtils.toString(document);
+        } catch (XMLStreamException e) {
+            return super.toString();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            return super.toString();
+        }
+    }
 
     
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java Mon Mar 12
02:20:16 2012
@@ -97,7 +97,7 @@ public class W3CDOMStreamWriter implemen
     }
 
     public void writeStartElement(String local) throws XMLStreamException {
-        newChild(document.createElementNS(null, local));
+        createAndAddElement(null, local, null);
     }
 
     protected void newChild(Element element) {
@@ -122,20 +122,31 @@ public class W3CDOMStreamWriter implemen
     }
 
     public void writeStartElement(String namespace, String local) throws XMLStreamException
{
-        newChild(document.createElementNS(namespace, local));
+        createAndAddElement(null, local, namespace);
     }
 
     public void writeStartElement(String prefix, String local, String namespace) throws XMLStreamException
{
         if (prefix == null || prefix.equals("")) {
             writeStartElement(namespace, local);
         } else {
-            newChild(document.createElementNS(namespace, prefix + ":" + local));
+            createAndAddElement(prefix, local, namespace);
             if (nsRepairing
                 && !prefix.equals(getNamespaceContext().getPrefix(namespace))) {
                 writeNamespace(prefix, namespace);
             }
         }
     }
+    protected void createAndAddElement(String prefix, String local, String namespace) {
+        if (prefix == null) {
+            if (namespace == null) {
+                newChild(document.createElementNS(null, local));
+            } else {
+                newChild(document.createElementNS(namespace, local));
+            }
+        } else {
+            newChild(document.createElementNS(namespace, prefix + ":" + local));
+        }
+    }
 
     public void writeEmptyElement(String namespace, String local) throws XMLStreamException
{
         writeStartElement(namespace, local);
@@ -307,4 +318,20 @@ public class W3CDOMStreamWriter implemen
     public void flush() throws XMLStreamException {
     }
     
+    public String toString() {
+        if (document == null) {
+            return "<null>";
+        }
+        if (document.getDocumentElement() == null) {
+            return "<null document element>";
+        }
+        try {
+            return StaxUtils.toString(document);
+        } catch (XMLStreamException e) {
+            return super.toString();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            return super.toString();
+        }
+    }
 }

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Mon Mar 12 02:20:16 2012
@@ -55,6 +55,7 @@ import org.apache.cxf.message.MessageUti
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
 
 public class ReadHeadersInterceptor extends AbstractSoapInterceptor {
@@ -151,8 +152,12 @@ public class ReadHeadersInterceptor exte
                     .getBody());
 
                 Node nd = message.getContent(Node.class);
+                W3CDOMStreamWriter writer = message.get(W3CDOMStreamWriter.class);
                 Document doc = null;
-                if (nd instanceof Document) {
+                if (writer != null) {
+                    StaxUtils.copy(filteredReader, writer);
+                    doc = writer.getDocument();
+                } else if (nd instanceof Document) {
                     doc = (Document)nd;
                     StaxUtils.readDocElements(doc, doc, filteredReader, false, false);
                 } else {

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Mon Mar 12 02:20:16 2012
@@ -134,6 +134,7 @@ public class SAAJInInterceptor extends A
                 
                 SOAPPart part = soapMessage.getSOAPPart();
                 message.setContent(Node.class, part);
+                message.put(W3CDOMStreamWriter.class, new SAAJStreamWriter(part));
                 message.put(BODY_FILLED_IN, Boolean.FALSE);
 
             } catch (RuntimeException ex) {
@@ -182,14 +183,15 @@ public class SAAJInInterceptor extends A
             if (xmlReader == null) {
                 return;
             }
-            SOAPPart part = soapMessage.getSOAPPart();
+            final SOAPPart part = soapMessage.getSOAPPart();
             Document node = (Document) message.getContent(Node.class);
             if (node != part) {
                 if (node == null) {
                     // replicate 2.1 behavior.
                     part.setContent(new DOMSource(null));
                 } else {
-                    StaxUtils.copy(node, new W3CDOMStreamWriter(part));
+                    //part.setContent(new DOMSource(node));
+                    StaxUtils.copy(node, new SAAJStreamWriter(part));
                 }
             }
             message.setContent(Node.class, soapMessage.getSOAPPart());
@@ -220,7 +222,8 @@ public class SAAJInInterceptor extends A
             if (message.hasHeaders()) {
                 replaceHeaders(soapMessage, message);
             }
-            if (soapMessage.getSOAPHeader() == null) {
+
+            if (soapMessage.getSOAPPart().getEnvelope().getHeader() == null) {
                 soapMessage.getSOAPPart().getEnvelope().addHeader();
             }
             
@@ -233,7 +236,7 @@ public class SAAJInInterceptor extends A
                     ? Soap11FaultInInterceptor.unmarshalFault(message, xmlReader)
                     : Soap12FaultInInterceptor.unmarshalFault(message, xmlReader);
                 if (fault.getFaultCode() != null) {
-                    soapFault.setFaultCode(fault.getFaultCode());
+                    SAAJUtils.setFaultCode(soapFault, fault.getFaultCode());
                 }
                 if (fault.getMessage() != null) {
                     soapFault.setFaultString(fault.getMessage());
@@ -261,7 +264,8 @@ public class SAAJInInterceptor extends A
                 DOMSource bodySource = new DOMSource(soapFault);
                 xmlReader = StaxUtils.createXMLStreamReader(bodySource);
             } else { 
-                StaxUtils.readDocElements(soapMessage.getSOAPBody(), xmlReader, true, true);
+                StaxUtils.readDocElements(soapMessage.getSOAPPart().getEnvelope().getBody(),
+                                          xmlReader, true, true);
                 DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
                 xmlReader = StaxUtils.createXMLStreamReader(bodySource);
                 xmlReader.nextTag();
@@ -280,7 +284,7 @@ public class SAAJInInterceptor extends A
     }
 
     public static void replaceHeaders(SOAPMessage soapMessage, SoapMessage message) throws
SOAPException {
-        SOAPHeader header = soapMessage.getSOAPHeader();
+        SOAPHeader header = SAAJUtils.getHeader(soapMessage);
         if (header == null) {
             return;
         }

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
Mon Mar 12 02:20:16 2012
@@ -126,7 +126,7 @@ public class SAAJOutInterceptor extends 
                 
                 XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
                 message.put(ORIGINAL_XML_WRITER, origWriter);
-                W3CDOMStreamWriter writer = new W3CDOMStreamWriter(soapPart);
+                W3CDOMStreamWriter writer = new SAAJStreamWriter(soapPart);
                 // Replace stax writer with DomStreamWriter
                 message.setContent(XMLStreamWriter.class, writer);
                 message.setContent(SOAPMessage.class, soapMessage);

Added: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java?rev=1299524&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
(added)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJStreamWriter.java
Mon Mar 12 02:20:16 2012
@@ -0,0 +1,83 @@
+/**
+ * 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 javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPPart;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+
+public final class SAAJStreamWriter extends W3CDOMStreamWriter {
+    private final SOAPPart part;
+
+    public SAAJStreamWriter(SOAPPart part) {
+        super(part);
+        this.part = part;
+    }
+
+    protected void createAndAddElement(String prefix, String local, String namespace) {
+        try {
+            if (namespace != null 
+                && namespace.equals(part.getEnvelope().getElementName().getURI()))
{
+                if ("Envelope".equals(local)) {
+                    setChild(part.getEnvelope(), false);
+                    return;
+                } else if ("Body".equals(local)) {
+                    setChild(part.getEnvelope().getBody(), false);
+                    return;
+                } else if ("Header".equals(local)) {
+                    setChild(part.getEnvelope().getHeader(), false);
+                    return;
+                } else if ("Fault".equals(local)) {
+                    SOAPFault f = part.getEnvelope().getBody().getFault();
+                    if (f == null) {
+                        f = part.getEnvelope().getBody().addFault();
+                    }
+                    setChild(f, false);
+                    return;
+                }
+            } else if (getCurrentNode() instanceof SOAPFault) {
+                SOAPFault f = (SOAPFault)getCurrentNode();
+                Node nd = f.getFirstChild();
+                while (nd != null) {
+                    if (nd instanceof Element) {
+                        Element el = (Element)nd;
+                        if (local.equals(nd.getLocalName())) {
+                            setChild(el, false);
+                            nd = el.getFirstChild();
+                            while (nd != null) {
+                                el.removeChild(nd);
+                                nd = el.getFirstChild();
+                            }
+                            return;
+                        }
+                    }
+                    nd = nd.getNextSibling();
+                }
+            }
+        } catch (SOAPException e) {
+            //ignore, fallback
+        }
+        super.createAndAddElement(prefix, local, namespace);
+    }
+}
\ No newline at end of file

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

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

Added: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java?rev=1299524&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
(added)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java
Mon Mar 12 02:20:16 2012
@@ -0,0 +1,69 @@
+/**
+ * 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 javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.cxf.common.util.StringUtils;
+
+/**
+ * 
+ */
+public final class SAAJUtils {
+    
+    private SAAJUtils() {
+        //not constructed
+    }
+    
+    public static SOAPHeader getHeader(SOAPMessage m) throws SOAPException {
+        try {
+            return m.getSOAPHeader();
+        } catch (UnsupportedOperationException ex) {
+            return m.getSOAPPart().getEnvelope().getHeader();
+        }
+    }
+    public static SOAPBody getBody(SOAPMessage m) throws SOAPException {
+        try {
+            return m.getSOAPBody();
+        } catch (UnsupportedOperationException ex) {
+            return m.getSOAPPart().getEnvelope().getBody();
+        }
+    }
+    public static void setFaultCode(SOAPFault f, QName code) throws SOAPException {
+        try {
+            f.setFaultCode(code);
+        } catch (Throwable t) {
+            int count = 1;
+            String pfx = "fc1";
+            while (!StringUtils.isEmpty(f.getNamespaceURI(pfx))) {
+                count++;
+                pfx = "fc" + count;
+            }
+            f.addNamespaceDeclaration(pfx, code.getNamespaceURI());
+            f.setFaultCode(pfx + ":" + code.getLocalPart());
+        }
+        
+    }
+}

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

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

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Mon
Mar 12 02:20:16 2012
@@ -48,6 +48,7 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.saaj.SAAJFactoryResolver;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Client;
@@ -195,7 +196,7 @@ public class JaxWsClientProxy extends or
             //method to work.  Try the saaj 1.2 method of doing this.
             try {
                 soapFault = binding.getMessageFactory().createMessage()
-                    .getSOAPBody().addFault();
+                    .getSOAPPart().getEnvelope().getBody().addFault();
             } catch (Throwable t2) {
                 //still didn't work, we'll just throw what we have
                 return null;
@@ -214,7 +215,7 @@ public class JaxWsClientProxy extends or
                 }
             }
             soapFault.setFaultString(((SoapFault)ex).getReason());
-            soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
+            SAAJUtils.setFaultCode(soapFault, ((SoapFault)ex).getFaultCode());
             soapFault.setFaultActor(((SoapFault)ex).getRole());
             if (((SoapFault)ex).getSubCode() != null) {
                 soapFault.appendFaultSubcode(((SoapFault)ex).getSubCode());

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainInvoker.java
Mon Mar 12 02:20:16 2012
@@ -45,6 +45,7 @@ import org.apache.cxf.binding.soap.SoapF
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.binding.soap.saaj.SAAJFactoryResolver;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.context.WebServiceContextImpl;
@@ -444,13 +445,13 @@ public class HandlerChainInvoker {
             soapMessage = SAAJFactoryResolver.createMessageFactory(version).createMessage();
             msg.setContent(SOAPMessage.class, soapMessage);
 
-            SOAPBody body = soapMessage.getSOAPBody();
+            SOAPBody body = SAAJUtils.getBody(soapMessage);
             SOAPFault soapFault = body.addFault();
 
             if (exception instanceof SOAPFaultException) {
                 SOAPFaultException sf = (SOAPFaultException)exception;
                 soapFault.setFaultString(sf.getFault().getFaultString());
-                soapFault.setFaultCode(sf.getFault().getFaultCode());
+                SAAJUtils.setFaultCode(soapFault, sf.getFault().getFaultCodeAsQName());
                 soapFault.setFaultActor(sf.getFault().getFaultActor());
                 if (sf.getFault().hasDetail()) {
                     Node nd = soapMessage.getSOAPPart().importNode(sf.getFault().getDetail(),
@@ -465,7 +466,7 @@ public class HandlerChainInvoker {
             } else if (exception instanceof Fault) {
                 SoapFault sf = SoapFault.createFault((Fault)exception, ((SoapMessage)msg).getVersion());
                 soapFault.setFaultString(sf.getReason());
-                soapFault.setFaultCode(sf.getFaultCode());
+                SAAJUtils.setFaultCode(soapFault, sf.getFaultCode());
                 if (sf.hasDetails()) {
                     soapFault.addDetail();
                     Node nd = soapMessage.getSOAPPart().importNode(sf.getDetail(), true);
@@ -476,7 +477,8 @@ public class HandlerChainInvoker {
                     }
                 }
             } else {
-                soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
+                SAAJUtils.setFaultCode(soapFault, 
+                                       new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
                 soapFault.setFaultString(exception.getMessage());
             }
         } catch (SOAPException e) {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
Mon Mar 12 02:20:16 2012
@@ -45,6 +45,7 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.saaj.SAAJFactoryResolver;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.common.WSDLConstants;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -80,7 +81,7 @@ public class LogicalMessageImpl implemen
                 XMLStreamReader reader = null;
                 if (msg != null) {
                     try {
-                        Node node = msg.getSOAPBody().getFirstChild();
+                        Node node = SAAJUtils.getBody(msg).getFirstChild();
                         while (node != null && !(node instanceof Element))  {
                             node = node.getNextSibling();
                         }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerFaultOutInterceptor.java
Mon Mar 12 02:20:16 2012
@@ -42,6 +42,7 @@ import org.apache.cxf.binding.soap.SoapM
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptor;
@@ -134,7 +135,7 @@ public class SOAPHandlerFaultOutIntercep
              */
             try {
                 SOAPMessage originalMsg = message.getContent(SOAPMessage.class);
-                SOAPBody body = originalMsg.getSOAPBody();
+                SOAPBody body = originalMsg.getSOAPPart().getEnvelope().getBody();
                 body.removeContents();
 
                 SOAPFault soapFault = body.addFault();
@@ -142,7 +143,7 @@ public class SOAPHandlerFaultOutIntercep
                 if (exception instanceof SOAPFaultException) {
                     SOAPFaultException sf = (SOAPFaultException)exception;
                     soapFault.setFaultString(sf.getFault().getFaultString());
-                    soapFault.setFaultCode(sf.getFault().getFaultCodeAsQName());
+                    SAAJUtils.setFaultCode(soapFault, sf.getFault().getFaultCodeAsQName());
                     soapFault.setFaultActor(sf.getFault().getFaultActor());
                     if (sf.getFault().hasDetail()) {
                         Node nd = originalMsg.getSOAPPart().importNode(
@@ -154,7 +155,7 @@ public class SOAPHandlerFaultOutIntercep
                     SoapFault sf = SoapFault.createFault((Fault)exception, message
                         .getVersion());
                     soapFault.setFaultString(sf.getReason());
-                    soapFault.setFaultCode(sf.getFaultCode());
+                    SAAJUtils.setFaultCode(soapFault, sf.getFaultCode());
                     if (sf.hasDetails()) {
                         soapFault.addDetail();
                         Node nd = originalMsg.getSOAPPart().importNode(sf.getDetail(), true);
@@ -166,7 +167,8 @@ public class SOAPHandlerFaultOutIntercep
                     }
                 } else {
                     soapFault.setFaultString(exception.getMessage());
-                    soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandleFault"));
+                    SAAJUtils.setFaultCode(soapFault,
+                                           new QName("http://cxf.apache.org/faultcode", "HandleFault"));
                 }
             } catch (SOAPException e) {
                 // do nothing

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
Mon Mar 12 02:20:16 2012
@@ -50,6 +50,7 @@ import org.apache.cxf.binding.soap.inter
 import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -257,7 +258,7 @@ public class SOAPHandlerInterceptor exte
         try {            
             List<SOAPElement> params = new ArrayList<SOAPElement>();
             message.put(MessageContext.REFERENCE_PARAMETERS, params);
-            SOAPHeader head = msg.getSOAPHeader();
+            SOAPHeader head = SAAJUtils.getHeader(msg);
             if (head != null) {
                 Iterator<Node> it = CastUtils.cast(head.getChildElements());
                 while (it != null && it.hasNext()) {
@@ -314,6 +315,7 @@ public class SOAPHandlerInterceptor exte
             SAAJ_OUT.handleFault(message);
         }
     }    
+
     protected QName getOpQName(Exchange ex, Object data) {
         SOAPMessageContextImpl sm = (SOAPMessageContextImpl)data;
         try {
@@ -321,7 +323,7 @@ public class SOAPHandlerInterceptor exte
             if (msg == null) {
                 return null;
             }
-            SOAPBody body = msg.getSOAPBody();
+            SOAPBody body = SAAJUtils.getBody(msg);
             if (body == null) {
                 return null;
             }

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerInvocationTest.java
Mon Mar 12 02:20:16 2012
@@ -84,6 +84,12 @@ public class HandlerInvocationTest exten
 
     @BeforeClass
     public static void startServers() throws Exception {
+        
+        //System.setProperty(SAAJFactoryResolver.MESSAGE_FACTORY_KEY, 
+        //                     "com.ibm.ws.webservices.engine.soap.MessageFactoryImpl");
+        //System.setProperty(SAAJFactoryResolver.SOAP_FACTORY_KEY, 
+        //    "com.ibm.ws.webservices.engine.xmlsoap.SOAPFactory");
+            
         assertTrue("server did not launch correctly", launchServer(Server.class, true));
     }
 
@@ -1183,7 +1189,7 @@ public class HandlerInvocationTest exten
         String[] handlerNames = {"soapHandler4", "soapHandler3", "handler2", "handler1",
"servant",
                                  "handler1", "handler2", "soapHandler3", "soapHandler4"};
 
-        List<String> resp = getHandlerNames(inMsg.getSOAPBody());
+        List<String> resp = getHandlerNames(inMsg.getSOAPPart().getEnvelope().getBody());
         assertEquals(handlerNames.length, resp.size());
 
         Iterator<String> iter = resp.iterator();

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java
Mon Mar 12 02:20:16 2012
@@ -34,6 +34,7 @@ import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.soap.SOAPFaultException;
 
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.handler_test.HandlerTest;
 import org.apache.handler_test.PingException;
@@ -94,7 +95,7 @@ public class HandlerTestImpl implements 
         try {
             SOAPFault fault = SOAPFactory.newInstance().createFault();
             fault.setFaultString(faultString);
-            fault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "Server"));
+            SAAJUtils.setFaultCode(fault, new QName("http://cxf.apache.org/faultcode", "Server"));
             return new SOAPFaultException(fault);
         } catch (SOAPException e) {
             // do nothing

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestHandler.java
Mon Mar 12 02:20:16 2012
@@ -41,6 +41,7 @@ import javax.xml.xpath.XPathConstants;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.helpers.XPathUtils;
@@ -224,7 +225,7 @@ public class TestHandler<T extends Logic
         try {
             SOAPFault fault = SOAPFactory.newInstance().createFault();
             fault.setFaultString(faultString);
-            fault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "Server"));
+            SAAJUtils.setFaultCode(fault, new QName("http://cxf.apache.org/faultcode", "Server"));
             return new SOAPFaultException(fault);
         } catch (SOAPException e) {
             // do nothing

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestMustUnderstandHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestMustUnderstandHandler.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestMustUnderstandHandler.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestMustUnderstandHandler.java
Mon Mar 12 02:20:16 2012
@@ -58,7 +58,9 @@ public class TestMustUnderstandHandler<T
                         header = envelope.addHeader();
                     }
 
-                    SOAPHeaderElement headerElement = header.addHeaderElement(qname);
+                    
+                    SOAPHeaderElement headerElement 
+                        = header.addHeaderElement(envelope.createName("MU", "ns1", qname.getNamespaceURI()));
 
                     // QName soapMustUnderstand = new QName("http://schemas.xmlsoap.org/soap/envelope/",
                     // "mustUnderstand");

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java?rev=1299524&r1=1299523&r2=1299524&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/handlers/TestSOAPHandler.java
Mon Mar 12 02:20:16 2012
@@ -19,6 +19,7 @@
 package org.apache.cxf.systest.handlers;
 
 
+import java.io.IOException;
 import java.util.Set;
 import java.util.StringTokenizer;
 
@@ -45,6 +46,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.saaj.SAAJUtils;
 
 //import org.apache.handler_test.PingException;
 
@@ -125,7 +127,7 @@ public class  TestSOAPHandler extends Te
                 if (outbound) {
                     try {
                         // append handler id to SOAP response message 
-                        SOAPBody body = msg.getSOAPBody(); 
+                        SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); 
                         Node resp = body.getFirstChild();
                         
                         if (resp.getNodeName().contains("pingResponse")) { 
@@ -162,11 +164,16 @@ public class  TestSOAPHandler extends Te
 
             try {
                 SOAPMessage msg = ctx.getMessage();
-                if ("soapHandler4HandleFaultThrowsRunException".equals(msg.getSOAPBody().getFault()
-                    .getFaultString())) {
+                try {
+                    msg.writeTo(System.out);
+                } catch (IOException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+                String fs = msg.getSOAPPart().getEnvelope().getBody().getFault().getFaultString();
+                if ("soapHandler4HandleFaultThrowsRunException".equals(fs)) {
                     throw new RuntimeException("soapHandler4 HandleFault throws RuntimeException");
-                } else if ("soapHandler4HandleFaultThrowsSOAPFaultException".equals(msg.getSOAPBody()
-                    .getFault().getFaultString())) {
+                } else if ("soapHandler4HandleFaultThrowsSOAPFaultException".equals(fs))
{
                     throw createSOAPFaultException("soapHandler4 HandleFault throws SOAPFaultException");
                 }
             } catch (SOAPException e) {
@@ -189,7 +196,7 @@ public class  TestSOAPHandler extends Te
         boolean ret = true;
         try {
             SOAPMessage msg  = ctx.getMessage(); 
-            SOAPBody body = msg.getSOAPBody();
+            SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
 
             if (body.getFirstChild().getFirstChild() == null) {
                 return true;
@@ -282,7 +289,7 @@ public class  TestSOAPHandler extends Te
     private SOAPFaultException createSOAPFaultException(String faultString) throws SOAPException
{
         SOAPFault fault = SOAPFactory.newInstance().createFault();
         fault.setFaultString(faultString);
-        fault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "Server"));
+        SAAJUtils.setFaultCode(fault, new QName("http://cxf.apache.org/faultcode", "Server"));
         return new SOAPFaultException(fault);
     }
     private SOAPFaultException createSOAPFaultExceptionWithDetail(String faultString) 
@@ -292,7 +299,7 @@ public class  TestSOAPHandler extends Te
 
         QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, 
                         "Server"); 
-        fault.setFaultCode(faultName); 
+        SAAJUtils.setFaultCode(fault, faultName); 
         fault.setFaultActor("http://gizmos.com/orders"); 
         fault.setFaultString(faultString); 
 



Mime
View raw message