IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Business objects programming > Programming using business object services
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, export, or both for the XML documents related to 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 –
- The SCA component invokes the service.
- The service invokes a destination URL.
- The destination URL responds with an invalid XML exception.
- The service fails with a runtime exception and message.
- Exports –
- The service client invokes the service export.
- The service client sends an invalid XML
- 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 –
- The import invokes the JMS or MQ service.
- The service returns a response.
- The service returns an invalid XML exception.
- The import fails and generates a message.
- Exports –
- The MQ or JMS client invokes an export.
- The client sends invalid XML.
- The export fails and generates an exception and message.
You can view the logs for any messages generated by an XML validation exception. The following examples are messages generated by improper XML coding that was validated by the BOXMLSerializer
- JAXWS import
javax.xml.ws.WebServiceException: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: Element type "TestResponse" must be followed by either attribute specifications, ">" or "/>". javax.xml.ws.WebServiceException: org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope- JAXRPC import
[9/11/08 15:16:27:417 CDT] 0000003e ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "transactionNotSupportedActivitySessionNotSupported" on bean "BeanId(WSXMLValidationApp#WSXMLValidationEJB.jar#Module, null)". Exception data: WebServicesFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException faultString: org.xml.sax.SAXParseException: Element type "TestResponse" must be followed by either attribute specifications, ">" or "/>". Message being parsed: <?xml version="1.0"?><TestResponse xmlns="http://WSXMLValidation"<firstName>Bob</firstName> <lastName>Smith</lastName></TestResponse> faultActor: null faultDetail: [9/11/08 15:16:35:135 CDT] 0000003f ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "transactionNotSupportedActivitySessionNotSupported" on bean "BeanId(WSXMLValidationApp#WSXMLValidationEJB.jar#Module, null)". Exception data: WebServicesFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException faultString: org.xml.sax.SAXException: WSWS3066E: Error: Expected 'envelope' but found TestResponse Message being parsed: <?xml version="1.0"?><TestResponse xmlns="http://WSXMLValidation"> <firstName>Bob</firstName><middleName>John</middleName> <lastName>Smith</lastName> </TestResponse> faultActor: null faultDetail:- JAXRPC/JAXWS export
[9/11/08 15:35:13:401 CDT] 00000064 WebServicesSe E com.ibm.ws.webservices.engine.transport.http.WebServicesServlet getSoapAction WSWS3112E: Error: Generating WebServicesFault due to missing SOAPAction. WebServicesFault faultCode: Client.NoSOAPAction faultString: WSWS3147E: Error: no SOAPAction header! faultActor: null faultDetail:
For more information about validation services, see the BOInstanceValidator interface in the Generated API and SPI documentation in the Reference section.