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);
}
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());
}
}
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);
}
}
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());
}
}
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();
}
Aggregations