Search in sources :

Example 6 with AckRequestedType

use of org.apache.cxf.ws.rm.v200702.AckRequestedType 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 7 with AckRequestedType

use of org.apache.cxf.ws.rm.v200702.AckRequestedType in project cxf by apache.

the class Destination method ackRequested.

void ackRequested(Message message) throws SequenceFault, RMException {
    // TODO
    Collection<AckRequestedType> ars = RMContextUtils.retrieveRMProperties(message, false).getAcksRequested();
    if (null == ars) {
        return;
    }
    for (AckRequestedType ar : ars) {
        Identifier id = ar.getIdentifier();
        DestinationSequence seq = getSequence(id);
        if (null == seq) {
            continue;
        }
        ackImmediately(seq, message);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType)

Example 8 with AckRequestedType

use of org.apache.cxf.ws.rm.v200702.AckRequestedType in project cxf by apache.

the class EncoderDecoder method buildHeaders.

/**
 * Builds an element containing WS-RM headers. This adds the appropriate WS-RM namespace declaration to the element,
 * and then adds any WS-RM headers set in the supplied properties as child elements.
 *
 * @param rmps
 * @param qname constructed element name
 * @return element (<code>null</code> if none)
 */
public void buildHeaders(RMProperties rmps, List<Header> headers) throws JAXBException {
    // check if there's anything to insert
    SequenceType seq = rmps.getSequence();
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    Collection<AckRequestedType> reqs = rmps.getAcksRequested();
    if (seq == null && acks == null && reqs == null) {
        return;
    }
    buildHeaders(seq, acks, reqs, rmps.isLastMessage(), headers);
}
Also used : AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 9 with AckRequestedType

use of org.apache.cxf.ws.rm.v200702.AckRequestedType in project cxf by apache.

the class EncoderDecoder10AImpl method buildHeaders.

@Override
protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement> acks, Collection<AckRequestedType> reqs, boolean last, List<Header> headers) throws JAXBException {
    if (null != seq) {
        LOG.log(Level.FINE, "encoding sequence into RM header");
        org.apache.cxf.ws.rm.v200502wsa15.SequenceType toseq = VersionTransformer.convert200502wsa15(seq);
        if (last) {
            toseq.setLastMessage(new org.apache.cxf.ws.rm.v200502wsa15.SequenceType.LastMessage());
        }
        JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> element = RMUtils.getWSRM200502WSA200508Factory().createSequence(toseq);
        headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
    }
    if (null != acks) {
        LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
        for (SequenceAcknowledgement ack : acks) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.SEQUENCE_ACK_NAME), VersionTransformer.convert200502wsa15(ack), getDataBinding()));
        }
    }
    if (null != reqs) {
        LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
        for (AckRequestedType req : reqs) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.ACK_REQUESTED_NAME), RMUtils.getWSRM200502WSA200508Factory().createAckRequested(VersionTransformer.convert200502wsa15(req)), getDataBinding()));
        }
    }
}
Also used : QName(javax.xml.namespace.QName) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) SoapHeader(org.apache.cxf.binding.soap.SoapHeader) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 10 with AckRequestedType

use of org.apache.cxf.ws.rm.v200702.AckRequestedType in project cxf by apache.

the class EncoderDecoder10Impl method buildHeaders.

@Override
protected void buildHeaders(SequenceType seq, Collection<SequenceAcknowledgement> acks, Collection<AckRequestedType> reqs, boolean last, List<Header> headers) throws JAXBException {
    if (null != seq) {
        LOG.log(Level.FINE, "encoding sequence into RM header");
        org.apache.cxf.ws.rm.v200502.SequenceType toseq = VersionTransformer.convert200502(seq);
        if (last) {
            toseq.setLastMessage(new org.apache.cxf.ws.rm.v200502.SequenceType.LastMessage());
        }
        JAXBElement<?> element = RMUtils.getWSRM200502Factory().createSequence(toseq);
        headers.add(new SoapHeader(element.getName(), element, getDataBinding(), true));
    }
    if (null != acks) {
        LOG.log(Level.FINE, "encoding sequence acknowledgement(s) into RM header");
        for (SequenceAcknowledgement ack : acks) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.SEQUENCE_ACK_NAME), VersionTransformer.convert200502(ack), getDataBinding()));
        }
    }
    if (null != reqs) {
        LOG.log(Level.FINE, "encoding acknowledgement request(s) into RM header");
        for (AckRequestedType req : reqs) {
            headers.add(new SoapHeader(new QName(getConstants().getWSRMNamespace(), RMConstants.ACK_REQUESTED_NAME), RMUtils.getWSRM200502Factory().createAckRequested(VersionTransformer.convert200502(req)), getDataBinding()));
        }
    }
}
Also used : QName(javax.xml.namespace.QName) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) SoapHeader(org.apache.cxf.binding.soap.SoapHeader) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Aggregations

AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)14 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)5 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)4 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)4 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)4 Unmarshaller (javax.xml.bind.Unmarshaller)3 QName (javax.xml.namespace.QName)3 SoapHeader (org.apache.cxf.binding.soap.SoapHeader)3 ArrayList (java.util.ArrayList)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)2 RMProperties (org.apache.cxf.ws.rm.RMProperties)2 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)2 Test (org.junit.Test)2 JAXBException (javax.xml.bind.JAXBException)1 Header (org.apache.cxf.headers.Header)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 EncoderDecoder (org.apache.cxf.ws.rm.EncoderDecoder)1 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)1 RMConfiguration (org.apache.cxf.ws.rm.RMConfiguration)1