CXF REST & SOAP Exception Handling Together

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 this configuration, We can expose both restful / JAX-RS and JAX-WS services without any code change and helps you to resuse the same business logic

You can see the below example, which is demonstrate about how to handle an Exception in CXF REST & SOAP together

CXF SOAP Exception Handling

CXF SOAP Exception Handling explains about step by step details of Exception Handling In CXF SOAP Services

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 and JAX-WS.

Services will talk different protocols such as SOAP, RESTful HTTP, CORBA & XML/HTTP and work with different transports like JMS, HTTP or JBI.

Apache CXF Project was created by the merger of the Celtix and XFire projects. These two projects were merged by folks working together at the Apache Software Foundation.

On this example, we are showing how to Implement CXF Exception Handling

Wsimport clientjar Option

Wsimport clientjar Option explains about generating Java Code From A WSDL Document and packed into a jar, So that Client Can Invoke/Consume The Service

I am showing here, an example of generating java code from WSDL document using wsimport tool.

You can also use CXF Client , if you need more custom features like adding logging,interceptor etc.

Reference -> http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

For deploying the service, you can follow this tutorial CXF Web Service Tutorial. After the deployment you can access the url

http://localhost:8080/CXFTutorial/ChangeStudent?wsdl

How To Maintain Cookies Using CXF

How To Maintain Cookies Using CXF explains about Maintaining Cookies Using CXF

I am showing here, How to do maintain Cookies in CXF framework, this is applicable for both SOAP & RESTFul services

Message message = PhaseInterceptorChain.getCurrentMessage();
HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
Cookie[] cookies = request.getCookies();

On this code, we are getting HttpServletRequest and from that we are getting cookies object in CXF

You can see the below example, on which we are storing a value into cookies from client side and retriving the same, using CXF Framework

Java wsimport Tool Example

Java wsimport Example explains about generating Java Code From A WSDL Document, So that Client Can Invoke/Consume The Service

I am showing here, an example of generating java code from WSDL document using wsimport tool.

You can also use CXF Client , if you need more custom features like adding logging,interceptor etc.

Reference -> http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

For deploying the service, you can follow this tutorial CXF Web Service Tutorial. After the deployment you can access the url

http://localhost:8080/CXFTutorial/ChangeStudent?wsdl