use of org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor in project cxf by apache.
the class SoapBindingFactory method setupUDP.
protected void setupUDP(InterceptorProvider p, EndpointInfo ei) {
// soap UDP requires ws-addressing turned on
WSAddressingFeature add = new WSAddressingFeature();
add.setAddressingRequired(true);
add.initialize(p, bus);
// UDP has a strict size limit on messages (<64K) so we'll try to shrink the
// message a little by putting the WSA namespace into the
// the soap:env which allows it to not be written on every header
// element as well as disable the output stream optimizations (doesn't really
// matter on such small messages anyway) to make sure we pickup those
// namespaces that are declared there.
p.getOutInterceptors().add(new AbstractSoapInterceptor(Phase.POST_LOGICAL) {
public void handleMessage(SoapMessage message) throws Fault {
AddressingProperties p = ContextUtils.retrieveMAPs(message, false, true);
if (p == null) {
return;
}
String ns = p.getNamespaceURI();
Map<String, String> nsMap = message.getEnvelopeNs();
if (nsMap == null) {
nsMap = new HashMap<>();
} else {
nsMap = new HashMap<>(nsMap);
}
message.put("soap.env.ns.map", nsMap);
if (!nsMap.containsValue(ns) && !nsMap.containsKey("wsa")) {
nsMap.put("wsa", ns);
}
message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION, Boolean.TRUE);
}
});
// don't send the optional ReplyTo headers if we don't need to either
ei.setProperty("ws-addressing.write.optional.replyto", Boolean.FALSE);
}
Aggregations