When soap 1.2 binding is set in camel-cxf transport, the expectation is that it should serve for both soap 1.1 as well as 1.2 soap requests.
However, when soap 1.1 request is sent, the Content-Type returned in the response is 'application/soap+xml', which is not correct.
The expected soap response Content-type for soap 1.1 message with soap 1.2 binding set should still be 'text/xml'.
This behaviour of camel-cxf transport differs from the pure CXF's JAX-WS frontend configuration, wherein, the Content-Type returned in response for soap 1.1 request is 'text/xml'.
Workaround :
- As a workaround for this issue, you have to include a custom interceptor as below to change the Content-Type:
public class Soap11ContentTypeOutInterceptor extends AbstractSoapInterceptor { |
|
|
public Soap11ContentTypeOutInterceptor() { |
super(Phase.POST_PROTOCOL); |
addAfter(SoapPreProtocolOutInterceptor.class.getName()); |
}
|
|
|
public void handleMessage(SoapMessage message) throws Fault { |
|
|
if (message.getVersion() instanceof Soap11) { |
message.put(Message.CONTENT_TYPE, ((Soap11) message.getVersion()).getContentType());
|
}
|
|
|
/*Map<String, List<String>> headers = CastUtils |
.cast((Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS));
|
|
|
if (headers.containsKey("content-type.override")) {
|
message.put(Message.CONTENT_TYPE, headers.get("content-type.override").get(0));
|
headers.remove("content-type.override");
|
}*/
|
|
|
}
|
|
|
public void setContentTypeOverride(@Headers Map<String, Object> headers) { |
|
|
org.apache.cxf.binding.soap.SoapMessage cxfMsg = (SoapMessage) headers.get("CamelCxfMessage"); |
|
|
SoapVersion version = (SoapVersion) cxfMsg.get("org.apache.cxf.binding.soap.SoapVersion"); |
|
|
if (version instanceof Soap11) { |
headers.put("content-type.override", ((Soap11) version).getContentType()); |
}
|
}
|
|
|
}
|