You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by tl...@apache.org on 2006/11/20 06:44:09 UTC

svn commit: r477057 - in /incubator/cxf/trunk/rt/bindings/soap/src: main/java/org/apache/cxf/binding/soap/interceptor/ test/java/org/apache/cxf/binding/soap/ test/resources/org/apache/cxf/binding/soap/

Author: tli
Date: Sun Nov 19 21:44:08 2006
New Revision: 477057

URL: http://svn.apache.org/viewvc?view=rev&rev=477057
Log:
CXF-252 fix potencial bug by apply the modified patch

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
    incubator/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=477057&r1=477056&r2=477057
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java Sun Nov 19 21:44:08 2006
@@ -67,6 +67,9 @@
         }
 
         try {
+            while (xmlReader.isWhiteSpace()) { 
+                xmlReader.next(); 
+            } 
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
@@ -88,15 +91,13 @@
 
                     Element element = (Element)doc.getChildNodes().item(0);
                     message.setHeaders(Element.class, element);
-                    message.put(Element.class, element);                
+                    message.put(Element.class, element);                    
                 }
                 // advance just past body.
-                xmlReader.next();
-
-                while (xmlReader.isWhiteSpace()) {
-                    xmlReader.next();
-                }
-                
+                xmlReader.nextTag();
+                if (xmlReader.getName().equals(message.getVersion().getBody())) {
+                    xmlReader.nextTag();
+                }                    
                 if (message.getVersion().getFault().equals(xmlReader.getName())) {
                     Endpoint ep = message.getExchange().get(Endpoint.class);
                     if (ep != null) {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java?view=diff&rev=477057&r1=477056&r2=477057
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/ReadHeaderInterceptorTest.java Sun Nov 19 21:44:08 2006
@@ -26,6 +26,7 @@
 
 import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.stream.XMLStreamReader;
 
 import org.w3c.dom.Element;
 
@@ -57,6 +58,10 @@
 
         staxIntc.handleMessage(soapMessage);
         soapMessage.getInterceptorChain().doIntercept(soapMessage);
+        // check the xmlReader should be placed on the first entry of the body element
+        XMLStreamReader xmlReader = soapMessage.getContent(XMLStreamReader.class);
+        assertEquals("check the first entry of body", "itinerary", xmlReader.getLocalName());
+        
         Element eleHeaders = soapMessage.getHeaders(Element.class);
         List<Element> headerChilds = new ArrayList<Element>();
         for (int i = 0; i < eleHeaders.getChildNodes().getLength(); i++) {

Modified: incubator/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml?view=diff&rev=477057&r1=477056&r2=477057
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/test/resources/org/apache/cxf/binding/soap/test-soap-header.xml Sun Nov 19 21:44:08 2006
@@ -1,56 +1,56 @@
 <!--
-  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.
+    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.
 -->
-<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> 
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+    <!-- before header test for processing comment here -->
     <env:Header>
-	<m:reservation xmlns:m="http://travelcompany.example.org/reservation" 
-		       env:role="http://www.w3.org/2003/05/soap-envelope/role/next"
-		       env:mustUnderstand="true">
-	    <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
-	    <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
-	</m:reservation>
-	<n:passenger xmlns:n="http://mycompany.example.com/employees"
-		     env:role="http://www.w3.org/2003/05/soap-envelope/role/next"
-		     env:mustUnderstand="true">
-	    <n:name>Bob</n:name>
-	</n:passenger>
+        <!-- header test for processing comment here -->
+        <m:reservation xmlns:m="http://travelcompany.example.org/reservation"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
+            <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
+        </m:reservation>
+        <n:passenger xmlns:n="http://mycompany.example.com/employees"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
+            <n:name>Bob</n:name>
+        </n:passenger>
     </env:Header>
-    <env:Body>	
-	<p:itinerary
-	    xmlns:p="http://travelcompany.example.org/reservation/travel">
-	    <p:departure>
-		<p:departing>New York</p:departing>
-		<p:arriving>Los Angeles</p:arriving>
-		<p:departureDate>2001-12-14</p:departureDate>
-		<p:departureTime>late afternoon</p:departureTime>
-		<p:seatPreference>aisle</p:seatPreference>
-	    </p:departure>
-	    <p:return>
-		<p:departing>Los Angeles</p:departing>
-		<p:arriving>New York</p:arriving>
-		<p:departureDate>2001-12-20</p:departureDate>
-		<p:departureTime>mid-morning</p:departureTime>
-		<p:seatPreference/>
-	    </p:return>
-	</p:itinerary>
-	<q:lodging
-	    xmlns:q="http://travelcompany.example.org/reservation/hotels">
-	    <q:preference>none</q:preference>
-	</q:lodging>
+    <!-- before body test for processing comment here -->
+    <env:Body>
+        <!-- boyd test for processing comment here -->
+        <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel">
+            <p:departure>
+                <p:departing>New York</p:departing>
+                <p:arriving>Los Angeles</p:arriving>
+                <p:departureDate>2001-12-14</p:departureDate>
+                <p:departureTime>late afternoon</p:departureTime>
+                <p:seatPreference>aisle</p:seatPreference>
+            </p:departure>
+            <p:return>
+                <p:departing>Los Angeles</p:departing>
+                <p:arriving>New York</p:arriving>
+                <p:departureDate>2001-12-20</p:departureDate>
+                <p:departureTime>mid-morning</p:departureTime>
+                <p:seatPreference />
+            </p:return>
+        </p:itinerary>
+        <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels">
+            <q:preference>none</q:preference>
+        </q:lodging>
     </env:Body>
 </env:Envelope>