Expose CXF Service With REST And SOAP
Expose CXF Service With REST And SOAP explains step by step details of Exposing restful / SOAP services using Apache CXF and Eclipse with spring framework
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 re-use the same business logic
You can see the below example, which is demonstrate Exposing CXF Service With REST And SOAP
Change CXF Character Encoding
Change CXF Character Encoding explains about How to change character encoding of CXF based messages
Usually CXF not change the encoding of messages, but you can deliberately change one encoding to another by specifying a particular charset that we needed.
Here I am showing an CXF Character Encoding Example where you can see How to change one encoding to another, covering both JAX-WS & JAX-RS services
Change Character Encoding In CXF Restful Services
I am going to re-use CXF Restful Tutorial
Getting IP Address Using CXF
Getting IP Address Using CXF explains about How to get IP Address of client who is consuming the CXF service
I am showing here, How to capture the remote IP Address of clients, both SOAP & RESTFul services
Message message = PhaseInterceptorChain.getCurrentMessage(); HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST); request.getRemoteAddr()
On this code, we are getting HttpServletRequest and from that taking the remote ip address
You can see the below example, which is finding client ip address using cxf
GZIP Using CXF
GZIP Using CXF explains about How to use GZIP compression with CXF framework
GZIP is a text-based encoding protocol which will compress the size of response dramatically
You can configure GZIP encoding with cxf framework according to the following configuration
You can also see the FastInfoset Using CXF, FastInfoset will result in a much better compression rate than gzip because FastInfoset optimize both size and performance, while gzip only deals with size
You can see the below example, which is demonstrating the usage of GZIP With CXF Framework
Apache CXF Logging
Apache CXF Logging explains about configure / enable logging of request and response using CXF framework
For every application logging is vital because it is a must for debugging web services, CXF framework have in-built feature for enabling logging of request / response
You can Enable / Configure CXF Logging using two ways
1) Server Side Logging 2) Client Side Logging
If you are interested to add logs in separate file using log4j, you can find below article
FastInfoset Using CXF
FastInfoset Using CXF explains about How to use FastInfoset encoding with CXF framework
FastInfoset is a binary encoding for an XML Information, It incorporated with a more efficiant serialization mechanism than text based
Using FastInfoset encoding is a much better solution than gzip encoding because FastInfoset optimize both size and performance, while gzip only deals with size
You can also see the GZIP Using CXF if you need to configure gzip compression
You can see the below example, which is demonstrating the usage of FastInfoset Using CXF
RESTful Java Client Using HttpClient
RESTful Java Client Using HttpClient Example explains step by step details of How to create a RESTful java client using Apache HttpClient With Apache CXF
For Creating RESTful Java Client, We are using Apache HttpClient, which will call java.net.HttpURLConnection internally
Here we showing an example, of how to invoking GET and POST method of an exposed restful service (ie; GET & POST operations) .
You can see the below example, which is demonstrating a CXF REST Java Client Using HttpClient
CXF Restful Client
CXF Restful Client Example explains step by step details of How To Create a CXF REST Client from a deployed Apache CXF Restful service
For Creating Apache CXF Restful Client, We are using java.net.HttpURLConnection.
By using HttpURLConnection, we are invoking the correct exposed methods / operations of restful service.
You can see the below example, which is demonstrating a CXF REST Client Example