org.systinet.xml.schema.validation
Interface ValidationConfig


public interface ValidationConfig

This interface represents configuration for message validation. It is a crucial part of runtime API for configuring validations. Currently you can configure whether to validate input or output, and what kind of validation is performed - the only supported kind at this moment is simpletypes validation.

The common scenario on both client and server side is:

The only difference in usage on the client and server side is how to obtain the context.

Server side usage

If you want to configure server side validation using API you can do it like this:
    ...
    // obtaining an instance of service endpoint
    ServiceEndpoint serviceEndpoint = ServiceEndpoint.create(SERVICE_PATH, serviceClass);

    // configuring server side validation against xml schema
    ValidationConfig config = (ValidationConfig) Configurator.newRuntimeConfigurable().narrow(ValidationConfig.class);
    // set the direction of validations
    config.setDirection(ValidationConfig.DIRECTION_ALL);
    // set the type of validation
    config.setValidationType(ValidationConfig.VT_SIMPLE_TYPES);

    // applying validation configuration to endpoint that will be published
    serviceEndpoint.getContext().getContextData().put(ValidationConfig.CONTEXT_KEY, config);
    ...
 

Client side usage

If you want to configure validations on the client side using API, do it like this:
    ...
    // create instance of service client
    ServiceClient client = ServiceClient.create(SERVICE_PATH + "/wsdl");
    // set different parameters on the client
    ...
    // create an instance of validation config
    ValidationConfig config = (ValidationConfig) Configurator.newRuntimeConfigurable().narrow(ValidationConfig.class);
    // set the direction of validations
    config.setDirection(ValidationConfig.DIRECTION_IN);
    // set the type of validation
    config.setValidationType(ValidationConfig.VT_SIMPLE_TYPES);
    // applying validation configuration for the client
    client.getContext().getContextData().put(ValidationConfig.CONTEXT_KEY, config);
    ...
  

Since:
4.7
Component:
Core

Field Summary
static java.lang.String CONTEXT_KEY
          under this key, there may be stored class implementing ValidationConfig in the context - on client side it is in ServiceClientContext and on server side it is in ServiceEndpointContext.
static int DIRECTION_ALL
          validation is performed in both directions
static int DIRECTION_IN
          validation is performed only during deserialization
static int DIRECTION_NONE
          no validation is performed
static int DIRECTION_OUT
          validation is performed only during serialization
static int VT_MINOCCURS
          validation of minOccurs attribute that is defined in XML Schema for elements; e.g.
static int VT_NILLABLE
          validation of nillable attribute that is defined in XML Schema for elements; e.g.
static int VT_SIMPLE_TYPES
          validation of simple types
 
Method Summary
 int getDirection()
          returns set direction
 int getValidationType()
          sets type of the validation performed
 void setDirection(int direction)
          sets direction in which validation should be performed
 void setValidationType(int validationType)
          sets type of the validation performed
 

Field Detail

CONTEXT_KEY

public static final java.lang.String CONTEXT_KEY
under this key, there may be stored class implementing ValidationConfig in the context - on client side it is in ServiceClientContext and on server side it is in ServiceEndpointContext.

See Also:
Constant Field Values

DIRECTION_NONE

public static final int DIRECTION_NONE
no validation is performed

See Also:
Constant Field Values

DIRECTION_IN

public static final int DIRECTION_IN
validation is performed only during deserialization

See Also:
Constant Field Values

DIRECTION_OUT

public static final int DIRECTION_OUT
validation is performed only during serialization

See Also:
Constant Field Values

DIRECTION_ALL

public static final int DIRECTION_ALL
validation is performed in both directions

See Also:
Constant Field Values

VT_SIMPLE_TYPES

public static final int VT_SIMPLE_TYPES
validation of simple types

See Also:
Constant Field Values

VT_NILLABLE

public static final int VT_NILLABLE
validation of nillable attribute that is defined in XML Schema for elements; e.g. it is not valid to deserialize element with attribute xsi:nil if element definition in XML Schema forbids it

See Also:
Constant Field Values

VT_MINOCCURS

public static final int VT_MINOCCURS
validation of minOccurs attribute that is defined in XML Schema for elements; e.g. it is not valid to deserialize empty element as empty object (object whose attributes are initialized to default values(nulls)) if element definition in XML Schema mandates non-empty content

See Also:
Constant Field Values
Method Detail

getDirection

public int getDirection()
returns set direction

Returns:
DIRECTION_ALL, DIRECTION_IN, DIRECTION_NONE or DIRECTION_OUT

setDirection

public void setDirection(int direction)
sets direction in which validation should be performed

Parameters:
direction - see the static members (e.g. DIRECTION_ALL, DIRECTION_IN, DIRECTION_NONE or DIRECTION_OUT).

getValidationType

public int getValidationType()
sets type of the validation performed

Returns:
currently set validation type (e.g. VT_SIMPLE_TYPES)

setValidationType

public void setValidationType(int validationType)
sets type of the validation performed

Parameters:
validationType - type of the validation to perform (e.g. VT_SIMPLE_TYPES)