You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2009/06/10 21:14:00 UTC

svn commit: r783456 - in /cxf/trunk: .gitignore rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java

Author: bimargulies
Date: Wed Jun 10 19:13:59 2009
New Revision: 783456

URL: http://svn.apache.org/viewvc?rev=783456&view=rev
Log:
Add .gitignore, try to get old-fashioned validation working.

Added:
    cxf/trunk/.gitignore
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java   (with props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java

Added: cxf/trunk/.gitignore
URL: http://svn.apache.org/viewvc/cxf/trunk/.gitignore?rev=783456&view=auto
==============================================================================
--- cxf/trunk/.gitignore (added)
+++ cxf/trunk/.gitignore Wed Jun 10 19:13:59 2009
@@ -0,0 +1,7 @@
+.checkstyle
+.classpath
+.pmd
+.project
+.ruleset
+.settings/
+target/

Added: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java?rev=783456&view=auto
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java (added)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/StartBodyInterceptor.java Wed Jun 10 19:13:59 2009
@@ -0,0 +1,70 @@
+/**
+ * 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.interceptor;
+
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+public class StartBodyInterceptor extends AbstractSoapInterceptor {
+    private static final Logger LOG = LogUtils.getL7dLogger(StartBodyInterceptor.class);
+    
+    public StartBodyInterceptor() {
+        super(Phase.READ);
+    }
+    
+    public StartBodyInterceptor(String phase) {
+        super(phase);
+    }
+
+    /** {@inheritDoc}*/
+    public void handleMessage(SoapMessage message) throws Fault {
+        if (isGET(message)) {
+            LOG.fine("ReadHeadersInterceptor skipped in HTTP GET method");
+            return;
+        }
+        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+        //advance to just outside the <soap:body> opening tag, but not 
+        //to the nextTag as that may skip over white space that is 
+        //important to keep for ws-security signature digests and stuff
+        try {
+            int i = xmlReader.next();
+            while (i == XMLStreamReader.NAMESPACE
+                || i == XMLStreamReader.ATTRIBUTE) {
+                i = xmlReader.next();
+            }
+        } catch (XMLStreamException e) {
+            throw new SoapFault(new Message("XML_STREAM_EXC", LOG), e, message.getVersion().getSender());
+        }
+
+    }
+
+}

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

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?rev=783456&r1=783455&r2=783456&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java Wed Jun 10 19:13:59 2009
@@ -27,6 +27,7 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
 
 import org.w3c.dom.Node;
 
@@ -46,6 +47,7 @@
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.service.model.ServiceModelUtil;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
 public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInterceptor<Message> {
     public static final String NO_VALIDATE_PARTS = AbstractInDatabindingInterceptor.class.getName() 
@@ -86,10 +88,10 @@
         }
         dataReader.setAttachments(message.getAttachments());
         dataReader.setProperty(DataReader.ENDPOINT, message.getExchange().get(Endpoint.class));
-
+        setSchemaInMessage(service, message, dataReader);   
         return dataReader;
     }
-
+    
     protected DataReader<XMLStreamReader> getDataReader(Message message) {
         return getDataReader(message, XMLStreamReader.class);
     }
@@ -98,6 +100,15 @@
         return getDataReader(message, Node.class);
     }
 
+    private void setSchemaInMessage(Service service, Message message, DataReader<?> reader) {
+        Object en = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+        if (Boolean.TRUE.equals(en) || "true".equals(en)) {
+            //all serviceInfos have the same schemas
+            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0));
+            reader.setSchema(schema);
+        }
+    }
+
     protected DepthXMLStreamReader getXMLStreamReader(Message message) {
         XMLStreamReader xr = message.getContent(XMLStreamReader.class);
         if (xr instanceof DepthXMLStreamReader) {