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 2012/10/01 21:17:31 UTC
svn commit: r1392529 - in /cxf/branches/2.6.x-fixes:
api/src/main/java/org/apache/cxf/annotations/
api/src/main/java/org/apache/cxf/helpers/
api/src/main/java/org/apache/cxf/interceptor/
api/src/test/java/org/apache/cxf/helpers/ rt/core/src/main/java/o...
Author: dkulp
Date: Mon Oct 1 19:17:30 2012
New Revision: 1392529
URL: http://svn.apache.org/viewvc?rev=1392529&view=rev
Log:
Merged revisions 1392527 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1392527 | dkulp | 2012-10-01 15:16:18 -0400 (Mon, 01 Oct 2012) | 3 lines
[CXF-3813] Ability to validate just incoming or outgoing requests
Slightly modified patch from Jason Pell applied
........
Modified:
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
cxf/branches/2.6.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/annotations/SchemaValidation.java Mon Oct 1 19:17:30 2012
@@ -32,6 +32,13 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface SchemaValidation {
+ public enum SchemaValidationType {
+ IN, OUT, BOTH, NONE
+ }
+
+ @Deprecated
boolean enabled() default true;
+
+ SchemaValidationType type() default SchemaValidationType.BOTH;
}
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/helpers/ServiceUtils.java Mon Oct 1 19:17:30 2012
@@ -26,11 +26,40 @@ import java.util.StringTokenizer;
import javax.xml.namespace.QName;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.message.Message;
+
public final class ServiceUtils {
private ServiceUtils() {
}
-
+
+ /**
+ * Determines the appropriate SchemaValidationType to return based on either
+ * a Boolean (for backwards compatibility) or the selected Schema Validation Type.
+ *
+ * @param message
+ * @return
+ */
+ public static SchemaValidationType getSchemaValidationType(Message message) {
+ Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+ if (obj instanceof SchemaValidationType) {
+ return (SchemaValidationType)obj;
+ } else if (obj != null) {
+ String value = obj.toString().toUpperCase(); // handle boolean values as well
+ if ("TRUE".equals(value)) {
+ return SchemaValidationType.BOTH;
+ } else if ("FALSE".equals(value)) {
+ return SchemaValidationType.NONE;
+ } else if (value.length() > 0) {
+ return SchemaValidationType.valueOf(value);
+ }
+ }
+
+ // fall through default value
+ return SchemaValidationType.NONE;
+ }
+
/**
* Generates a suitable service name from a given class. The returned name
* is the simple name of the class, i.e. without the package name.
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java Mon Oct 1 19:17:30 2012
@@ -31,12 +31,13 @@ import javax.xml.validation.Schema;
import org.w3c.dom.Node;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.databinding.DataReader;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingMessageInfo;
@@ -103,7 +104,8 @@ public abstract class AbstractInDatabind
}
private void setSchemaInMessage(Service service, Message message, DataReader<?> reader) {
- if (MessageUtils.getContextualBoolean(message, Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE)) {
+ SchemaValidationType type = ServiceUtils.getSchemaValidationType(message);
+ if (type.equals(SchemaValidationType.BOTH) || type.equals(SchemaValidationType.IN)) {
//all serviceInfos have the same schemas
Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
message.getExchange().getBus());
Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java Mon Oct 1 19:17:30 2012
@@ -29,7 +29,9 @@ import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.XMLEvent;
import javax.xml.validation.Schema;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
@@ -133,8 +135,8 @@ public abstract class AbstractOutDatabin
protected boolean shouldValidate(Message m) {
- Object en = m.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
- return Boolean.TRUE.equals(en) || "true".equals(en);
+ SchemaValidationType type = ServiceUtils.getSchemaValidationType(m);
+ return type.equals(SchemaValidationType.BOTH) || type.equals(SchemaValidationType.OUT);
}
protected boolean writeToOutputStream(Message m, BindingInfo info, Service s) {
Modified: cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java Mon Oct 1 19:17:30 2012
@@ -20,13 +20,82 @@
package org.apache.cxf.helpers;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.message.Message;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
public class ServiceUtilsTest {
+ private IMocksControl control;
+ private Message msg;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ msg = control.createMock(Message.class);
+ }
+
@Test
public void testmakeNamespaceFromClassName() throws Exception {
String tns = ServiceUtils.makeNamespaceFromClassName("com.example.ws.Test", "http");
Assert.assertEquals("http://ws.example.com/", tns);
}
+
+ @Test
+ public void testGetSchemaValidationTypeBoolean() {
+ setupSchemaValidationValue(null);
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("");
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue(Boolean.FALSE);
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("false");
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("FALSE");
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("fAlse");
+ Assert.assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue(Boolean.TRUE);
+ Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("true");
+ Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("TRUE");
+ Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue("tRue");
+ Assert.assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
+ }
+
+ @Test
+ public void testGetSchemaValidationType() {
+ for (SchemaValidationType type : SchemaValidationType.values()) {
+ setupSchemaValidationValue(type.name());
+ Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue(type.name().toLowerCase());
+ Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+
+ setupSchemaValidationValue(StringUtils.capitalize(type.name()));
+ Assert.assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
+ }
+ }
+
+ private void setupSchemaValidationValue(Object value) {
+ control.reset();
+ msg.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+ EasyMock.expectLastCall().andReturn(value);
+ control.replay();
+ }
}
Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java (original)
+++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java Mon Oct 1 19:17:30 2012
@@ -32,6 +32,7 @@ import org.apache.cxf.annotations.FastIn
import org.apache.cxf.annotations.GZIP;
import org.apache.cxf.annotations.Logging;
import org.apache.cxf.annotations.SchemaValidation;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.annotations.WSDLDocumentation;
import org.apache.cxf.annotations.WSDLDocumentation.Placement;
import org.apache.cxf.annotations.WSDLDocumentationCollection;
@@ -255,9 +256,20 @@ public class AnnotationsFactoryBeanListe
}
}
+ /**
+ * @param endpoint
+ * @param annotation
+ */
+ @SuppressWarnings("deprecation")
private void addSchemaValidationSupport(Endpoint endpoint, SchemaValidation annotation) {
if (annotation != null) {
- endpoint.put(Message.SCHEMA_VALIDATION_ENABLED, annotation.enabled());
+ // if someone has gone to the effort of specifying enabled=false, then we need to
+ // handle that, otherwise we use the new SchemaValidationType type only
+ if (!annotation.enabled()) {
+ endpoint.put(Message.SCHEMA_VALIDATION_ENABLED, SchemaValidationType.NONE);
+ } else {
+ endpoint.put(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+ }
}
}
Modified: cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java (original)
+++ cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/SchemaValidationImpl.java Mon Oct 1 19:17:30 2012
@@ -27,6 +27,8 @@ 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.SomeRequest;
+import org.apache.schema_validation.types.SomeResponse;
@WebService(serviceName = "SchemaValidationService",
portName = "SoapPort",
@@ -64,4 +66,15 @@ public class SchemaValidationImpl implem
return occuringStruct;
}
+ @Override
+ public SomeResponse doSomething(SomeRequest in) {
+ SomeResponse response = new SomeResponse();
+ if (in.getId().equals("1234567890")) {
+ response.setTransactionId("aaaaaaaaaaxxx"); // invalid transaction id
+ } else {
+ response.setTransactionId("aaaaaaaaaa");
+ }
+
+ return response;
+ }
}
Modified: cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java (original)
+++ cxf/branches/2.6.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/schema_validation/ValidationClientServerTest.java Mon Oct 1 19:17:30 2012
@@ -27,12 +27,15 @@ import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.WebServiceException;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.message.Message;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.schema_validation.SchemaValidation;
import org.apache.schema_validation.SchemaValidationService;
import org.apache.schema_validation.types.ComplexStruct;
import org.apache.schema_validation.types.OccuringStruct;
+import org.apache.schema_validation.types.SomeRequest;
+import org.apache.schema_validation.types.SomeResponse;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -54,17 +57,7 @@ public class ValidationClientServerTest
// Only tests client side validation enabled/server side disabled.
@Test
public void testSchemaValidation() throws Exception {
- URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
- assertNotNull(wsdl);
-
- SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
- assertNotNull(service);
-
- SchemaValidation validation = service.getPort(portName, SchemaValidation.class);
- updateAddressPort(validation, PORT);
- ((BindingProvider)validation).getRequestContext()
- .put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
-
+ SchemaValidation validation = createService(Boolean.TRUE);
ComplexStruct complexStruct = new ComplexStruct();
complexStruct.setElem1("one");
// Don't initialize a member of the structure.
@@ -95,8 +88,8 @@ public class ValidationClientServerTest
String expected = "'{\"http://apache.org/schema_validation/types\":varFloat}' is expected.";
assertTrue(e.getMessage().indexOf(expected) != -1);
}
- ((BindingProvider)validation).getRequestContext()
- .put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
+
+ validation = createService(Boolean.FALSE);
try {
// The server will attempt to return an invalid ComplexStruct
@@ -111,8 +104,8 @@ public class ValidationClientServerTest
e.getMessage().indexOf(expected) != -1);
}
- ((BindingProvider)validation).getRequestContext()
- .put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
+ validation = createService(Boolean.TRUE);
+
try {
// The server will attempt to return an invalid OccuringStruct
// When validation is disabled on the server side, we'll get the
@@ -126,4 +119,130 @@ public class ValidationClientServerTest
}
}
+ @Test
+ public void testRequestFailedSchemaValidation() throws Exception {
+ assertFailedRequestValidation(Boolean.TRUE);
+ }
+
+ @Test
+ public void testFailedRequestSchemaValidationTypeBoth() throws Exception {
+ assertFailedRequestValidation(SchemaValidationType.BOTH.name());
+ }
+
+ @Test
+ public void testFailedSchemaValidationSchemaValidationTypeOut() throws Exception {
+ assertFailedRequestValidation(SchemaValidationType.OUT.name());
+ }
+
+ @Test
+ public void testIgnoreRequestSchemaValidationNone() throws Exception {
+ assertIgnoredRequestValidation(SchemaValidationType.NONE.name());
+ }
+
+ @Test
+ public void testIgnoreRequestSchemaValidationResponseOnly() throws Exception {
+ assertIgnoredRequestValidation(SchemaValidationType.IN.name());
+ }
+
+ @Test
+ public void testIgnoreRequestSchemaValidationFalse() throws Exception {
+ assertIgnoredRequestValidation(Boolean.FALSE);
+ }
+
+ @Test
+ public void testResponseFailedSchemaValidation() throws Exception {
+ assertFailureResponseValidation(Boolean.TRUE);
+ }
+
+ @Test
+ public void testResponseSchemaFailedValidationBoth() throws Exception {
+ assertFailureResponseValidation(SchemaValidationType.BOTH.name());
+ }
+
+ @Test
+ public void testResponseSchemaFailedValidationIn() throws Exception {
+ assertFailureResponseValidation(SchemaValidationType.IN.name());
+ }
+
+ @Test
+ public void testIgnoreResponseSchemaFailedValidationNone() throws Exception {
+ assertIgnoredResponseValidation(SchemaValidationType.NONE.name());
+ }
+
+ @Test
+ public void testIgnoreResponseSchemaFailedValidationFalse() throws Exception {
+ assertIgnoredResponseValidation(Boolean.FALSE);
+ }
+
+ @Test
+ public void testIgnoreResponseSchemaFailedValidationOut() throws Exception {
+ assertIgnoredResponseValidation(SchemaValidationType.OUT.name());
+ }
+
+ private SomeResponse execute(SchemaValidation service, String id) throws Exception {
+ SomeRequest request = new SomeRequest();
+ request.setId(id);
+ return service.doSomething(request);
+ }
+
+ private void assertFailureResponseValidation(Object validationConfig) throws Exception {
+ SchemaValidation service = createService(validationConfig);
+
+ SomeResponse response = execute(service, "1111111111"); // valid request
+ assertEquals(response.getTransactionId(), "aaaaaaaaaa");
+
+ try {
+ execute(service, "1234567890"); // valid request, but will result in invalid response
+ fail("should catch marshall exception as the invalid incoming message per schema");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Unmarshalling Error"));
+ assertTrue(e.getMessage().contains("is not facet-valid with respect to pattern"));
+ }
+ }
+
+ private void assertIgnoredRequestValidation(Object validationConfig) throws Exception {
+ SchemaValidation service = createService(validationConfig);
+
+ // this is an invalid request but validation is turned off.
+ SomeResponse response = execute(service, "1234567890aaaa");
+ assertEquals(response.getTransactionId(), "aaaaaaaaaa");
+ }
+
+ private void assertIgnoredResponseValidation(Object validationConfig) throws Exception {
+ SchemaValidation service = createService(validationConfig);
+
+ // the request will result in invalid response but validation is turned off
+ SomeResponse response = execute(service, "1234567890");
+ assertEquals(response.getTransactionId(), "aaaaaaaaaaxxx");
+ }
+
+ private void assertFailedRequestValidation(Object validationConfig) throws Exception {
+ SchemaValidation service = createService(validationConfig);
+
+ SomeResponse response = execute(service, "1111111111");
+ assertEquals(response.getTransactionId(), "aaaaaaaaaa");
+
+ try {
+ execute(service, "1234567890aaa");
+ 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"));
+ }
+ }
+
+ private SchemaValidation createService(Object validationConfig) throws Exception {
+ URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
+ assertNotNull(wsdl);
+
+ SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
+ assertNotNull(service);
+
+ SchemaValidation validation = service.getPort(portName, SchemaValidation.class);
+ updateAddressPort(validation, PORT);
+ ((BindingProvider)validation).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
+ ((BindingProvider)validation).getResponseContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
+
+ return validation;
+ }
}
Modified: cxf/branches/2.6.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl?rev=1392529&r1=1392528&r2=1392529&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl (original)
+++ cxf/branches/2.6.x-fixes/testutils/src/main/resources/wsdl/schema_validation.wsdl Mon Oct 1 19:17:30 2012
@@ -28,6 +28,35 @@
<schema targetNamespace="http://apache.org/schema_validation/types"
xmlns:x1="http://apache.org/schema_validation/types"
xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+ <simpleType name="RequestIdType">
+ <restriction base="xsd:string">
+ <pattern value="[0-9]{10}" />
+ </restriction>
+ </simpleType>
+
+ <simpleType name="ResponseTransactionType">
+ <restriction base="xsd:string">
+ <pattern value="[a-zA-Z]{10}" />
+ </restriction>
+ </simpleType>
+
+ <element name="SomeRequest">
+ <complexType>
+ <sequence>
+ <element name="id" type="x1:RequestIdType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="SomeResponse">
+ <complexType>
+ <sequence>
+ <element name="transactionId" type="x1:ResponseTransactionType"/>
+ </sequence>
+ </complexType>
+ </element>
+
<complexType name="ComplexStruct">
<sequence>
<element name="elem1" type="string"/>
@@ -100,9 +129,18 @@
</element>
</schema>
</wsdl:types>
+ <wsdl:message name="doSomethingRequest">
+ <wsdl:part element="x1:SomeRequest" name="in"/>
+ </wsdl:message>
+
+ <wsdl:message name="doSomethingResponse">
+ <wsdl:part element="x1:SomeResponse" name="in"/>
+ </wsdl:message>
+
<wsdl:message name="setComplexStructRequest">
<wsdl:part element="x1:setComplexStruct" name="in"/>
</wsdl:message>
+
<wsdl:message name="setComplexStructResponse">
<wsdl:part element="x1:setComplexStructResponse" name="out"/>
</wsdl:message>
@@ -126,6 +164,11 @@
</wsdl:message>
<wsdl:portType name="SchemaValidation">
+ <wsdl:operation name="doSomething">
+ <wsdl:input message="tns:doSomethingRequest" name="doSomethingRequest"/>
+ <wsdl:output message="tns:doSomethingResponse" name="doSomethingResponse"/>
+ </wsdl:operation>
+
<wsdl:operation name="setComplexStruct">
<wsdl:input message="tns:setComplexStructRequest" name="setComplexStructRequest"/>
<wsdl:output message="tns:setComplexStructResponse" name="setComplexStructResponse"/>
@@ -150,6 +193,16 @@
<wsdl:binding name="SchemaValidationBinding" type="tns:SchemaValidation">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="doSomething">
+ <soap:operation style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+
<wsdl:operation name="setComplexStruct">
<soap:operation style="document"/>
<wsdl:input>