cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r542943 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
Date Wed, 30 May 2007 21:46:35 GMT
Author: gawor
Date: Wed May 30 14:46:34 2007
New Revision: 542943

URL: http://svn.apache.org/viewvc?view=rev&rev=542943
Log:
replace headers as soap handlers could have changed the soap message

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java

Modified: 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=diff&rev=542943&r1=542942&r2=542943
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Wed May 30 14:46:34 2007
@@ -28,6 +28,7 @@
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
 import javax.xml.stream.XMLStreamException;
@@ -95,44 +96,7 @@
             
             //replace header element if necessary
             if (message.hasHeaders()) {
-                NodeList headerEls = soapMessage.getSOAPHeader().getChildNodes();
-                int len = headerEls.getLength();
-                for (int i = 0; i < len; i++) {
-                    Node nd = headerEls.item(i);
-                    if (Node.ELEMENT_NODE == nd.getNodeType()) {
-                        Element hel = (Element)nd;
-                        HeaderProcessor p = BusFactory.getDefaultBus().getExtension(HeaderManager.class)
-                            .getHeaderProcessor(hel.getNamespaceURI());
-
-                        Object obj;
-                        DataBinding dataBinding = null;
-                        if (p == null || p.getDataBinding() == null) {
-                            obj = nd;
-                        } else {
-                            obj = p.getDataBinding().createReader(Node.class).read(nd);
-                        }
-                        //TODO - add the interceptors
-                        
-                        SoapHeader shead = new SoapHeader(new QName(nd.getNamespaceURI(),
-                                nd.getLocalName()),
-                                                           obj,
-                                                           dataBinding);
-                        String mu = hel.getAttributeNS(message.getVersion().getNamespace(),
-                                message.getVersion().getAttrNameMustUnderstand());
-                        String act = hel.getAttributeNS(message.getVersion().getNamespace(),
-                                message.getVersion().getAttrNameRole());
-                        
-                        shead.setActor(act);
-                        shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
-                        Header oldHdr = message.getHeader(
-                                new QName(nd.getNamespaceURI(), nd.getLocalName()));
-                        if (oldHdr != null) {
-                            message.getHeaders().remove(oldHdr);
-                        } 
-                        message.getHeaders().add(shead);
-                        
-                    }
-                }
+                replaceHeaders(soapMessage, message);
             }
             
             XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
@@ -150,6 +114,50 @@
             throw new SoapFault(new org.apache.cxf.common.i18n.Message(
                     "SOAPHANDLERINTERCEPTOR_EXCEPTION", BUNDLE), e, message
                     .getVersion().getSender());
+        }
+    }
+
+    public static void replaceHeaders(SOAPMessage soapMessage, SoapMessage message) throws
SOAPException {
+        SOAPHeader header = soapMessage.getSOAPHeader();
+        if (header == null) {
+            return;
+        }
+        NodeList headerEls = header.getChildNodes();
+        int len = headerEls.getLength();
+        for (int i = 0; i < len; i++) {
+            Node nd = headerEls.item(i);
+            if (Node.ELEMENT_NODE == nd.getNodeType()) {
+                Element hel = (Element)nd;
+                HeaderProcessor p = BusFactory.getDefaultBus().getExtension(HeaderManager.class)
+                    .getHeaderProcessor(hel.getNamespaceURI());
+
+                Object obj;
+                DataBinding dataBinding = null;
+                if (p == null || p.getDataBinding() == null) {
+                    obj = nd;
+                } else {
+                    obj = p.getDataBinding().createReader(Node.class).read(nd);
+                }
+                //TODO - add the interceptors
+                
+                SoapHeader shead = new SoapHeader(new QName(nd.getNamespaceURI(),
+                        nd.getLocalName()),
+                                                   obj,
+                                                   dataBinding);
+                String mu = hel.getAttributeNS(message.getVersion().getNamespace(),
+                        message.getVersion().getAttrNameMustUnderstand());
+                String act = hel.getAttributeNS(message.getVersion().getNamespace(),
+                        message.getVersion().getAttrNameRole());
+                
+                shead.setActor(act);
+                shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
+                Header oldHdr = message.getHeader(
+                        new QName(nd.getNamespaceURI(), nd.getLocalName()));
+                if (oldHdr != null) {
+                    message.getHeaders().remove(oldHdr);
+                } 
+                message.getHeaders().add(shead);                        
+            }
         }
     }
 

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=542943&r1=542942&r2=542943
==============================================================================
--- 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
Wed May 30 14:46:34 2007
@@ -40,6 +40,7 @@
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapActionInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
@@ -116,7 +117,13 @@
             SOAPMessage msg = message.getContent(SOAPMessage.class);
             if (msg != null) {
                 XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(msg);
-                message.setContent(XMLStreamReader.class, xmlReader);
+                message.setContent(XMLStreamReader.class, xmlReader);   
+                // replace headers
+                try {
+                    SAAJInInterceptor.replaceHeaders(msg, message);
+                } catch (SOAPException e) {
+                    e.printStackTrace();
+                }                
             }
         }
     }



Mime
View raw message