Search in sources :

Example 86 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class MAPCodecTest method setUpOutbound.

private void setUpOutbound(Message message, boolean outbound) {
    Exchange exchange = new ExchangeImpl();
    exchange.setOutMessage(outbound ? message : new MessageImpl());
    message.setExchange(exchange);
}
Also used : Exchange(org.apache.cxf.message.Exchange) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 87 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class MEXInInterceptor method handleMessage.

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());
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 88 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class AbstractPolicyInterceptor method getTransportAssertions.

protected void getTransportAssertions(Message message) {
    Exchange ex = message.getExchange();
    Conduit conduit = ex.getConduit(message);
    Assertor assertor = PolicyUtils.createAsserter(conduit);
    if (assertor == null) {
        Destination destination = ex.getDestination();
        assertor = PolicyUtils.createAsserter(destination);
    }
    if (null != assertor) {
        assertor.assertMessage(message);
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Destination(org.apache.cxf.transport.Destination) Conduit(org.apache.cxf.transport.Conduit)

Example 89 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class Destination method acknowledge.

/**
 * Acknowledges receipt of a message. If the message is the last in the
 * sequence, sends an out-of-band SequenceAcknowledgement unless there a
 * response will be sent to the acksTo address onto which the acknowldegment
 * can be piggybacked.
 *
 * @param sequenceType the sequenceType object that includes identifier and
 *            message number (and possibly a lastMessage element) for the
 *            message to be acknowledged)
 * @param replyToAddress the replyTo address of the message that carried
 *            this sequence information
 * @throws SequenceFault if the sequence specified in
 *             <code>sequenceType</code> does not exist
 */
public void acknowledge(Message message) throws SequenceFault, RMException {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType sequenceType = rmps.getSequence();
    if (null == sequenceType) {
        return;
    }
    DestinationSequence seq = getSequence(sequenceType.getIdentifier());
    if (null != seq) {
        if (seq.applyDeliveryAssurance(sequenceType.getMessageNumber(), message)) {
            if (PropertyUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY))) {
                return;
            }
            seq.acknowledge(message);
            if (null != rmps.getCloseSequence()) {
                seq.setLastMessageNumber(sequenceType.getMessageNumber());
                ackImmediately(seq, message);
            }
        } else {
            try {
                message.getInterceptorChain().abort();
                if (seq.sendAcknowledgement()) {
                    ackImmediately(seq, message);
                }
                Exchange exchange = message.getExchange();
                Conduit conduit = exchange.getDestination().getBackChannel(message);
                if (conduit != null) {
                    // null if it knows it cannot send anything.
                    if (seq.sendAcknowledgement()) {
                        AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
                        InternalContextUtils.rebaseResponse(null, maps, message);
                    } else {
                        Message response = createMessage(exchange);
                        response.setExchange(exchange);
                        response.remove(Message.CONTENT_TYPE);
                        conduit.prepare(response);
                        conduit.close(response);
                    }
                }
            } catch (IOException e) {
                LOG.log(Level.SEVERE, e.getMessage());
                throw new RMException(e);
            }
        }
    } else {
        ProtocolVariation protocol = RMContextUtils.getProtocolVariation(message);
        RMConstants consts = protocol.getConstants();
        SequenceFaultFactory sff = new SequenceFaultFactory(consts);
        throw sff.createUnknownSequenceFault(sequenceType.getIdentifier());
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) IOException(java.io.IOException)

Example 90 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class HTTPConduitURLEasyMockTest method setUpExchange.

private void setUpExchange(Message message, boolean oneway) {
    Exchange exchange = control.createMock(Exchange.class);
    message.setExchange(exchange);
    exchange.isOneWay();
    EasyMock.expectLastCall().andReturn(oneway).anyTimes();
    exchange.isSynchronous();
    EasyMock.expectLastCall().andReturn(true).anyTimes();
    exchange.isEmpty();
    EasyMock.expectLastCall().andReturn(true).anyTimes();
}
Also used : Exchange(org.apache.cxf.message.Exchange)

Aggregations

Exchange (org.apache.cxf.message.Exchange)272 Message (org.apache.cxf.message.Message)151 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)131 MessageImpl (org.apache.cxf.message.MessageImpl)118 Test (org.junit.Test)93 Endpoint (org.apache.cxf.endpoint.Endpoint)66 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)50 QName (javax.xml.namespace.QName)42 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)33 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)32 Bus (org.apache.cxf.Bus)30 Fault (org.apache.cxf.interceptor.Fault)27 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)26 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)25 Conduit (org.apache.cxf.transport.Conduit)25 MessageContentsList (org.apache.cxf.message.MessageContentsList)22 SOAPMessage (javax.xml.soap.SOAPMessage)19 XMLStreamReader (javax.xml.stream.XMLStreamReader)19 ServerProviderFactory (org.apache.cxf.jaxrs.provider.ServerProviderFactory)19