cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1513983 - in /cxf/branches/2.7.x-fixes: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ systests/jaxws/ systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ systests/jaxws/src/test/resources/wsdl_systest_jaxws/
Date Wed, 14 Aug 2013 18:04:07 GMT
Author: dkulp
Date: Wed Aug 14 18:04:07 2013
New Revision: 1513983

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

........
  r1513960 | dkulp | 2013-08-14 12:52:50 -0400 (Wed, 14 Aug 2013) | 3 lines

  [CXF-5194] Testcase for validating header elements
  Fix problem discovered of NOT validating outgoing headers.

........

Modified:
    cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    cxf/branches/2.7.x-fixes/systests/jaxws/pom.xml
    cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
    cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServicePortTypeImpl.java
    cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/request.xsd
    cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/schemaValidation.wsdl

Modified: cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.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/SoapOutInterceptor.java?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
Wed Aug 14 18:04:07 2013
@@ -27,10 +27,12 @@ import java.util.ResourceBundle;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
+import javax.xml.validation.Schema;
 
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -43,6 +45,7 @@ import org.apache.cxf.databinding.DataWr
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.headers.HeaderManager;
 import org.apache.cxf.headers.HeaderProcessor;
+import org.apache.cxf.helpers.ServiceUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.WriteOnCloseOutputStream;
 import org.apache.cxf.message.Exchange;
@@ -57,6 +60,7 @@ import org.apache.cxf.service.model.Mess
 import org.apache.cxf.service.model.ServiceModelUtil;
 import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
 
 public class SoapOutInterceptor extends AbstractSoapInterceptor {
     public static final String WROTE_ENVELOPE_START = "wrote.envelope.start";
@@ -264,9 +268,16 @@ public class SoapOutInterceptor extends 
                 .getName()));
         }
         dataWriter.setAttachments(message.getAttachments());
-
+        setDataWriterValidation(service, message, dataWriter);
         return dataWriter;
     }
+    private void setDataWriterValidation(Service service, Message message, DataWriter<?>
writer) {
+        if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) {
+            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
+                                                             message.getExchange().getBus());
+            writer.setSchema(schema);
+        }
+    }
         
     public class SoapOutEndingInterceptor extends AbstractSoapInterceptor {
         public SoapOutEndingInterceptor() {

Modified: cxf/branches/2.7.x-fixes/systests/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxws/pom.xml?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxws/pom.xml (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxws/pom.xml Wed Aug 14 18:04:07 2013
@@ -47,6 +47,7 @@
                             <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
                             <testWsdlRoot>${basedir}/src/test/resources/wsdl_systest_jaxws</testWsdlRoot>
                             <defaultOptions>
+                                <extendedSoapHeaders>true</extendedSoapHeaders>
                                 <validate>basic</validate>
                             </defaultOptions>
                         </configuration>

Modified: cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/SchemaValidationClientServerTest.java
Wed Aug 14 18:04:07 2013
@@ -32,12 +32,14 @@ import org.apache.cxf.interceptor.Loggin
 import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.schemavalidation.CkRequestType;
 import org.apache.cxf.jaxws.schemavalidation.CkResponseType;
+import org.apache.cxf.jaxws.schemavalidation.RequestHeader;
 import org.apache.cxf.jaxws.schemavalidation.RequestIdType;
 import org.apache.cxf.jaxws.schemavalidation.Service;
 import org.apache.cxf.jaxws.schemavalidation.ServicePortType;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -101,19 +103,48 @@ public class SchemaValidationClientServe
         CkRequestType request = new CkRequestType();
         request.setRequest(requestId);
         ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
Boolean.TRUE);
-        CkResponseType response = greeter.ckR(request); 
+        RequestHeader header = new RequestHeader();
+        header.setHeaderValue("AABBCC");
+        CkResponseType response = greeter.ckR(request, header); 
         assertEquals(response.getProduct().get(0).getAction().getStatus(), 4);
         
         try {
             requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeez");
             request.setRequest(requestId);
-            greeter.ckR(request);
+            greeter.ckR(request, header);
             fail("should catch marshall exception as the invalid outgoing message per schema");
         } catch (Exception e) {
             assertTrue(e.getMessage().contains("Marshalling Error"));
             assertTrue(e.getMessage().contains("is not facet-valid with respect to pattern"));
         }
+
+        try {
+            requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
+            request.setRequest(requestId);
+            header.setHeaderValue("AABBCCDDEEFFGGHHIIJJ");
+            
+            //Check if incoming validation on server side works, turn off outgoing
+            greeter.ckR(request, header);
+            fail("should catch marshall exception as the invalid outgoing message per schema");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Marshalling Error"));
+            assertTrue(e.getMessage().contains("is not facet-valid with respect to maxLength"));
+        }
+        
+        try {
+            requestId.setId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
+            request.setRequest(requestId);
+            header.setHeaderValue("AABBCCDDEEFFGGHHIIJJ");
             
+            //Check if incoming validation on server side works, turn off outgoing
+            ((BindingProvider)greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED,
Boolean.FALSE);
+            greeter.ckR(request, header);
+            fail("should catch marshall exception as the invalid outgoing message per schema");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Could not validate soapheader "));
+            assertTrue(e.getMessage().contains("is not facet-valid with respect to maxLength"));
+        }
+        
     }
     
 }

Modified: cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServicePortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServicePortTypeImpl.java?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServicePortTypeImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServicePortTypeImpl.java
Wed Aug 14 18:04:07 2013
@@ -22,12 +22,13 @@ import org.apache.cxf.jaxws.schemavalida
 import org.apache.cxf.jaxws.schemavalidation.CkRequestType;
 import org.apache.cxf.jaxws.schemavalidation.CkResponseType;
 import org.apache.cxf.jaxws.schemavalidation.ProductPostActionType;
+import org.apache.cxf.jaxws.schemavalidation.RequestHeader;
 import org.apache.cxf.jaxws.schemavalidation.ServicePortType;
 
 @javax.xml.ws.BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/")
 public class ServicePortTypeImpl implements ServicePortType {
     
-    public CkResponseType ckR(CkRequestType ckRIn) {
+    public CkResponseType ckR(CkRequestType ckRIn, RequestHeader header) {
         CkResponseType result = new CkResponseType();
         ActionCheckMajType action = new ActionCheckMajType();
         action.setStatus(4);
@@ -36,4 +37,5 @@ public class ServicePortTypeImpl impleme
         result.getProduct().add(pdt);
         return result;
     }
+
 }

Modified: cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/request.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/request.xsd?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/request.xsd
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/request.xsd
Wed Aug 14 18:04:07 2013
@@ -38,4 +38,17 @@
 			</xsd:element>
 		</xsd:sequence>
 	</xsd:complexType>
+    
+    <xsd:element name="RequestHeaderElement" type="RequestHeader"/>
+    <xsd:complexType name="RequestHeader">
+      <xsd:sequence>
+        <xsd:element name="HeaderValue">
+            <xsd:simpleType>
+                <xsd:restriction base="xsd:string">
+                    <xsd:maxLength value="10" />
+                </xsd:restriction>
+            </xsd:simpleType>
+        </xsd:element>
+      </xsd:sequence>
+    </xsd:complexType>    
 </xsd:schema>

Modified: cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/schemaValidation.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/schemaValidation.wsdl?rev=1513983&r1=1513982&r2=1513983&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/schemaValidation.wsdl
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/wsdl_systest_jaxws/schemaValidation.wsdl
Wed Aug 14 18:04:07 2013
@@ -27,6 +27,9 @@
 	
 	<wsdl:message name="ckRIn">
 		<wsdl:part name="ckRIn" element="tns:ckRequest"/>
+    </wsdl:message>
+    <wsdl:message name="ckRInHeader">
+        <wsdl:part name="header" element="tns:RequestHeaderElement"/>
 	</wsdl:message>
 	<wsdl:message name="ckROut">
 		<wsdl:part name="ckROut" element="tns:ckResponse"/>
@@ -45,6 +48,7 @@
 		<wsdl:operation name="ckR">
 		   <wsoap12:operation soapAction="ckR"/>
 		   <wsdl:input>
+                <wsoap12:header message="tns:ckRInHeader" part="header" use="literal"/>
 				<wsoap12:body parts="ckRIn" use="literal"/>
             </wsdl:input>
             <wsdl:output>



Mime
View raw message