Interceptors :
-----
Positive case : Here in Headers I'm getting the request headers
OutputSOATest out = new OutputSOATest();
List soaList = exchange.getIn().getBody(List.class);
InputSOATest inputSOATest = (InputSOATest) soaList.get(0);
out.setResult("Welcome " + inputSOATest.getTest().toString());
QName faultCode = new QName("http://cxf.apache.org/faultcode", "Fault occurred");
Throwable throwable = null;
SoapFault soapFault = new SoapFault("", throwable, faultCode);
exchange.getOut().setFault(true);
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
exchange.getOut().setBody(out);
Log :
org.apache.cxf.cxf-core - 3.1.5.redhat-630187 | Outbound Messagen | ---------------------------n | ID: 6n | Response-Code: 200n | Encoding: UTF-8n | Content-Type: application/soap+xmln | Headers: {accept-encoding=[gzip,deflate], breadcrumbId=[ID-chardahe-pnq-csb-29906-1566274495472-6-1], Host=[localhost:8181], myHeader=[abc123], SOAPAction=[http://javainuse.com], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}n | Payload: Welcome Testn | --------------------------------------
--------------------------------------------
Producing Soap fault and Headers is empty
QName faultCode = new QName("http://cxf.apache.org/faultcode", "Fault occurred");
Throwable throwable = null;
SoapFault soapFault = new SoapFault("", throwable, faultCode);
exchange.getOut().setFault(true);
exchange.getOut().setHeaders(exchange.getIn().getHeaders());
exchange.getOut().setBody(soapFault);
Log :
org.apache.cxf.cxf-core - 3.1.5.redhat-630187 | Outbound Messagen | ---------------------------n | ID: 4n | Response-Code: 500n | Encoding: UTF-8n | Content-Type: application/soap+xmln | Headers: {}n | Payload: soap:Receiverns1:Fault occurredn | --