|
Page Edited :
SM :
servicemix-validation
servicemix-validation has been edited by Lars Heinemann (Jun 17, 2008). Content:ServiceMix ValidationThe ServiceMix Validation component provides schema validation of documents using JAXP 1.3
InstallationInstalling the servicemix-validation component can be done in several ways:
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console. CreationYou can use Maven to create a service unit. mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-validation-service-unit \
-DgroupId=com.mycompany.myproduct \
-DartifactId=mycomponent.artifact
The following table shows the additional configuration possibilities of the endpoint.
For all xbean file endpoint configuration take a look at Xml schemas The schemaResourceThe schema resource can be defined in different ways: script="classpath:mySchema.xsd" OR script="file:///home/lhein/mySchema.xsd" The errorHandlerFactoryYou can specify your own error handling factory which will be used to create an error handler for the validation. All factories have to implement the interface org.apache.servicemix.validation.handler.MessageAwareErrorHandlerFactory. This interface This method createMessageAwareErrorHandler() creates the error handler for validating the xml. The MessageAwareErrorHandler is also a interface defining the methods needed for call back while validating a xml: You can the configure your endpoint to use your factory and handler instead the standard ones. Example: <validation:endpoint service="test:service3"
endpoint="endpoint"
schemaResource="classpath:schema.xsd"
handlingErrorMethod="FAULT_FLOW">
<property name="errorHandlerFactory">
<bean class="org.apache.servicemix.validation.handler.MessageAggregatingErrorHandlerFactory">
<property name="rootPath" value="Fault/payload/messages"/>
<property name="namespace" value="http://www.servicemix.org/fault"/>
<property name="includeStackTraces" value="false"/>
</bean>
</property>
</validation:endpoint>
Available factories / handlersCountingErrorHandlerFactory / CountingErrorHandlerThis one is just counting warnings, errors and fatal errors. Depending on the set handlingErrorMethod it will throw an exception or deliver a fault string containing a xml like this: <result> <warning>10</warning> <error>2</error> <fatal>0</fatal> </result> As you can see this factory / handler is just counting problems in the xml and delivers the result back. MessageAggregatingErrorHandlerFactory / MessageAggregatingErrorHandlerThis one captures messages from the validator and delivers them to the caller like this: <rootPath xmlns="namespace">
<warning><![CDATA[ warning message ]]></warning>
<error><![CDATA[ error message ]]></error>
<fatalError><![CDATA[ fatal error message ]]></fatalError>
</rootPath>
handlingErrorMethodThere are 2 modes existing:
|
Unsubscribe or edit your notifications preferences
