cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1446732 - in /cxf/branches/2.7.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/ systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_...
Date Fri, 15 Feb 2013 19:20:25 GMT
Author: dkulp
Date: Fri Feb 15 19:20:25 2013
New Revision: 1446732

URL: http://svn.apache.org/r1446732
Log:
Merged revisions 1446731 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1446731 | dkulp | 2013-02-15 14:18:28 -0500 (Fri, 15 Feb 2013) | 3 lines

  [CXF-4819] Remove the soap specific attributes from the header elements so that validation
can occur.
  Recheck the operation defined headers for ultimate reciever processing after the bindingoperationinfo
is known.

........

Modified:
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
    cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
    cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
    cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ProtocolVariationsTest.java
    cxf/branches/2.7.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
Fri Feb 15 19:20:25 2013
@@ -47,7 +47,7 @@ import org.apache.cxf.interceptor.OneWay
 import org.apache.cxf.phase.Phase;
 
 public class MustUnderstandInterceptor extends AbstractSoapInterceptor {
-    public static final String FAULT = "MustUnderstand.Fault";
+    public static final String UNKNOWNS = "MustUnderstand.UNKNOWNS";
 
     private static final Logger LOG = LogUtils.getL7dLogger(MustUnderstandInterceptor.class);
 
@@ -83,35 +83,25 @@ public class MustUnderstandInterceptor e
         checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames, notUnderstandHeaders);
         
         if (!notUnderstandHeaders.isEmpty()) {
-            SoapFault soapFault = new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders),
-                                                soapVersion.getMustUnderstand());
             if (!isRequestor(soapMessage)) {
-                soapMessage.put(MustUnderstandInterceptor.FAULT, soapFault);
+                soapMessage.put(MustUnderstandInterceptor.UNKNOWNS, notUnderstandHeaders);
                 soapMessage.getInterceptorChain().add(ending);
             } else {
-                throw soapFault;
+                throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, notUnderstandHeaders),
+                                                    soapVersion.getMustUnderstand());
             }
         }
         if (!ultimateReceiverHeaders.isEmpty() && !isRequestor(soapMessage)) {
             checkUltimateReceiverHeaders(ultimateReceiverHeaders, mustUnderstandQNames, soapMessage);
         }
     }
-    public void handleFault(SoapMessage message) {
-        SoapFault soapFault = (SoapFault)message.get(MustUnderstandInterceptor.FAULT);
-        if (soapFault != null
-            && !message.getExchange().isOneWay()
-            && soapFault != message.getContent(Exception.class)) {
-            
-            message.setContent(Exception.class, soapFault);
-        }
-    }
-
 
     private void checkUltimateReceiverHeaders(Set<Header> ultimateReceiverHeaders,
                                               Set<QName> mustUnderstandQNames, 
                                               SoapMessage soapMessage) {
         soapMessage.getInterceptorChain()
             .add(new UltimateReceiverMustUnderstandInterceptor(mustUnderstandQNames));
+
         Object o = soapMessage.getContextualProperty("endpoint-processes-headers");
         if (o == null) {
             o = Collections.EMPTY_LIST;
@@ -147,9 +137,7 @@ public class MustUnderstandInterceptor e
             if (!notFound.isEmpty()) {
                 // Defer throwing soap fault exception in SOAPHeaderInterceptor once the
isOneway can
                 // be detected
-                SoapFault soapFault = new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE,
notFound),
-                                                    soapMessage.getVersion().getMustUnderstand());
-                soapMessage.put(MustUnderstandInterceptor.FAULT, soapFault);
+                soapMessage.put(MustUnderstandInterceptor.UNKNOWNS, notFound);
                 soapMessage.getInterceptorChain().add(ending);
             }
         }
@@ -267,9 +255,20 @@ public class MustUnderstandInterceptor e
         
         public void handleMessage(SoapMessage message) throws Fault {
             // throws soapFault after the response code 202 is set in OneWayProcessorInterceptor
-            if (message.get(MustUnderstandInterceptor.FAULT) != null) {
-                SoapFault soapFault = (SoapFault)message.get(MustUnderstandInterceptor.FAULT);
-                throw soapFault;
+            if (message.get(MustUnderstandInterceptor.UNKNOWNS) != null) {
+                //we may not have known the Operation in the main interceptor and thus may
not 
+                //have been able to get the parameter based headers.   We now know the
+                //operation and thus can remove those.
+                Set<QName> unknowns = CastUtils.cast((Set<?>)message.get(MustUnderstandInterceptor.UNKNOWNS));
+                Set<QName> paramHeaders = HeaderUtil.getHeaderQNameInOperationParam(message);
+                unknowns.removeAll(paramHeaders);
+                
+                if (!unknowns.isEmpty()) {
+                    throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE, unknowns),
+                                        message.getVersion().getMustUnderstand());
+                } else {
+                    message.remove(MustUnderstandInterceptor.UNKNOWNS);
+                }
             }
         }
     }

Modified: cxf/branches/2.7.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.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Fri Feb 15 19:20:25 2013
@@ -229,8 +229,12 @@ 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.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/MustUnderstandInterceptorTest.java
Fri Feb 15 19:20:25 2013
@@ -37,6 +37,7 @@ import org.apache.cxf.binding.soap.inter
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
 import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -99,12 +100,11 @@ public class MustUnderstandInterceptorTe
         assertEquals("DummaySoapInterceptor getUnderstood has been called!", true, dsi
             .isCalledGetUnderstood());
 
-        SoapFault ie = (SoapFault)soapMessage.get(MustUnderstandInterceptor.FAULT);
+        Set<QName> ie = CastUtils.cast((Set<?>)soapMessage.get(MustUnderstandInterceptor.UNKNOWNS));
         if (ie == null) {
-            fail("InBound Exception Missing! Exception should be Can't understands QNames:
" + PASSENGER);
+            fail("InBound unknowns missing! Exception should be Can't understands QNames:
" + PASSENGER);
         } else {
-            assertEquals(soapMessage.getVersion().getMustUnderstand(), ie.getFaultCode());
-            assertTrue(ie.getMessage().toString().contains(PASSENGER.toString()));
+            assertTrue(ie.contains(PASSENGER));
         }
     }
 

Modified: cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
Fri Feb 15 19:20:25 2013
@@ -27,8 +27,11 @@ import javax.jws.WebService;
 import org.apache.schema_validation.SchemaValidation;
 import org.apache.schema_validation.types.ComplexStruct;
 import org.apache.schema_validation.types.OccuringStruct;
+import org.apache.schema_validation.types.SomeHeader;
 import org.apache.schema_validation.types.SomeRequest;
+import org.apache.schema_validation.types.SomeRequestWithHeader;
 import org.apache.schema_validation.types.SomeResponse;
+import org.apache.schema_validation.types.SomeResponseWithHeader;
 
 @WebService(serviceName = "SchemaValidationService", 
             portName = "SoapPort",
@@ -77,4 +80,11 @@ public class SchemaValidationImpl implem
         
         return response;
     }
+
+
+    public SomeResponseWithHeader doSomethingWithHeader(SomeRequestWithHeader in,
+                                                        SomeHeader inHeader) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

Modified: cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
Fri Feb 15 19:20:25 2013
@@ -20,11 +20,16 @@
 package org.apache.cxf.systest.schema_validation;
 
 import java.io.Serializable;
+import java.io.StringReader;
 import java.net.URL;
 import java.util.List;
 
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service.Mode;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
@@ -179,6 +184,24 @@ public class ValidationClientServerTest 
         assertIgnoredResponseValidation(SchemaValidationType.OUT.name());
     }
 
+    @Test
+    public void testHeaderValidation() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
+        assertNotNull(wsdl);
+        SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
+        assertNotNull(service);
+
+        
+        String smsg = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Header>"
+            + "<SomeHeader soap:mustUnderstand='1' xmlns='http://apache.org/schema_validation/types'>"
+            + "<id>1111111111</id></SomeHeader>"
+            + "</soap:Header><soap:Body><SomeRequestWithHeader xmlns='http://apache.org/schema_validation/types'>"
+            + "<id>1111111111</id></SomeRequestWithHeader></soap:Body></soap:Envelope>";
+        Dispatch<Source> dsp = service.createDispatch(SchemaValidationService.SoapPort,
Source.class, Mode.MESSAGE);
+        updateAddressPort(dsp, PORT);
+        dsp.invoke(new StreamSource(new StringReader(smsg)));
+    }
+    
     private SomeResponse execute(SchemaValidation service, String id) throws Exception {

         SomeRequest request = new SomeRequest();
         request.setId(id);

Modified: cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ProtocolVariationsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ProtocolVariationsTest.java?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ProtocolVariationsTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ProtocolVariationsTest.java
Fri Feb 15 19:20:25 2013
@@ -287,12 +287,8 @@ public class ProtocolVariationsTest exte
             fail("invalid wsrm header");
         } catch (Exception e) {
             assertTrue(e.getCause() instanceof SoapFault);
-            // verify a partial error text match to exclude an unexpected exception
-            // because there is a mustUnderstand header that is not understood,
-            // the corresponding error is returned.
-            final String text = "MustUnderstand headers: " 
-                                + "[{http://cxf.apache.org/invalid}Sequence] are not understood.";
-            assertTrue(e.getCause().getMessage() != null 
+            final String text = "WS-ReliableMessaging is required";
+            assertTrue(e.getCause().getMessage(), e.getCause().getMessage() != null 
                 && e.getCause().getMessage().indexOf(text) >= 0);
         }
     }

Modified: cxf/branches/2.7.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl?rev=1446732&r1=1446731&r2=1446732&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl (original)
+++ cxf/branches/2.7.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl Fri
Feb 15 19:20:25 2013
@@ -56,7 +56,30 @@
 	            	</sequence>
     	        </complexType>
 	    	</element>
+            <element name="SomeRequestWithHeader">
+                <complexType>
+                    <sequence>
+                        <element name="id" type="x1:RequestIdType"/>
+                    </sequence>
+                </complexType>
+            </element>
+                        
+            <element name="SomeResponseWithHeader">
+                <complexType>
+                    <sequence>
+                        <element name="transactionId" type="x1:ResponseTransactionType"/>
+                    </sequence>
+                </complexType>
+            </element>   
+            <element name="SomeHeader">
+                <complexType>
+                    <sequence>
+                        <element name="id" type="x1:RequestIdType"/>
+                    </sequence>
+                </complexType>
+            </element>
             
+
             <complexType name="ComplexStruct">
                 <sequence>
                     <element name="elem1" type="string"/>
@@ -137,6 +160,14 @@
         <wsdl:part element="x1:SomeResponse" name="in"/>
     </wsdl:message>
     
+    <wsdl:message name="doSomethingRequestWithHeader">
+        <wsdl:part element="x1:SomeRequestWithHeader" name="in"/>
+        <wsdl:part element="x1:SomeHeader" name="inHeader"/>
+    </wsdl:message>
+    <wsdl:message name="doSomethingResponseWithHeader">
+        <wsdl:part element="x1:SomeResponseWithHeader" name="in"/>
+    </wsdl:message>
+
     <wsdl:message name="setComplexStructRequest">
         <wsdl:part element="x1:setComplexStruct" name="in"/>
     </wsdl:message>
@@ -188,6 +219,10 @@
             <wsdl:input message="tns:getOccuringStructRequest" name="getOccuringStructRequest"/>
             <wsdl:output message="tns:getOccuringStructResponse" name="getOccuringStructResponse"/>
         </wsdl:operation>
+        <wsdl:operation name="doSomethingWithHeader">
+            <wsdl:input message="tns:doSomethingRequestWithHeader" name="doSomethingRequestWithHeader"/>
+            <wsdl:output message="tns:doSomethingResponseWithHeader" name="doSomethingResponseWithHeader"/>
+        </wsdl:operation>
     </wsdl:portType>
 
     <wsdl:binding name="SchemaValidationBinding" type="tns:SchemaValidation">
@@ -202,6 +237,16 @@
                 <soap:body use="literal"/>
             </wsdl:output>
         </wsdl:operation>
+        <wsdl:operation name="doSomethingWithHeader">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:header message="tns:doSomethingRequestWithHeader" part="inHeader"
use="literal"/>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
         
         <wsdl:operation name="setComplexStruct">
             <soap:operation style="document"/>



Mime
View raw message