public void handleMessage(Message message) throws Fault { W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class); XMLStreamWriter origWriter = (XMLStreamWriter)message .get(LogicalHandlerOutInterceptor.ORIGINAL_WRITER); XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER"); SOAPMessage origMessage = null; if (reader != null) { message.getInterceptorChain().abort(); if (!message.getExchange().isOneWay()) { Endpoint e = message.getExchange().getEndpoint(); Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); MessageObserver observer = message.getExchange() .get(MessageObserver.class); if (observer != null) {
= ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures(); List<Feature> allFeatures; if (client.getBus().getFeatures() != null) { allFeatures = new ArrayList<>(endpointFeatures.size() + client.getBus().getFeatures().size()); allFeatures.addAll(endpointFeatures); allFeatures.addAll(client.getBus().getFeatures()); } else { allFeatures = endpointFeatures; client.getEndpoint().getBinding().getBindingInfo(), hasOpName); if (findDispatchOp && !payloadOPMap.isEmpty()) { QName payloadElementName = null; client.getEndpoint().getBinding().getBindingInfo(), hasOpName); BindingOperationInfo dbop = client.getEndpoint().getBinding().getBindingInfo() .getOperation(dispatchedOpName); if (dbop != null) { opName = dispatchedOpName;
public void handleMessage(Message message) throws Fault { W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class); XMLStreamWriter origWriter = (XMLStreamWriter)message .get(LogicalHandlerFaultOutInterceptor.ORIGINAL_WRITER); boolean requestor = isRequestor(message); XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER"); SOAPMessage origMessage = null; if (reader != null) { FaultMode mode = message.get(FaultMode.class); Message faultMessage = exchange.getOutMessage(); if (null == faultMessage) { faultMessage = new MessageImpl(); faultMessage.setExchange(message.getExchange()); faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage); faultMessage.setContent(Exception.class, ex); faultMessage.put(FaultMode.class, mode); exchange.setOutMessage(null); exchange.setOutFaultMessage(faultMessage);
public void handleMessage(Message message) throws Fault { String action = (String)message.get(SoapBindingConstants.SOAP_ACTION); if (action == null) { AddressingProperties inProps = (AddressingProperties)message .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND); if (inProps != null && inProps.getAction() != null) { action = inProps.getAction().getValue(); } } if ("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get".equals(action) || "http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata/Request".equals(action)) { message.remove(AssertionInfoMap.class.getName()); Exchange ex = message.getExchange(); Endpoint endpoint = createEndpoint(message); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.put(BindingOperationInfo.class, endpoint.getBinding().getBindingInfo() .getOperation(new QName("http://mex.ws.cxf.apache.org/", "Get2004"))); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); message.getInterceptorChain().add(endpoint.getInInterceptors()); message.getInterceptorChain().add(endpoint.getBinding().getInInterceptors()); } }
private void handleAbort(Message message, W3CDOMStreamWriter writer) { message.getInterceptorChain().abort(); if (!message.getExchange().isOneWay()) { //server side inbound Endpoint e = message.getExchange().getEndpoint(); Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); message.getExchange().setOutMessage(responseMsg); XMLStreamReader reader = message.getContent(XMLStreamReader.class); if (reader == null && writer != null) { reader = StaxUtils.createXMLStreamReader(writer.getDocument()); } InterceptorChain chain = OutgoingChainInterceptor .getOutInterceptorChain(message.getExchange()); responseMsg.setInterceptorChain(chain); responseMsg.put("LogicalHandlerInterceptor.INREADER", reader); chain.doIntercept(responseMsg); } }
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); Set<Endpoint> endpoints = CastUtils.cast((Set<?>)ex.get(MultipleEndpointObserver.ENDPOINTS)); Endpoint ep = selectEndpoint(message, endpoints); if (ep == null) { return; } ex.put(Endpoint.class, ep); ex.put(Binding.class, ep.getBinding()); ex.put(Service.class, ep.getService()); InterceptorChain chain = message.getInterceptorChain(); chain.add(ep.getInInterceptors()); chain.add(ep.getBinding().getInInterceptors()); chain.add(ep.getService().getInInterceptors()); chain.setFaultObserver(ep.getOutFaultObserver()); }
private Message createOutMessage(Message inMessage) { Endpoint e = inMessage.getExchange().getEndpoint(); Message mout = e.getBinding().createMessage(); mout.setExchange(inMessage.getExchange()); mout.setInterceptorChain( OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange())); inMessage.getExchange().setOutMessage(mout); inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE); return mout; } }
protected void invokeInboundChain(Exchange ex, Endpoint ep) { Message m = getInBoundMessage(ex); Message inMsg = ep.getBinding().createMessage(); MessageImpl.copyContent(m, inMsg); //Copy Response Context to Client inBound Message //TODO a Context Filter Strategy required. inMsg.putAll(m); inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE); inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE); inMsg.setExchange(ex); Exception exc = inMsg.getContent(Exception.class); if (exc != null) { ex.setInFaultMessage(inMsg); ColocInFaultObserver observer = new ColocInFaultObserver(bus); observer.onMessage(inMsg); } else { //Handle Response ex.setInMessage(inMsg); PhaseManager pm = bus.getExtension(PhaseManager.class); SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases()); ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE); InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases); inMsg.setInterceptorChain(chain); chain.doIntercept(inMsg); } ex.put(ClientImpl.FINISHED, Boolean.TRUE); }
public void handleMessage(Message message) { if (isGET(message) && message.getContent(List.class) != null) { LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method"); return; MessageContentsList parameters = new MessageContentsList(); Exchange exchange = message.getExchange(); BindingOperationInfo bop = exchange.get(BindingOperationInfo.class); Endpoint ep = exchange.get(Endpoint.class); bop = ep.getBinding().getBindingInfo().getOperations().iterator().next(); message.getExchange().put(BindingOperationInfo.class, bop);
public void handleMessage(Message message) { if (isGET(message) && message.getContent(List.class) != null) { LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method"); return; MessageContentsList parameters = new MessageContentsList(); Exchange exchange = message.getExchange(); BindingOperationInfo bop = exchange.getBindingOperationInfo(); Endpoint ep = exchange.getEndpoint(); bop = ep.getBinding().getBindingInfo().getOperations().iterator().next(); message.getExchange().put(BindingOperationInfo.class, bop);
protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) { Endpoint e = ex.getEndpoint(); Client c = ex.get(Client.class); chain.add(getBus().getOutFaultInterceptors()); if (c != null) { chain.add(c.getOutFaultInterceptors()); } chain.add(e.getService().getOutFaultInterceptors()); chain.add(e.getOutFaultInterceptors()); chain.add(e.getBinding().getOutFaultInterceptors()); if (e.getService().getDataBinding() instanceof InterceptorProvider) { chain.add(((InterceptorProvider)e.getService().getDataBinding()).getOutFaultInterceptors()); } addToChain(chain, ex.getInMessage()); addToChain(chain, ex.getOutFaultMessage()); } private void addToChain(PhaseInterceptorChain chain, Message m) {
protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) { Endpoint e = ex.getEndpoint(); Client c = ex.get(Client.class); InterceptorProvider ip = ex.get(InterceptorProvider.class); chain.add(getBus().getInFaultInterceptors()); if (c != null) { chain.add(c.getInFaultInterceptors()); } else if (ip != null) { chain.add(ip.getInFaultInterceptors()); } chain.add(e.getService().getInFaultInterceptors()); chain.add(e.getInFaultInterceptors()); chain.add(e.getBinding().getInFaultInterceptors()); if (e.getService().getDataBinding() instanceof InterceptorProvider) { chain.add(((InterceptorProvider)e.getService().getDataBinding()).getInFaultInterceptors()); } addToChain(chain, ex.getInFaultMessage()); addToChain(chain, ex.getOutMessage()); } private void addToChain(PhaseInterceptorChain chain, Message m) {
message.getInterceptorChain().abort(); MessageObserver observer = message.getExchange().get(MessageObserver.class); if (!message.getExchange().isOneWay() && observer != null) { Endpoint e = message.getExchange().getEndpoint(); Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(soapMessage); responseMsg.setContent(XMLStreamReader.class, xmlReader); responseMsg.put(InterceptorChain.STARTING_AT_INTERCEPTOR_ID, Endpoint e = message.getExchange().getEndpoint(); if (!message.getExchange().isOneWay()) { Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); message.getExchange().setOutMessage(responseMsg); SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();
public static InterceptorChain getOutInterceptorChain(Exchange ex) { Bus bus = ex.get(Bus.class); Binding binding = ex.get(Binding.class); PhaseManager pm = bus.getExtension(PhaseManager.class); PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases()); Endpoint ep = ex.get(Endpoint.class); List<Interceptor<? extends Message>> il = ep.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + il); il = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); il = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); il = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + il); chain.setFaultObserver(ep.getOutFaultObserver()); return chain;
protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) { PhaseManager pm = bus.getExtension(PhaseManager.class); List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + i1); } List<Interceptor<? extends Message>> i2 = getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by client: " + i2); } List<Interceptor<? extends Message>> i3 = endpoint.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + i3); } List<Interceptor<? extends Message>> i4 = endpoint.getBinding().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + i4); } List<Interceptor<? extends Message>> i5 = null; if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) { i5 = ((InterceptorProvider)endpoint.getService().getDataBinding()).getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by databinding: " + i5); } } if (i5 != null) { return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4, i5); } return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4); }
private Message createResponseMessage() { if (exchange == null || exchange.isOneWay()) { return null; m = exchange.getInFaultMessage(); if (m == null) { m = exchange.getInMessage(); Endpoint ep = exchange.getEndpoint(); m = new org.apache.cxf.message.MessageImpl(); m.setExchange(exchange); m = ep.getBinding().createMessage(m); exchange.setInMessage(m); Endpoint ep = exchange.getEndpoint(); m = new org.apache.cxf.message.MessageImpl(); m.setExchange(exchange); m = ep.getBinding().createMessage(m); exchange.setOutMessage(m);
private Message getOutMessage() { Message message = m.getExchange().getOutMessage(); if (message == null) { Endpoint ep = m.getExchange().getEndpoint(); message = new org.apache.cxf.message.MessageImpl(); message.setExchange(m.getExchange()); message = ep.getBinding().createMessage(message); m.getExchange().setOutMessage(message); } return message; }
@Override protected void init() { // configure handlers try { initHandlers(); } catch (Exception e) { throw new WebServiceException("Error configuring handlers", e); } BeanContext beanContext = bus.getExtension(BeanContext.class); service.setInvoker(new EJBMethodInvoker(this, this.bus, beanContext)); Endpoint endpoint = getEndpoint(); /* * Remove interceptors that perform handler processing since * handler processing must happen within the EJB container. */ removeHandlerInterceptors(bus.getInInterceptors()); removeHandlerInterceptors(endpoint.getInInterceptors()); removeHandlerInterceptors(endpoint.getBinding().getInInterceptors()); removeHandlerInterceptors(endpoint.getService().getInInterceptors()); // install SAAJ interceptor if (endpoint.getBinding() instanceof SoapBinding && !this.implInfo.isWebServiceProvider()) { endpoint.getService().getInInterceptors().add(new SAAJInInterceptor()); } }
private Message createOutMessage(Message inMessage, Response r) { Endpoint e = inMessage.getExchange().get(Endpoint.class); Message mout = new MessageImpl(); mout.setContent(List.class, new MessageContentsList(r)); mout.setExchange(inMessage.getExchange()); mout = e.getBinding().createMessage(mout); mout.setInterceptorChain( OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange())); inMessage.getExchange().setOutMessage(mout); if (r.getStatus() >= Response.Status.BAD_REQUEST.getStatusCode()) { inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE); } return mout; } }
private static InterceptorChain getRedeliveryInterceptorChain(Message m, String phase) { Exchange exchange = m.getExchange(); Endpoint ep = exchange.getEndpoint(); Bus bus = exchange.getBus(); PhaseManager pm = bus.getExtension(PhaseManager.class); SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases()); for (Iterator<Phase> it = phases.iterator(); it.hasNext();) { Phase p = it.next(); if (phase.equals(p.getName())) { break; } it.remove(); } PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); List<Interceptor<? extends Message>> il = ep.getInInterceptors(); addInterceptors(chain, il); il = ep.getService().getInInterceptors(); addInterceptors(chain, il); il = ep.getBinding().getInInterceptors(); addInterceptors(chain, il); il = bus.getInInterceptors(); addInterceptors(chain, il); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors(); addInterceptors(chain, il); } return chain; }