Tuesday, June 26, 2012

AggregatedXmlMessageValidationException and inbound-gateway

I wrote a mediation layer with spring integration for a system. Mediation layer validates, transform, signs and encrypts given xml and then route it to required target.

However client is right to complain about the failure message for an xml which does not validate against the xsd schema. I am using validating-filter with spring integration and ws client recieves following message on xsd validation failure:




In order to fix that add an error channel to ws inbound such:



And finally the logger; it logs the detail of the problem to log and also returns it to client; so he/she can fix her code for given problem:



Tuesday, June 12, 2012

Custom XSLT Factory within application scope

Yesterday I tried an xsl transformation with the following xsl:




That xsl helps me to transform an xml to an xml which have scoped default namespaces. However that xsl is not working with Xalan. It is ok with Saxon. So I passed

-Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl to jvm.

It is okay with Tomcat but when you deploy to IBM Websphere application server; you recieve:

"[6/12/12 10:09:57:586 EEST] 0000000d UserRegistryC E SECJ0281E: Error creating user registry object. The exception is javax.xml.transform.TransformerFactoryConfigurationError: Provider net.sf.saxon.TransformerFactoryImpl not found" error.

The reason is that saxon.jar is only on application path; but we ask server to use it everywhere; so it looks for that factory as soon as server is running. One solution is to put that jar in the shared folder of ibm webshepre; so that it can locate it.

But then I think not to do it; let ibm webshere (and other deployed applications) to use it own xslt factory and my application use it's own xslt factory.

I was using Spring Integration. Spring Integration has a nice transformer (XsltPayloadTransformer) class; but it does not let you specify the xslt factory; it uses system variable.  So I extend it as:



I was lazy to extend XsltPayloadTransformerParser as well; so in my spring configuration file; I defined it as below: