cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Przemysław Bielicki <>
Subject Custom fault response (JAX-WS)
Date Thu, 12 Dec 2013 14:08:29 GMT

I spent couple of last days, debugging CXF and trying to intercept/inject
custom fault response but I give up. I need your help guys.

I am currently getting this kind of response when an exception is thrown
(either in In or Out interceptor).

<soap:Envelope xmlns:soap="">
         <faultstring>exception message</faultstring>

 I would like to send a custom response as (example):

<soap:Envelope xmlns:soap="">

How can I do it in the easiest way? Let's assume that my Response and
MessageHeader are Java beans with JAXB annotations so I can use JAXB

The only thing I succeeded at the moment is to add custom header but I
can't help changing the Body part.

Anyway, customizing the header part was not obvious:

public void handleFault(SoapMessage message) {
   Map<String, List<String>> headers = (Map<String, List<String>>)
   Header header = new Header(Constants.HEADER_QNAME, msgHeader,

I had to clean "Content-Length" header (otherwise CXF was copying the value
of this header from the HTTP request and my response was cut in the middle
as the length was wrong) and set inMessage as outMessage

Many thanks for help.
Przemyslaw Bielicki

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message