You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/02/19 21:52:01 UTC

svn commit: r1447915 - in /cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor: ReadHeadersInterceptor.java SoapHeaderInterceptor.java

Author: dkulp
Date: Tue Feb 19 20:52:00 2013
New Revision: 1447915

URL: http://svn.apache.org/r1447915
Log:
Merged revisions 1447902 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1447902 | dkulp | 2013-02-19 15:27:22 -0500 (Tue, 19 Feb 2013) | 10 lines

  Merged revisions 1447876 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1447876 | dkulp | 2013-02-19 14:16:55 -0500 (Tue, 19 Feb 2013) | 2 lines

    [CXF-4819] Don't actually remove the attributes as SoapHandlers or Provider<SOAPMessage> or similar may need/expect them.   Instead, ignore those attributes for the purpose of validation.

  ........

........

Modified:
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java

Modified: cxf/branches/2.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1447915&r1=1447914&r2=1447915&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java (original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java Tue Feb 19 20:52:00 2013
@@ -229,12 +229,8 @@ public class ReadHeadersInterceptor exte
                                                            dataBinding);
                         String mu = hel.getAttributeNS(soapVersion.getNamespace(),
                                                       soapVersion.getAttrNameMustUnderstand());
-                        hel.removeAttributeNS(soapVersion.getNamespace(),
-                                           soapVersion.getAttrNameMustUnderstand());
                         String act = hel.getAttributeNS(soapVersion.getNamespace(),
                                                         soapVersion.getAttrNameRole());
-                        hel.removeAttributeNS(soapVersion.getNamespace(),
-                                              soapVersion.getAttrNameRole());
 
                         if (!StringUtils.isEmpty(act)) {
                             shead.setActor(act);

Modified: cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java?rev=1447915&r1=1447914&r2=1447915&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java (original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java Tue Feb 19 20:52:00 2013
@@ -27,11 +27,14 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.validation.Schema;
+import javax.xml.validation.Validator;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -162,21 +165,38 @@ public class SoapHeaderInterceptor exten
         }
     }
 
-    private void validateHeader(SoapMessage message, MessagePartInfo mpi, Schema schema) {
+    private void validateHeader(final SoapMessage message, MessagePartInfo mpi, Schema schema) {
         Header param = findHeader(message, mpi);
-        Element el = null;
         if (param != null
             && param.getDataBinding() == null) {
             Node source = (Node)param.getObject();
-            if (source instanceof Element) {
-                el = (Element)source;
-            } else {
+            if (!(source instanceof Element)) {
                 return;
             }
             if (schema != null) {
+                final Element el = (Element)source;
                 DOMSource ds = new DOMSource(el);
                 try {
-                    schema.newValidator().validate(ds);
+                    Validator v = schema.newValidator();
+                    ErrorHandler errorHandler = new ErrorHandler() {
+                        public void warning(SAXParseException exception) throws SAXException {
+                        }
+                        public void error(SAXParseException exception) throws SAXException {
+                            String msg = exception.getMessage();
+                            if (msg.contains(el.getLocalName())
+                                && (msg.contains(":" + message.getVersion().getAttrNameRole())
+                                    || msg.contains(":" + message.getVersion().getAttrNameMustUnderstand()))) {
+                                return;
+                            }
+                            System.out.println("2");
+                            throw exception;
+                        }
+                        public void fatalError(SAXParseException exception) throws SAXException {
+                            throw exception;
+                        }
+                    };
+                    v.setErrorHandler(errorHandler);
+                    v.validate(ds);
                 } catch (SAXException e) {
                     throw new Fault("COULD_NOT_VALIDATE_SOAP_HEADER_CAUSED_BY", LOG, e, e.getClass()
                         .getCanonicalName(), e.getMessage());