CXF REST & SOAP Exception Handling Together explains about how to handle an Exception In CXF REST & SOAP Services together without changing the logic
Apache CXF & is a free and open source project, and a fully featured Webservice framework. It helps you building webservices using different front-end API's, like as JAX-RS (restful based services) and JAX-WS (WSDL based services).
By using following configuration, You can handle exceptions for both restful / JAX-RS (Restful) and JAX-WS (SOAP) services without any code change and helps you to re-use the same business logic
You can see the below example, which is demonstrate about how to handle an Exception in CXF REST & SOAP together
You need to download
Following jar must be in classpath
- jettison-1.3.2.jar (JSON library)
CXF REST & SOAP Exception Handling
I am creating a sample restful and JAX-WS service that pass Student object and return with some changes on that object. The service is using simple POJO (Plain Old Java Object) bean.
Firstly create a Dynamic Web Project (File->New->Dynamic Web Project) named "CXFRestAndSoap" according to following screenshot