cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r833107 - in /cxf/branches/2.2.x-fixes: ./ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/
Date Thu, 05 Nov 2009 18:08:34 GMT
Author: dkulp
Date: Thu Nov  5 18:08:34 2009
New Revision: 833107

URL: http://svn.apache.org/viewvc?rev=833107&view=rev
Log:
Merged revisions 833075 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r833075 | dkulp | 2009-11-05 11:30:39 -0500 (Thu, 05 Nov 2009) | 3 lines
  
  [CXF-1536] If schemavalidation is enabled, also check to make sure the
  soap body/envelope are properly closed so the structure of the soap
  message is correct as well.
........

Added:
    cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-no-endenv.xml
      - copied unchanged from r833075, cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-no-endenv.xml
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
    cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=833107&r1=833106&r2=833107&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Thu Nov  5 18:08:34 2009
@@ -50,12 +50,41 @@
 import org.apache.cxf.headers.HeaderManager;
 import org.apache.cxf.headers.HeaderProcessor;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
 
 
 public class ReadHeadersInterceptor extends AbstractSoapInterceptor {
+    /**
+     * 
+     */
+    public static class CheckClosingTagsInterceptor extends AbstractSoapInterceptor {
+        public CheckClosingTagsInterceptor() {
+            super(Phase.POST_LOGICAL);
+        }
+        
+        /** {@inheritDoc}*/
+        public void handleMessage(SoapMessage message) throws Fault {
+            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+            if (xmlReader != null) {
+                try {
+                    while (xmlReader.hasNext()) {
+                        if (xmlReader.next() == XMLStreamReader.END_DOCUMENT) {
+                            return;
+                        }
+                    }
+                } catch (XMLStreamException e) {
+                    throw new SoapFault(e.getMessage(), e, 
+                                        message.getVersion().getSender());
+                }
+            }
+        }
+
+    }
+
     private static final Logger LOG = LogUtils.getL7dLogger(ReadHeadersInterceptor.class);
 
     private Bus bus;
@@ -191,6 +220,11 @@
                     || i == XMLStreamReader.ATTRIBUTE) {
                     i = xmlReader.next();
                 }
+                if (MessageUtils.getContextualBoolean(message, 
+                                                      SoapMessage.SCHEMA_VALIDATION_ENABLED,
+                                                      false)) {
+                    message.getInterceptorChain().add(new CheckClosingTagsInterceptor());
+                }
             }
         } catch (XMLStreamException e) {
             throw new SoapFault(new Message("XML_STREAM_EXC", LOG), e, message.getVersion().getSender());

Modified: cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java?rev=833107&r1=833106&r2=833107&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
Thu Nov  5 18:08:34 2009
@@ -40,6 +40,9 @@
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.StaxInInterceptor;
 import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.staxutils.StaxUtils;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -75,6 +78,17 @@
     }
 
     @Test
+    public void testNoClosingEnvTage() throws Exception {
+        soapMessage = TestUtil.createEmptySoapMessage(Soap12.getInstance(), chain);
+        InputStream in = getClass().getResourceAsStream("test-no-endenv.xml");
+        assertNotNull(in);
+        soapMessage.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
+        soapMessage.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader(in));
+
+        soapMessage.getInterceptorChain().doIntercept(soapMessage);
+        assertNotNull(soapMessage.getContent(Exception.class));
+    }
+    @Test
     public void testHandleHeader() {
         try {
             prepareSoapMessage("test-soap-header.xml");

Modified: cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java?rev=833107&r1=833106&r2=833107&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/TestBase.java
Thu Nov  5 18:08:34 2009
@@ -69,7 +69,8 @@
         phases.add(phase2);
         phases.add(phase3);
         phases.add(phase4);
-        phases.add(new Phase(Phase.INVOKE, 5));
+        phases.add(new Phase(Phase.POST_LOGICAL, 5));
+        phases.add(new Phase(Phase.INVOKE, 6));
         chain = new PhaseInterceptorChain(phases);
 
         soapMessage = TestUtil.createEmptySoapMessage(Soap11.getInstance(), chain);



Mime
View raw message