Search in sources :

Example 16 with RMProperties

use of org.apache.cxf.ws.rm.RMProperties in project cxf by apache.

the class RMSoapInInterceptorTest method testDecodeSequence.

@Test
public void testDecodeSequence() throws XMLStreamException {
    SoapMessage message = setUpInboundMessage("resources/Message1.xml");
    RMSoapInInterceptor codec = new RMSoapInInterceptor();
    codec.handleMessage(message);
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType st = rmps.getSequence();
    assertNotNull(st);
    assertEquals(st.getIdentifier().getValue(), SEQ_IDENTIFIER);
    assertEquals(st.getMessageNumber(), MSG1_MESSAGE_NUMBER);
    assertNull(rmps.getAcks());
    assertNull(rmps.getAcksRequested());
}
Also used : SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 17 with RMProperties

use of org.apache.cxf.ws.rm.RMProperties in project cxf by apache.

the class RMSoapOutInterceptorTest method testEncode.

@Test
public void testEncode() throws Exception {
    RMSoapOutInterceptor codec = new RMSoapOutInterceptor();
    setUpOutbound();
    SoapMessage message = setupOutboundMessage();
    // no RM headers
    codec.handleMessage(message);
    verifyHeaders(message, new String[] {});
    // one sequence header
    message = setupOutboundMessage();
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
    rmps.setSequence(s1);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_NAME });
    // one acknowledgment header
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    Collection<SequenceAcknowledgement> acks = new ArrayList<>();
    acks.add(ack1);
    rmps.setAcks(acks);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_ACK_NAME });
    // two acknowledgment headers
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    acks.add(ack2);
    rmps.setAcks(acks);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_ACK_NAME, RMConstants.SEQUENCE_ACK_NAME });
    // one ack requested header
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    Collection<AckRequestedType> requested = new ArrayList<>();
    requested.add(ar1);
    rmps.setAcksRequested(requested);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.ACK_REQUESTED_NAME });
    // two ack requested headers
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    requested.add(ar2);
    rmps.setAcksRequested(requested);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.ACK_REQUESTED_NAME, RMConstants.ACK_REQUESTED_NAME });
}
Also used : ArrayList(java.util.ArrayList) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 18 with RMProperties

use of org.apache.cxf.ws.rm.RMProperties in project cxf by apache.

the class RMSoapOutInterceptorTest method setupOutboundFaultMessage.

private SoapMessage setupOutboundFaultMessage() throws Exception {
    Exchange ex = new ExchangeImpl();
    Message message = new MessageImpl();
    RMProperties rmps = new RMProperties();
    rmps.exposeAs(RM10Constants.NAMESPACE_URI);
    RMContextUtils.storeRMProperties(message, rmps, false);
    AddressingProperties maps = new AddressingProperties();
    RMContextUtils.storeMAPs(maps, message, false, false);
    ex.setInMessage(message);
    message = new MessageImpl();
    SoapMessage soapMessage = new SoapMessage(message);
    ex.setOutFaultMessage(soapMessage);
    soapMessage.setExchange(ex);
    MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    SOAPMessage soap = factory.createMessage();
    soap.getSOAPBody().addFault();
    soapMessage.setContent(SOAPMessage.class, soap);
    return soapMessage;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) SOAPMessage(javax.xml.soap.SOAPMessage) MessageFactory(javax.xml.soap.MessageFactory) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) SOAPMessage(javax.xml.soap.SOAPMessage) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage)

Example 19 with RMProperties

use of org.apache.cxf.ws.rm.RMProperties in project cxf by apache.

the class RMSoapInInterceptor method decode.

/**
 * Decode the RM properties from protocol-specific headers
 * and store them in the message.
 *
 * @param message the SOAP mesage
 */
void decode(SoapMessage message) {
    RMProperties rmps = unmarshalRMProperties(message);
    RMContextUtils.storeRMProperties(message, rmps, false);
// TODO: decode SequenceFault ?
}
Also used : RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 20 with RMProperties

use of org.apache.cxf.ws.rm.RMProperties in project cxf by apache.

the class RedeliveryQueueImpl method getRedeliveryStatus.

public RetryStatus getRedeliveryStatus(DestinationSequence seq, long num) {
    List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(seq);
    if (null != sequenceCandidates) {
        for (int i = 0; i < sequenceCandidates.size(); i++) {
            RedeliverCandidate candidate = sequenceCandidates.get(i);
            RMProperties properties = RMContextUtils.retrieveRMProperties(candidate.getMessage(), false);
            SequenceType st = properties.getSequence();
            if (num == st.getMessageNumber()) {
                return candidate;
            }
        }
    }
    return null;
}
Also used : SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Endpoint(org.apache.cxf.endpoint.Endpoint) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Aggregations

RMProperties (org.apache.cxf.ws.rm.RMProperties)25 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)12 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)11 Message (org.apache.cxf.message.Message)10 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)8 Test (org.junit.Test)6 Endpoint (org.apache.cxf.endpoint.Endpoint)5 MessageImpl (org.apache.cxf.message.MessageImpl)4 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)4 SoapFault (org.apache.cxf.binding.soap.SoapFault)3 Exchange (org.apache.cxf.message.Exchange)3 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)3 RMEndpoint (org.apache.cxf.ws.rm.RMEndpoint)3 RMException (org.apache.cxf.ws.rm.RMException)3 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 MessageFactory (javax.xml.soap.MessageFactory)2 SOAPMessage (javax.xml.soap.SOAPMessage)2