You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jp...@apache.org on 2014/12/01 04:25:33 UTC
[2/2] cxf git commit: CXF-6118 support overriding schema validation
at jaxws endpoint and client level. Added REQUEST / RESPONSE annotations and
apply them correct direction for client and server
CXF-6118 support overriding schema validation at jaxws endpoint and client level. Added REQUEST / RESPONSE annotations and apply them correct direction for client and server
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b2bbfa3c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b2bbfa3c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b2bbfa3c
Branch: refs/heads/3.0.x-fixes
Commit: b2bbfa3c3a46359d5113858ac21ff79b8708bd10
Parents: 526d4ef
Author: Jason Pell <jp...@apache.org>
Authored: Mon Dec 1 09:42:52 2014 +1100
Committer: Jason Pell <jp...@apache.org>
Committed: Mon Dec 1 13:21:15 2014 +1100
----------------------------------------------------------------------
.../cxf/annotations/SchemaValidation.java | 2 +-
.../validation/SchemaValidationFeature.java | 2 +-
.../org/apache/cxf/helpers/ServiceUtils.java | 99 +++++++-
.../AbstractInDatabindingInterceptor.java | 28 +--
.../AbstractOutDatabindingInterceptor.java | 26 +-
.../java/org/apache/cxf/message/Message.java | 11 +-
.../factory/AnnotationsFactoryBeanListener.java | 9 +-
.../apache/cxf/helpers/ServiceUtilsTest.java | 94 +++++---
.../soap/interceptor/RPCInInterceptor.java | 2 +-
.../JavaFirstSchemaValidationTest.java | 241 ++++++++++++++-----
.../jaxws/schemavalidation/PersonService.java | 13 +-
.../PersonServiceAnnotated.java | 13 +-
.../PersonServiceAnnotatedImpl.java | 15 +-
.../schemavalidation/PersonServiceImpl.java | 12 +-
.../PersonServiceWithRequestResponseAnns.java | 52 ++++
...ersonServiceWithRequestResponseAnnsImpl.java | 50 ++++
16 files changed, 498 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java b/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
index 2d338ad..eb78ea4 100644
--- a/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
+++ b/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface SchemaValidation {
public enum SchemaValidationType {
- IN, OUT, BOTH, NONE
+ IN, REQUEST, OUT, RESPONSE, BOTH, NONE
}
/**
* Schema Validation Type
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java b/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
index 5eda79c..c314eaf 100644
--- a/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
@@ -51,7 +51,7 @@ public class SchemaValidationFeature extends AbstractFeature {
for (BindingOperationInfo bop : endpoint.getEndpointInfo().getBinding().getOperations()) {
SchemaValidationType type = provider.getSchemaValidationType(bop.getOperationInfo());
if (type != null) {
- bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_ENABLED, type);
+ bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_TYPE, type);
}
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
index 85d77d0..7bac53c 100644
--- a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
@@ -27,7 +27,14 @@ import java.util.StringTokenizer;
import javax.xml.namespace.QName;
import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.service.model.AbstractPropertiesHolder;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.OperationInfo;
public final class ServiceUtils {
@@ -42,24 +49,96 @@ public final class ServiceUtils {
* @param type
*/
public static boolean isSchemaValidationEnabled(SchemaValidationType type, Message message) {
- SchemaValidationType messageType = getSchemaValidationType(message);
+ SchemaValidationType validationType = getSchemaValidationType(message);
+
+ boolean isRequestor = MessageUtils.isRequestor(message);
+ if (SchemaValidationType.REQUEST.equals(validationType)) {
+ if (isRequestor) {
+ validationType = SchemaValidationType.OUT;
+ } else {
+ validationType = SchemaValidationType.IN;
+ }
+ } else if (SchemaValidationType.RESPONSE.equals(validationType)) {
+ if (isRequestor) {
+ validationType = SchemaValidationType.IN;
+ } else {
+ validationType = SchemaValidationType.OUT;
+ }
+ }
- return messageType.equals(type)
+ return validationType.equals(type)
|| ((SchemaValidationType.IN.equals(type) || SchemaValidationType.OUT.equals(type))
- && SchemaValidationType.BOTH.equals(messageType));
+ && SchemaValidationType.BOTH.equals(validationType));
}
-
/**
- * Determines the appropriate SchemaValidationType to return based on either
- * a Boolean (for backwards compatibility) or the selected Schema Validation Type.
- *
- * Package private as the isSchemaValidationEnabled method should be used instead. Only
- * visible for easier testing
+ * A convenience method to check for schema validation config in the message context, and then in the service model.
+ * Does not modify the Message context (other than what is done in the getContextualProperty itself)
*
* @param message
+ * @param type
*/
- static SchemaValidationType getSchemaValidationType(Message message) {
+ public static SchemaValidationType getSchemaValidationType(Message message) {
+ SchemaValidationType validationType = getOverrideSchemaValidationType(message);
+ if (validationType == null) {
+ validationType = getSchemaValidationTypeFromModel(message);
+ }
+
+ if (validationType == null) {
+ validationType = SchemaValidationType.NONE;
+ }
+
+ return validationType;
+ }
+
+ private static SchemaValidationType getOverrideSchemaValidationType(Message message) {
Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+ if (obj != null) {
+ // this method will transform the legacy enabled as well
+ return getSchemaValidationType(obj);
+ } else {
+ return null;
+ }
+ }
+
+ private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) {
+ Exchange exchange = message.getExchange();
+
+ if (exchange != null) {
+ BindingOperationInfo boi = exchange.getBindingOperationInfo();
+ Endpoint endpoint = exchange.getEndpoint();
+
+ if (boi != null && endpoint != null) {
+ SchemaValidationType validationType = null;
+ OperationInfo opInfo = boi.getOperationInfo();
+ EndpointInfo ep = endpoint.getEndpointInfo();
+
+ if (validationType == null && opInfo != null) {
+ validationType = getSchemaValidationTypeFromModel(message, opInfo);
+
+ if (validationType == null && ep != null) {
+ validationType = getSchemaValidationTypeFromModel(message, ep);
+ }
+ }
+
+ return validationType;
+ }
+ }
+
+ // else
+ return null;
+ }
+
+ private static SchemaValidationType getSchemaValidationTypeFromModel(
+ Message message, AbstractPropertiesHolder properties) {
+ Object obj = properties.getProperty(Message.SCHEMA_VALIDATION_TYPE);
+ if (obj != null) {
+ return getSchemaValidationType(obj);
+ } else {
+ return null;
+ }
+ }
+
+ public static SchemaValidationType getSchemaValidationType(Object obj) {
if (obj instanceof SchemaValidationType) {
return (SchemaValidationType)obj;
} else if (obj != null) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
index 472a426..fc3e530 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
@@ -38,6 +38,7 @@ 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;
@@ -52,6 +53,7 @@ import org.apache.cxf.staxutils.DepthXMLStreamReader;
import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
import org.apache.ws.commons.schema.constants.Constants;
+
public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInterceptor<Message> {
public static final String NO_VALIDATE_PARTS = AbstractInDatabindingInterceptor.class.getName()
+ ".novalidate-parts";
@@ -66,8 +68,9 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
super(i, phase);
}
+ @Deprecated
protected boolean isRequestor(Message message) {
- return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
+ return MessageUtils.isRequestor(message);
}
protected boolean supportsDataReader(Message message, Class<?> input) {
@@ -124,24 +127,9 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
}
}
- /**
- * Where an operation level validation type has been set, copy it to the message, so it can be interrogated
- * by all downstream interceptors. It is expected that sub classes will call setDataReaderValidation subsequent
- * to this to ensure the DataReader schema reference is updated as appropriate.
- *
- * @param bop
- * @param message
- * @param reader
- * @see #setDataReaderValidation(Service, Message, DataReader)
- */
- protected void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
- if (opInfo != null) {
- SchemaValidationType validationType =
- (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
- if (validationType != null) {
- message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
- }
- }
+ protected void setOperationSchemaValidation(Message message) {
+ SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
+ message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
protected DepthXMLStreamReader getXMLStreamReader(Message message) {
@@ -246,7 +234,7 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
}
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
QName serviceQName = si.getName();
message.put(Message.WSDL_SERVICE, serviceQName);
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
index 4ba54e5..d144154 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
@@ -43,7 +43,6 @@ import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.staxutils.CachingXmlEventWriter;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
@@ -60,9 +59,11 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
super(id, phase);
}
+ @Deprecated
protected boolean isRequestor(Message message) {
- return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
+ return MessageUtils.isRequestor(message);
}
+
protected boolean shouldBuffer(Message message) {
Object en = message.getContextualProperty(OUT_BUFFERING);
boolean allowBuffer = true;
@@ -85,7 +86,7 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
CachingXmlEventWriter cache = null;
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
// need to cache the events in case validation fails or buffering is enabled
if (shouldBuffer(message)) {
@@ -159,22 +160,9 @@ public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInt
}
}
- /**
- * Where an operation level validation type has been set, copy it to the message, so it can be interrogated
- * by all downstream interceptors
- *
- * @param bop
- * @param message
- * @param reader
- */
- private void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
- if (opInfo != null) {
- SchemaValidationType validationType =
- (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
- if (validationType != null) {
- message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
- }
- }
+ protected void setOperationSchemaValidation(Message message) {
+ SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
+ message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
protected boolean shouldValidate(Message m) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/message/Message.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/message/Message.java b/core/src/main/java/org/apache/cxf/message/Message.java
index 91af8e9..39d6c96 100644
--- a/core/src/main/java/org/apache/cxf/message/Message.java
+++ b/core/src/main/java/org/apache/cxf/message/Message.java
@@ -112,8 +112,17 @@ public interface Message extends StringMap {
*/
String MTOM_ENABLED = "mtom-enabled";
String MTOM_THRESHOLD = "mtom-threshold";
+
+ /**
+ * Runtime schema validation property
+ */
String SCHEMA_VALIDATION_ENABLED = "schema-validation-enabled";
-
+
+ /**
+ * The default values for schema validation will be set in the service model using this property
+ */
+ String SCHEMA_VALIDATION_TYPE = "schema-validation-type";
+
/**
* Boolean property specifying if the Java stack trace is returned as a
* SOAP fault message.
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
index 5c6a9ee..09b75d3 100644
--- a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
+++ b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
@@ -288,9 +288,7 @@ public class AnnotationsFactoryBeanListener implements FactoryBeanListener {
*/
private void addSchemaValidationSupport(Endpoint endpoint, SchemaValidation annotation) {
if (annotation != null) {
- // 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
- endpoint.put(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+ endpoint.getEndpointInfo().setProperty(Message.SCHEMA_VALIDATION_TYPE, annotation.type());
}
}
@@ -349,11 +347,8 @@ public class AnnotationsFactoryBeanListener implements FactoryBeanListener {
}
private void addSchemaValidationSupport(OperationInfo inf, SchemaValidation annotation) {
- // Notice no support for deprecated enabled property here!
- // TODO - should we check for the use of this property and at least log the fact we are
- // ignoring it
if (annotation != null) {
- inf.setProperty(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+ inf.setProperty(Message.SCHEMA_VALIDATION_TYPE, annotation.type());
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
index b790880..bb0d5ec 100644
--- a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
@@ -45,96 +45,130 @@ public class ServiceUtilsTest extends Assert {
assertEquals("http://ws.example.com/", tns);
}
+
+ @Test
+ public void testRequestResponseTypes() {
+ // lets do server side first
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ // now client side
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ }
+
@Test
public void testIsSchemaValidationEnabled() {
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
}
@Test
public void testGetSchemaValidationTypeBoolean() {
- setupSchemaValidationValue(null);
+ setupSchemaValidationValue(null, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("");
+ setupSchemaValidationValue("", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(Boolean.FALSE);
+ setupSchemaValidationValue(Boolean.FALSE, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("false");
+ setupSchemaValidationValue("false", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("FALSE");
+ setupSchemaValidationValue("FALSE", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("fAlse");
+ setupSchemaValidationValue("fAlse", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(Boolean.TRUE);
+ setupSchemaValidationValue(Boolean.TRUE, false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("true");
+ setupSchemaValidationValue("true", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("TRUE");
+ setupSchemaValidationValue("TRUE", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("tRue");
+ setupSchemaValidationValue("tRue", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
}
@Test
public void testGetSchemaValidationType() {
for (SchemaValidationType type : SchemaValidationType.values()) {
- setupSchemaValidationValue(type.name());
+ setupSchemaValidationValue(type.name(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(type.name().toLowerCase());
+ setupSchemaValidationValue(type.name().toLowerCase(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(StringUtils.capitalize(type.name()));
+ setupSchemaValidationValue(StringUtils.capitalize(type.name()), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
}
}
- private void setupSchemaValidationValue(Object value) {
+ private void setupSchemaValidationValue(Object value, boolean isRequestor) {
control.reset();
msg.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
EasyMock.expectLastCall().andReturn(value);
+
+ msg.get(Message.REQUESTOR_ROLE);
+ EasyMock.expectLastCall().andReturn(isRequestor);
+
control.replay();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
index 37120a8..cad50af 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
@@ -224,6 +224,6 @@ public class RPCInInterceptor extends AbstractInDatabindingInterceptor {
message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
index 888e5a8..64863e9 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
@@ -26,60 +26,75 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPFaultException;
import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.Feature;
-import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.feature.validation.DefaultSchemaValidationTypeProvider;
import org.apache.cxf.feature.validation.SchemaValidationFeature;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.message.Message;
-import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-/**
- * TODO - test where the default is NONE at the service level test where the default is IN or OUT, and then
- * override at operation levels
- */
public class JavaFirstSchemaValidationTest extends Assert {
- static final String PORT = TestUtil.getPortNumber(JavaFirstSchemaValidationTest.class);
+ static final String PORT = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
+ static final String PORT2 = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
+ static final String PORT_UNUSED = TestUtil.getNewPortNumber(JavaFirstSchemaValidationTest.class);
private static List<Server> serverList = new ArrayList<Server>();
private static PersonServiceAnnotated annotatedClient;
private static PersonService client;
private static PersonServiceRPC rpcClient;
+
+ private static PersonServiceWithRequestResponseAnns annotatedNonValidatingClient;
+ private static PersonServiceWithRequestResponseAnns disconnectedClient;
+ private static PersonServiceWithRequestResponseAnns noValidationServerClient;
@BeforeClass
public static void startServers() throws Exception {
+ createServer(PORT, PersonService.class, new PersonServiceImpl(), null, createSchemaValidationFeature());
+
+ createServer(PORT2, PersonServiceWithRequestResponseAnns.class,
+ new PersonServiceWithRequestResponseAnnsImpl(), SchemaValidationType.NONE);
+
+ createServer(PORT, PersonServiceAnnotated.class, new PersonServiceAnnotatedImpl(), null);
+
+ createServer(PORT, PersonServiceRPC.class, new PersonServiceRPCImpl(), null,
+ createSchemaValidationFeature());
+
+ createServer(PORT, PersonServiceWithRequestResponseAnns.class,
+ new PersonServiceWithRequestResponseAnnsImpl(), null);
+
+ annotatedClient = createClient(PORT, PersonServiceAnnotated.class, SchemaValidationType.NONE);
+ annotatedNonValidatingClient = createClient(PORT, PersonServiceWithRequestResponseAnns.class,
+ SchemaValidationType.NONE);
+ client = createClient(PORT, PersonService.class, SchemaValidationType.NONE);
+ disconnectedClient = createClient(PORT_UNUSED, PersonServiceWithRequestResponseAnns.class, null);
+ rpcClient = createClient(PORT, PersonServiceRPC.class, SchemaValidationType.NONE);
+ noValidationServerClient = createClient(PORT2, PersonServiceWithRequestResponseAnns.class, null);
+ }
+
+ private static SchemaValidationFeature createSchemaValidationFeature() {
Map<String, SchemaValidationType> operationMap = new HashMap<String, SchemaValidationType>();
operationMap.put("saveInheritEndpoint", SchemaValidationType.BOTH);
operationMap.put("saveNoValidation", SchemaValidationType.NONE);
operationMap.put("saveValidateIn", SchemaValidationType.IN);
operationMap.put("saveValidateOut", SchemaValidationType.OUT);
DefaultSchemaValidationTypeProvider provider = new DefaultSchemaValidationTypeProvider(operationMap);
-
- SchemaValidationFeature feature = new SchemaValidationFeature(provider);
-
- createServer(PersonService.class, new PersonServiceImpl(), feature);
-
- createServer(PersonServiceAnnotated.class, new PersonServiceAnnotatedImpl());
-
- createServer(PersonServiceRPC.class, new PersonServiceRPCImpl(), feature, new LoggingFeature());
-
- annotatedClient = createClient(PersonServiceAnnotated.class);
- client = createClient(PersonService.class);
- rpcClient = createClient(PersonServiceRPC.class);
+ return new SchemaValidationFeature(provider);
}
-
+
@AfterClass
public static void cleanup() throws Exception {
for (Server server : serverList) {
@@ -87,10 +102,9 @@ public class JavaFirstSchemaValidationTest extends Assert {
}
}
- static String getAddress(Class<?> sei) {
- return "http://localhost:" + PORT + "/" + sei.getSimpleName();
+ static String getAddress(String port, Class<?> sei) {
+ return "http://localhost:" + port + "/" + sei.getSimpleName();
}
-
@Test
public void testRPCLit() throws Exception {
@@ -103,8 +117,8 @@ public class JavaFirstSchemaValidationTest extends Assert {
try {
person.setFirstName(null);
rpcClient.saveValidateOut(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Marshalling Error"));
assertTrue(sfe.getMessage().contains("lastName"));
}
@@ -119,39 +133,39 @@ public class JavaFirstSchemaValidationTest extends Assert {
try {
annotatedClient.saveInheritEndpoint(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
try {
person.setFirstName(""); // empty string is valid
annotatedClient.saveInheritEndpoint(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
person.setLastName(""); // empty string is valid
annotatedClient.saveInheritEndpoint(person);
}
-
+
@Test
public void testSaveValidateInAnnotated() {
Person person = new Person();
try {
annotatedClient.saveValidateIn(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
try {
person.setFirstName(""); // empty string is valid
annotatedClient.saveValidateIn(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
@@ -172,38 +186,59 @@ public class JavaFirstSchemaValidationTest extends Assert {
annotatedClient.saveNoValidation(person);
}
- // no validation is required for incoming
@Test
- public void testSaveValidationOutAnnotated() {
+ public void testRequestValidationWithClientValidationDisabled() {
Person person = new Person();
- annotatedClient.saveValidateOut(person);
-
+ try {
+ annotatedNonValidatingClient.saveValidateIn(person);
+ } catch (SOAPFaultException sfe) {
+ // has to be server side exception, as all validation is disabled on client
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
+
person.setFirstName(""); // empty string is valid
- annotatedClient.saveValidateOut(person);
+ try {
+ annotatedNonValidatingClient.saveValidateIn(person);
+ } catch (SOAPFaultException sfe) {
+ // has to be server side exception, as all validation is disabled on client
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
person.setLastName(""); // empty string is valid
- annotatedClient.saveValidateOut(person);
+ annotatedNonValidatingClient.saveValidateIn(person);
}
+
+ @Test
+ public void testResponseValidationWithClientValidationDisabled() {
+ Person person = new Person();
- // so this is the default, we are inheriting from the service level SchemaValidation annotation
- // which is set to BOTH
+ try {
+ person.setFirstName("InvalidResponse");
+ person.setLastName("WhoCares");
+ annotatedNonValidatingClient.saveValidateOut(person);
+ } catch (SOAPFaultException sfe) {
+ // has to be server side exception, as all validation is disabled on client
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
+ }
+
@Test
public void testEndpointSchemaValidationProvider() {
Person person = new Person();
try {
client.saveInheritEndpoint(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
-
+
try {
person.setFirstName(""); // empty string is valid
client.saveInheritEndpoint(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
@@ -217,16 +252,16 @@ public class JavaFirstSchemaValidationTest extends Assert {
try {
client.saveValidateIn(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
try {
person.setFirstName(""); // empty string is valid
client.saveValidateIn(person);
+ fail("Expected exception");
} catch (SOAPFaultException sfe) {
- // verify its server side and a schema validation
assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
}
@@ -234,7 +269,6 @@ public class JavaFirstSchemaValidationTest extends Assert {
client.saveValidateIn(person);
}
- // no validation at all is required
@Test
public void testSaveNoValidationProvider() {
Person person = new Person();
@@ -247,53 +281,130 @@ public class JavaFirstSchemaValidationTest extends Assert {
client.saveNoValidation(person);
}
- // no validation is required for incoming
@Test
- public void testSaveValidationOutProvider() {
+ public void testRequestClientValidation() {
Person person = new Person();
- client.saveValidateOut(person);
+ try {
+ disconnectedClient.saveValidateOut(person);
+ fail("Expected exception");
+ } catch (SOAPFaultException sfe) {
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
+
+ person.setFirstName(""); // empty string is valid
+ try {
+ disconnectedClient.saveValidateOut(person);
+ fail("Expected exception");
+ } catch (SOAPFaultException sfe) {
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
+ person.setLastName(""); // empty string is valid
+
+ // this confirms that we passed client validation as we then got the connectivity error
+ try {
+ disconnectedClient.saveValidateOut(person);
+ fail("Expected exception");
+ } catch (WebServiceException e) {
+ assertTrue(e.getMessage().contains("Could not send Message"));
+ }
+ }
+
+ @Test
+ public void testResponseClientValidation() {
+ Person person = new Person();
+
+ try {
+ noValidationServerClient.saveValidateIn(person);
+ fail("Expected exception");
+ } catch (SOAPFaultException e) {
+ assertTrue(e.getMessage().contains("Unmarshalling Error"));
+ }
+
person.setFirstName(""); // empty string is valid
- client.saveValidateOut(person);
+ try {
+ noValidationServerClient.saveValidateIn(person);
+ fail("Expected exception");
+ } catch (SOAPFaultException sfe) {
+ assertTrue(sfe.getMessage().contains("Unmarshalling Error"));
+ }
+
+ person.setLastName(""); // empty string is valid
+
+ noValidationServerClient.saveValidateIn(person);
+ }
+
+ @Test
+ public void testSaveValidationOutProvider() {
+ Person person = new Person();
+
+ try {
+ client.saveValidateOut(person);
+ } catch (SOAPFaultException sfe) {
+ // verify its server side outgoing
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
+
+ person.setFirstName(""); // empty string is valid
+ try {
+ client.saveValidateOut(person);
+ } catch (SOAPFaultException sfe) {
+ assertTrue(sfe.getMessage().contains("Marshalling Error"));
+ }
person.setLastName(""); // empty string is valid
client.saveValidateOut(person);
}
- private static <T> T createClient(Class<T> serviceClass) {
+ private static <T> T createClient(String port, Class<T> serviceClass, SchemaValidationType type,
+ Feature ... features) {
JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
clientFactory.setServiceClass(serviceClass);
-
- // ensure all client schema validation is disabled
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(Message.SCHEMA_VALIDATION_ENABLED, SchemaValidationType.NONE);
- clientFactory.setProperties(properties);
-
- clientFactory.setAddress(getAddress(serviceClass));
-
+
+
+ clientFactory.setAddress(getAddress(port, serviceClass));
+
+ if (features != null) {
+ clientFactory.getFeatures().addAll(Arrays.asList(features));
+ }
+
@SuppressWarnings("unchecked")
T newClient = (T)clientFactory.create();
- Client clientProxy = ClientProxy.getClient(newClient);
-
- // ensure all client schema validation is disabled
- for (BindingOperationInfo bop : clientProxy.getEndpoint().getEndpointInfo().getBinding()
- .getOperations()) {
- bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_ENABLED, SchemaValidationType.NONE);
+ Client proxy = ClientProxy.getClient(newClient);
+
+ if (type != null) {
+ proxy.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, type);
}
-
+
+ HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
+ // give me longer debug times
+ HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
+ clientPolicy.setConnectionTimeout(1000000);
+ clientPolicy.setReceiveTimeout(1000000);
+ conduit.setClient(clientPolicy);
+
return newClient;
}
- public static Server createServer(Class<?> serviceInterface, Object serviceImpl, Feature ... features)
+ public static Server createServer(String port, Class<?> serviceInterface, Object serviceImpl,
+ SchemaValidationType type, Feature ... features)
throws IOException {
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(serviceImpl.getClass());
+
if (features != null) {
svrFactory.getFeatures().addAll(Arrays.asList(features));
}
- svrFactory.setAddress(getAddress(serviceInterface));
+
+ if (type != null) {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ properties.put(Message.SCHEMA_VALIDATION_ENABLED, type);
+ svrFactory.setProperties(properties);
+ }
+
+ svrFactory.setAddress(getAddress(port, serviceInterface));
svrFactory.setServiceBean(serviceImpl);
Server server = svrFactory.create();
serverList.add(server);
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
index e3ee10c..d594e4e 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonService.java
@@ -21,6 +21,7 @@ package org.apache.cxf.systest.jaxws.schemavalidation;
import javax.jws.WebMethod;
import javax.jws.WebParam;
+import javax.jws.WebResult;
import javax.jws.WebService;
import org.apache.cxf.annotations.SchemaValidation;
@@ -30,14 +31,18 @@ import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
@SchemaValidation(type = SchemaValidationType.BOTH)
public interface PersonService {
@WebMethod(operationName = "saveInheritEndpoint")
- void saveInheritEndpoint(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveInheritEndpoint(@WebParam(name = "Person") Person data);
@WebMethod(operationName = "saveNoValidation")
- void saveNoValidation(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveNoValidation(@WebParam(name = "Person") Person data);
@WebMethod(operationName = "saveValidateIn")
- void saveValidateIn(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveValidateIn(@WebParam(name = "Person") Person data);
@WebMethod(operationName = "saveValidateOut")
- void saveValidateOut(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveValidateOut(@WebParam(name = "Person") Person data);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
index 3e06576..a760f27 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotated.java
@@ -21,6 +21,7 @@ package org.apache.cxf.systest.jaxws.schemavalidation;
import javax.jws.WebMethod;
import javax.jws.WebParam;
+import javax.jws.WebResult;
import javax.jws.WebService;
import org.apache.cxf.annotations.SchemaValidation;
@@ -30,17 +31,21 @@ import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
@SchemaValidation(type = SchemaValidationType.BOTH)
public interface PersonServiceAnnotated {
@WebMethod(operationName = "saveInheritEndpoint")
- void saveInheritEndpoint(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveInheritEndpoint(@WebParam(name = "Person") Person data);
@SchemaValidation(type = SchemaValidationType.NONE)
@WebMethod(operationName = "saveNoValidation")
- void saveNoValidation(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveNoValidation(@WebParam(name = "Person") Person data);
@SchemaValidation(type = SchemaValidationType.IN)
@WebMethod(operationName = "saveValidateIn")
- void saveValidateIn(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveValidateIn(@WebParam(name = "Person") Person data);
@SchemaValidation(type = SchemaValidationType.OUT)
@WebMethod(operationName = "saveValidateOut")
- void saveValidateOut(@WebParam(name = "Person") Person data);
+ @WebResult(name = "Person")
+ Person saveValidateOut(@WebParam(name = "Person") Person data);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
index c7b8038..78973c9 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceAnnotatedImpl.java
@@ -26,18 +26,25 @@ import javax.jws.WebService;
targetNamespace = "http://org.apache.cxf/service/PersonServiceAnnotated")
public class PersonServiceAnnotatedImpl implements PersonServiceAnnotated {
@Override
- public void saveNoValidation(Person data) {
+ public Person saveNoValidation(Person data) {
+ return data;
}
@Override
- public void saveInheritEndpoint(Person data) {
+ public Person saveInheritEndpoint(Person data) {
+ return data;
}
@Override
- public void saveValidateIn(Person data) {
+ public Person saveValidateIn(Person data) {
+ if ("InvalidResponse".equals(data.getFirstName())) {
+ return new Person();
+ }
+ return data;
}
@Override
- public void saveValidateOut(Person data) {
+ public Person saveValidateOut(Person data) {
+ return data;
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
index fe1d656..9edec45 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceImpl.java
@@ -26,18 +26,22 @@ import javax.jws.WebService;
targetNamespace = "http://org.apache.cxf/service/PersonService")
public class PersonServiceImpl implements PersonService {
@Override
- public void saveNoValidation(Person data) {
+ public Person saveNoValidation(Person data) {
+ return data;
}
@Override
- public void saveInheritEndpoint(Person data) {
+ public Person saveInheritEndpoint(Person data) {
+ return data;
}
@Override
- public void saveValidateIn(Person data) {
+ public Person saveValidateIn(Person data) {
+ return data;
}
@Override
- public void saveValidateOut(Person data) {
+ public Person saveValidateOut(Person data) {
+ return data;
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
new file mode 100644
index 0000000..a1f4fe0
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnns.java
@@ -0,0 +1,52 @@
+/**
+ * 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.systest.jaxws.schemavalidation;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+
+import org.apache.cxf.annotations.SchemaValidation;
+import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+
+@WebService(name = "PersonServiceWithRequestResponseAnns",
+ targetNamespace = "http://org.apache.cxf/service/PersonServiceWithRequestResponseAnns")
+@SchemaValidation(type = SchemaValidationType.BOTH)
+public interface PersonServiceWithRequestResponseAnns {
+ @WebMethod(operationName = "saveInheritEndpoint")
+ @WebResult(name = "Person")
+ Person saveInheritEndpoint(@WebParam(name = "Person") Person data);
+
+ @SchemaValidation(type = SchemaValidationType.NONE)
+ @WebMethod(operationName = "saveNoValidation")
+ @WebResult(name = "Person")
+ Person saveNoValidation(@WebParam(name = "Person") Person data);
+
+ @SchemaValidation(type = SchemaValidationType.RESPONSE)
+ @WebMethod(operationName = "saveValidateIn")
+ @WebResult(name = "Person")
+ Person saveValidateIn(@WebParam(name = "Person") Person data);
+
+ @SchemaValidation(type = SchemaValidationType.REQUEST)
+ @WebMethod(operationName = "saveValidateOut")
+ @WebResult(name = "Person")
+ Person saveValidateOut(@WebParam(name = "Person") Person data);
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/b2bbfa3c/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
new file mode 100644
index 0000000..f64014f
--- /dev/null
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/PersonServiceWithRequestResponseAnnsImpl.java
@@ -0,0 +1,50 @@
+/**
+ * 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.systest.jaxws.schemavalidation;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "org.apache.cxf.systest.jaxws.schemavalidation.PersonServiceWithRequestResponseAnns",
+ serviceName = "PersonServiceWithRequestResponseAnns",
+ targetNamespace = "http://org.apache.cxf/service/PersonServiceWithRequestResponseAnns")
+public class PersonServiceWithRequestResponseAnnsImpl implements PersonServiceWithRequestResponseAnns {
+ @Override
+ public Person saveNoValidation(Person data) {
+ return data;
+ }
+
+ @Override
+ public Person saveInheritEndpoint(Person data) {
+ return data;
+ }
+
+ @Override
+ public Person saveValidateIn(Person data) {
+ if ("InvalidResponse".equals(data.getFirstName())) {
+ return new Person();
+ }
+ return data;
+ }
+
+ @Override
+ public Person saveValidateOut(Person data) {
+ return data;
+ }
+}