Search in sources :

Example 1 with AbstractSoapInterceptor

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);
}
Also used : AbstractSoapInterceptor(org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) HashMap(java.util.HashMap) Fault(org.apache.cxf.interceptor.Fault) SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 AbstractSoapInterceptor (org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor)1 SoapFault (org.apache.cxf.binding.soap.wsdl.extensions.SoapFault)1 Fault (org.apache.cxf.interceptor.Fault)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)1