Configuring Web Services for XML Validation

You can use the "validate" module for schema validation of messages going in and out of xMatters web services.

Add the following lines to the services.xml file inside your service .aar file:

<module ref="validate" /> 
<parameter name="validationSchema">AlarmPointWebServiceValidation.wsdl.xml</parameter> 
<parameter name="validationPolicyOnError">ABORT</parameter>
 
Parameter Description
validationSchema Specifies the URL to access the schema definitions for your service. You must have a separate schema file for this feature; future releases may support automatic schema extraction from the WSDL. Note that schemas are cached for efficiency; if you change the schema, you must restart your web server.
validationPolicyOnError

Optional: Indicates how the module should respond if an error occurs during the validation. The possible values are:

  • ABORT: Cancel the request if validation fails.
  • CONTINUE: Ignore the error if validation fails, and continue the request.

The validation information is output to the log at the "INFO" logging level. With logging enabled, you should see messages similar to the following:

AlarmPointValidateHandler - Successfully validated 'getItem' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'getItemResponse' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'getTypes' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'getTypesResponse' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'addItem' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'addItemResponse' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'addItem' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'addItem' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'addItemResponse' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'getItemsByType' body element for service AlarmPointWebService 
AlarmPointValidateHandler - Successfully validated 'getItemsByTypeResponse' body element for service AlarmPointWebService 

Example

Use the following steps to view log messages related to schema validation; note that the following example requires the SOAP monitoring utility to be enabled:

  1. In the webserver/webapps/axis2/WEB-INF/services/AlarmPointWebService/META-INF directory, edit the services.xml file.
  2. Add the following code:
  3. <module ref="validate"/>

      <parameter name="validationSchema">file:///e:/AlarmpointSystems/AlarmPoint/webserver/webapps/axis2/WEB-INF/services/AlarmPointWebService/META-INF/AlarmPointWebService.xsd</parameter>

     

  4. Save and close the services.xml file.
  5. In the webserver/webapps/axis2/WEB-INF/classes directory, edit the log4j.xml file.
  6. Uncomment the validation section, or add the following:
  7. <appender name="AXIS2_VALIDATION" class="org.apache.log4j.FileAppender">

      <param name="File" value="${axis2.webapp.root}/WEB-INF/logs/validation.log" />

      <param name="Append" value="false" />

        <layout class="org.apache.log4j.PatternLayout">

          <param name="ConversionPattern" value="%d [%t] %-5p %c{2} - %m%n"/>

        </layout>

    </appender>

     

    <logger name="com.alarmpoint.axis2">

      <level value="INFO"/>

      <appender-ref ref="AXIS2_VALIDATION" />

      </logger>

     

  8. Save and close the file, and then restart the web server.

As the web service requests are received, a new log file called validation.log is created in the webserver/webapps/axis2/WEB-INF/logs directory. View this file to determine why your web service request might be failing.