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 retrieving the same, using CXF Framework

CXF REST Without Spring

CXF REST Without Spring explains step by step details of Creating / Developing CXF JAX-RS (Restful) services without any spring dependencies

JAX-RS is Java API for RESTful Webservices which is very rely upon Representational State Transfer model, you can view JAX-RS specification. JAX-RS uses annotations for simplifying the development efforts.

Most of the tutorial related to Apache CXF is developed using spring framework, this is because of easy integration with spring. But it is not a necessity.

You can see the below example, which is demonstrating How to create a Restful service using CXF without any spring dependencies

CXF java2wsdl Example

CXF JavaToWS Tutorial explains about generating WSDL And Other Artifacts From Web Service Endpoint's Implementation (SEI) Using CXF JavaToWS Tool

I am showing here, an example of generating WSDL,XSD schema using CXF JavaToWS Tool.

You can also generate server side and client side code using this tool, you can go to below reference

Reference -> http://cxf.apache.org/docs/java-to-ws.html

CXF Session Management

CXF session Management explains about Enabling Session Handling In Apache CXF

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

Message message = PhaseInterceptorChain.getCurrentMessage();
HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
HttpSession  session = request.getSession(true);

CXF Schema Validation Example

CXF Schema Validation Example explains about How to validating wsdl/schema using CXF framework

How to enable schema validation on CXF SOAP requests and responses

How can I turn on schema validation for jaxws endpoint?‎

CXF is providing in built schema validation, so that we can define different rule on WSDL schema level and if the request/response is not satisfying according to the schema, an error is produced

It is very helpful because, we get error message very before than it need to validate on server side.

Configure Log4j with CXF

Configure Log4j with CXF explains step by step details of configuring Log4j and Apache CXF Webservice.

For every application logging has a vital role because it is a must for various debugging purpose, CXF framework have in-built feature for enabling logging of request and response payloads

log4j is commonly used logging framework in java, this tutorial is using log4j as the logging tool.

You can also see server side/client side logging Apache CXF Logging

Here I am showing How to use Log4j for logging CXF soap messages

CXF Interceptor Example

CXF Interceptor Example explains about intercepting request/response of a CXF message

How to add an interceptor to the CXF ?

How to modify CXF message using interceptor?

In CXF framework InterceptorChains are divided up into Phases. Each request/response are going through different phases, we can intercept request and response on these phases with minimum effort.

CXF also providing lot of in built interceptors too, you can see them on the below link as CXF contributed interceptors

Apache CXF With Jackson

Apache CXF With Jackson Example explains step by step details of configuring Apache CXF With Jackson Provider

JAX-RS is Java API for RESTful Webservices which is very rely upon Representational State Transfer model, you can view JAX-RS specification 

Jackson is an open source java library for processing JSON format. We can use Jackson library by replacing Jettison, which is the default library for CXF

You can see the below example, which is demonstrating How to configure a Restful service using Jackson library by replacing default jettison library which is available with cxf bundle

You can also see Restful service using Jettison library CXF Restful Tutorial.