Category Apache CXF

Apache CXF with Spring: How to add HTTP headers to a SOAP request using a custom CXF interceptor?


Let’s assume that we want to make a SOAP call to a service at http://localhost:8080/samplewebservices/echoserviceinterface, and it requires that we add an API / Access token as a HTTP header, we can do it this way: Assumptions Endpoint: http://localhost:8080/samplewebservices/echoserviceinterface Service Interface: singz.ws.test.interface.EchoService ACCESS_TOKEN: 046b6c7f-0b8a-43b9-b35d-6489e6daee91 (HTTP Header) Spring Application Context Configuration Custom Interceptor to add HTTP […]

Using .NET v2.0 generated WSDLs with JAX-WS: How to resolve “A class/interface with the same name “XXXX” is already in use. Use a class customization to resolve this conflict”?


I’ve noticed an issue in WSDLs generated by .NET 2.0 apps: some of the element(s) and their corresponding complextype definitions have same name. If you happen to generate JAX-WS portable artifacts (see below) from one such WSDL for your project (during technology migration etc. and you don’t want the consumers who use this WSDL to […]

Apache CXF: How to add custom HTTP headers to a web service request?


HTTP header fields are components of the message header of requests and responses in the Hypertext Transfer Protocol (HTTP). They define the operating parameters of an HTTP transaction, carry information about the client browser, the requested page, the server and more. Here’s how the HTTP headers can be added to your web service calls made […]

Apache CXF: How to add custom SOAP message headers to a web service request?


SOAP headers can be added to a Web service request in different ways, if you use Apache CXF. They way I prefer is the one I’ve mentioned here – as it doesn’t require changes to wsdl or method signatures and it’s much faster as it doesn’t break streaming and the memory overhead is less. The […]

Apache CXF-based Java Web Services: How to log/print the payload XML of incoming SOAP request using LoggingInInterceptor?


I’ve had a requirement to print the exact SOAP XML of incoming requests to one of our web services written using Apache CXF Framework and here’s what I did. For doing this quickly, I’m taking the code from https://singztechmusings.wordpress.com/2010/12/10/java-web-services-soap-over-ssl-cxf-framework/ for CalculationServerIfc that basically does addition/subtraction based on web service requests. Here’s it: and I’m assuming […]

Apache CXF: How message processing happens and what’s the role of interceptor?


When a Apache CXF developed consumer invokes a remote service the following message processing sequence is started: 1. The Apache CXF runtime creates an outbound interceptor chain to process the request. 2. If the invocation starts a two-way message exchange, the runtime creates an inbound interceptor chain and a fault processing interceptor chain. 3. The […]

Apache CXF: Adding a custom interceptor to an interceptor chain


According to CXF docs, Interceptors are the fundamental processing unit inside CXF. When a service is invoked, an InterceptorChain is created and invoked. Each interceptor gets a chance to do what they want with the message. This can include reading it, transforming it, processing headers, validating the message, etc. When a CXF client invokes a […]

Apache CXF: Implementing Failover and Load Balancing


If you look at CXF feature list at http://cxf.apache.org/docs/featureslist.html, you’d find something called FAILOVER, and the description reads “Feature that allows clients to failover from the initial target endpoint to another, compatible endpoint for the target service”. I thought of exploring this a bit, and googled. Couldn’t find much in CXF docs. But, found an article […]

How to configure timeouts at client side for Apache CXF web services?


I’m extending the example at https://singztechmusings.wordpress.com/2010/12/10/java-web-services-soap-over-ssl-cxf-framework/ to show how to set connection/receive timeout duration for a CXF client. If you’d like to wait indefinitely for connecting to server, or receiving a response, either do not add marked lines in code, or set the timeouts to zero.

How to specify multiple WSDLs for generating JAX-WS artifacts using CXF’s Maven plugin for wsdl2java (cxf-codegen-plugin)?


Each element corresponds to a WSDL for which we need to generate artifcats.