use of org.apache.cxf.ws.rm.RMException in project cxf by apache.
the class RetransmissionQueueImpl method cacheUnacknowledged.
/**
* Accepts a new resend candidate.
*
* @param message the message object.
* @return ResendCandidate
*/
protected ResendCandidate cacheUnacknowledged(Message message) {
RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
SequenceType st = rmps.getSequence();
Identifier sid = st.getIdentifier();
String key = sid.getValue();
final ResendCandidate candidate;
synchronized (this) {
List<ResendCandidate> sequenceCandidates = getSequenceCandidates(key);
if (null == sequenceCandidates) {
sequenceCandidates = new ArrayList<>();
candidates.put(key, sequenceCandidates);
}
candidate = createResendCandidate(message);
if (isSequenceSuspended(key)) {
candidate.suspend();
}
sequenceCandidates.add(candidate);
unacknowledgedCount++;
}
LOG.fine("Cached unacknowledged message.");
try {
RMEndpoint rme = manager.getReliableEndpoint(message);
rme.handleAccept(key, st.getMessageNumber(), message);
} catch (RMException e) {
LOG.log(Level.WARNING, "Could not find reliable endpoint for message");
}
return candidate;
}
use of org.apache.cxf.ws.rm.RMException in project cxf by apache.
the class RMSoapInInterceptor method updateServiceModelInfo.
/**
* When invoked inbound, check if the action indicates that this is one of the
* RM protocol messages (CreateSequence, CreateSequenceResponse, TerminateSequence)
* and if so, replace references to the application service model with references to
* the RM service model.
* The addressing protocol handler must have extracted the action beforehand.
* @see org.apache.cxf.transport.ChainInitiationObserver
*
* @param message the message
*/
private void updateServiceModelInfo(SoapMessage message) throws Fault {
AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false);
AttributedURIType actionURI = null == maps ? null : maps.getAction();
String action = null == actionURI ? null : actionURI.getValue().trim();
LOG.fine("action: " + action);
RMConstants consts;
if (RM10Constants.ACTIONS.contains(action)) {
consts = RM10Constants.INSTANCE;
} else if (RM11Constants.ACTIONS.contains(action)) {
consts = RM11Constants.INSTANCE;
} else {
return;
}
RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
rmps.exposeAs(consts.getWSRMNamespace());
ProtocolVariation protocol = ProtocolVariation.findVariant(consts.getWSRMNamespace(), maps.getNamespaceURI());
LOG.info("Updating service model info in exchange");
RMManager manager = getManager(message);
assert manager != null;
final RMEndpoint rme;
try {
rme = manager.getReliableEndpoint(message);
} catch (RMException e) {
throw new SoapFault(new org.apache.cxf.common.i18n.Message("CANNOT_PROCESS", LOG), e, message.getVersion().getSender());
}
Exchange exchange = message.getExchange();
Endpoint ep = rme.getEndpoint(protocol);
exchange.put(Endpoint.class, ep);
exchange.put(Service.class, ep.getService());
exchange.put(Binding.class, ep.getBinding());
// Also set BindingOperationInfo as some operations (SequenceAcknowledgment) have
// neither in nor out messages, and thus the WrappedInInterceptor cannot
// determine the operation name.
BindingInfo bi = ep.getEndpointInfo().getBinding();
BindingOperationInfo boi = null;
boolean isOneway = true;
if (consts.getCreateSequenceAction().equals(action)) {
if (RMContextUtils.isServerSide(message)) {
boi = bi.getOperation(consts.getCreateSequenceOperationName());
isOneway = false;
} else {
boi = bi.getOperation(consts.getCreateSequenceOnewayOperationName());
}
} else if (consts.getCreateSequenceResponseAction().equals(action)) {
if (RMContextUtils.isServerSide(message)) {
boi = bi.getOperation(consts.getCreateSequenceResponseOnewayOperationName());
} else {
boi = bi.getOperation(consts.getCreateSequenceOperationName());
isOneway = false;
}
} else if (consts.getSequenceAckAction().equals(action)) {
boi = bi.getOperation(consts.getSequenceAckOperationName());
} else if (consts.getAckRequestedAction().equals(action)) {
boi = bi.getOperation(consts.getAckRequestedOperationName());
} else if (consts.getTerminateSequenceAction().equals(action)) {
boi = bi.getOperation(consts.getTerminateSequenceOperationName());
} else if (RM11Constants.INSTANCE.getTerminateSequenceResponseAction().equals(action)) {
// TODO add server-side TSR handling
boi = bi.getOperation(RM11Constants.INSTANCE.getTerminateSequenceOperationName());
isOneway = false;
} else if (consts.getCloseSequenceAction().equals(action)) {
boi = bi.getOperation(consts.getCloseSequenceOperationName());
} else if (RM11Constants.INSTANCE.getCloseSequenceResponseAction().equals(action)) {
boi = bi.getOperation(RM11Constants.INSTANCE.getCloseSequenceOperationName());
isOneway = false;
}
// make sure the binding information has been set
if (boi == null) {
LOG.fine("No BindingInfo for action " + action);
} else {
exchange.put(BindingOperationInfo.class, boi);
exchange.setOneWay(isOneway);
}
if (!consts.getCreateSequenceResponseAction().equals(action) && !consts.getSequenceAckAction().equals(action) && !RM11Constants.INSTANCE.getTerminateSequenceResponseAction().equals(action) && !RM11Constants.INSTANCE.getCloseSequenceResponseAction().equals(action)) {
LOG.fine("Changing requestor role from " + message.get(Message.REQUESTOR_ROLE) + " to false");
Object originalRequestorRole = message.get(Message.REQUESTOR_ROLE);
if (null != originalRequestorRole) {
message.put(RMMessageConstants.ORIGINAL_REQUESTOR_ROLE, originalRequestorRole);
}
message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
}
// replace WrappedInInterceptor with BareInInterceptor if necessary
// as RM protocol messages use parameter style BARE
InterceptorChain chain = message.getInterceptorChain();
ListIterator<Interceptor<? extends Message>> it = chain.getIterator();
boolean bareIn = false;
boolean wrappedIn = false;
while (it.hasNext() && !wrappedIn && !bareIn) {
PhaseInterceptor<? extends Message> pi = (PhaseInterceptor<? extends Message>) it.next();
if (BareInInterceptor.class.getName().equals(pi.getId())) {
bareIn = true;
}
}
if (!bareIn) {
chain.add(new BareInInterceptor());
LOG.fine("Added BareInInterceptor to chain.");
}
}
use of org.apache.cxf.ws.rm.RMException in project cxf by apache.
the class ProtocolVariationsTest method testInvalidRM11WSA200408.
@Test
public void testInvalidRM11WSA200408() throws Exception {
init("org/apache/cxf/systest/ws/rm/rminterceptors.xml", false);
// WS-RM 1.1, but using the WS-A 1.0 namespace
Client client = ClientProxy.getClient(greeter);
client.getRequestContext().put(RMManager.WSRM_VERSION_PROPERTY, RM11Constants.NAMESPACE_URI);
client.getRequestContext().put(RMManager.WSRM_WSA_VERSION_PROPERTY, Names200408.WSA_NAMESPACE_NAME);
try {
greeter.greetMe("one");
fail("invalid namespace combination accepted");
} catch (Exception e) {
assertTrue(e.getCause() instanceof RMException);
// verify a partial error text match to exclude an unexpected exception
// (see UNSUPPORTED_NAMESPACE in Messages.properties)
final String text = Names200408.WSA_NAMESPACE_NAME + " is not supported";
assertTrue(e.getCause().getMessage() != null && e.getCause().getMessage().indexOf(text) >= 0);
}
}
Aggregations