Problem Statement:
Currently, there are two requirements namely having the correctly populated “” element in the SOAP Fault, and as-close-as possible the match between SOAP Request and SOAP Response for pre- and post- migrated CXF web service from Axis Web Service.
For the first need abovementioned, we explored the following options:
- We configured custom Interceptor class for CXF that will handle the SOAP Fault as desired. We also modified the method in the service implementation such that the contents for the “ element can be directly set in the Java code. However, we encountered the problem related to the JAXB Context not being able to un-marshal the Java exception correctly into the SOAP Fault
- We created two new classes, one as an actual container for the exception as a simple Java bean, and another as its wrapper extending the Java exception class. We used the exception wrapper class in the service implementation for allowing the translation of the application exception into the SOAP Fault. However, we encountered the problem that these classes were not known to the JAXB Context
- We tried to use wsdl2java tool to generate various artifacts for JAX-WS and JAXB – we introduced changes to specify the SOAP Fault in the XSD fragment in the available (that is, the legacy from Axis / WebLogic) WSDL, and used the JAXB artifacts, particularly the ObjectFactory and DamageCatalogElementArray classes that handle the JAXB Context. Post this, we encountered the error that the various XML types i.e. their corresponding classes referenced were undefined for the specified namespace
- We made the namespaces (QName instances) used in various classes consistent and used another class, package-info to specify the schema mapping with the package structure. At this time, we are receiving the error that the schema conflict in collection for an array of a specific class, DamageCatalogElement in the service implementation method, catalogDamage() as related to the class, DamageCatalogElementArray. This is because the return type of this method in the service implementation is an array of type, DamageCatalogElement whereas when we return the JAXBElement instance in the ObjectFactory, we must use the class, DamageCatalogElementArray
We are using CXF 2.4.2, JDK1.6, JBoss AS 4.2.
Any help or pointers would be much appreciated!!
Finally we solved the issue.
The trick was, generating classes using CXF tool wsdl2java by supplying the WSDL of Axis and replacing the JAXB related classes in the legacy code.
While doing this we need to do some refactoring but that was fine.
The moment we put the generated classes, everything is working fine. 🙂