Sunday, April 14, 2013

WPS: BOXMLSerializer to validate XML document

XML document validation

XML documents and business objects can be validated using the validation service.
In addition, other services require certain minimum standards or they throw a runtime exception. One of these is BOXMLSerializer.
You can use the BOXMLSerializer to validate XML documents before they are processed by a service request. The BOXMLSerializer validates the structure of XML documents to determine if any of the following types of errors are present:
  • Invalid XML documents, such as those that are missing certain element tags.
  • Not well-formed XML documents, such as those that contain missing closing tags.
  • Documents containing parsing errors, such as errors in entity declaration.
When an error is discovered by the BOXMLSerializer, an exception will be thrown with problem details.
The validation can be performed for import and/or export of XML documents for the following services:
  • HTTP
  • JAXRPC web services
  • JAX-WS web services
  • JMS services
  • MQ services
For the HTTP, JAXRPC, and JAX-WS services, the BOXMLSerializer will generate exceptions in the following manner:
  • Imports –
    1. The SCA component invokes the service.
    2. The service invokes a destination URL.
    3. The destination URL responds with an invalid XML exception.
    4. The service fails with a runtime exception and message.
  • Exports –
    1. The service client invokes the service export.
    2. The service client sends an invalid XML
    3. The export fails for the service and generates an exception and message.
For the JMS and MQ messaging services, the exceptions are generated in the following manner:
  • Imports –
    1. The import invokes the JMS or MQ service.
    2. The service returns a response.
    3. The service returns an invalid XML exception.
    4. The import fails and generates a message.
  • Exports –
    1. The MQ or JMS client invokes an export.
    2. The client sends invalid XML.
    3. The export fails and generates an exception and message.
You can view the logs for any messages generated by an XML validation exception.