Java Code Examples for org.apache.cxf.ws.addressing.AddressingProperties#setReplyTo()

The following examples show how to use org.apache.cxf.ws.addressing.AddressingProperties#setReplyTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSAFromWSDLTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonAnonToAnon() throws Exception {
    try (AddNumbersPortTypeProxy port = getPort()) {
        port.getRequestContext()
            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                 "http://localhost:" + PORT + "/jaxws/addAnon");

        AddressingProperties maps = new AddressingProperties();
        EndpointReferenceType ref = new EndpointReferenceType();
        AttributedURIType add = new AttributedURIType();
        add.setValue("http://localhost:" + INVALID_PORT + "/not/a/real/url");
        ref.setAddress(add);
        maps.setReplyTo(ref);
        maps.setFaultTo(ref);

        port.getRequestContext()
            .put("javax.xml.ws.addressing.context", maps);

        try {
            port.addNumbers3(-1, 2);
        } catch (SOAPFaultException e) {
            assertTrue(e.getFault().getFaultCode().contains("OnlyAnonymousAddressSupported"));
        }
    }
}
 
Example 2
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test(expected = SoapFault.class)
public void testTwoWayRequestWithReplyToNone() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setOutMessage(message);
    message.setExchange(exchange);
    setUpMessageProperty(message,
                         REQUESTOR_ROLE,
                         Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    EndpointReferenceType replyTo = new EndpointReferenceType();
    replyTo.setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS));
    maps.setReplyTo(replyTo);
    AttributedURIType id =
        ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message,
                         ADDRESSING_PROPERTIES_OUTBOUND,
                         maps);
    setUpMessageProperty(message,
                         "org.apache.cxf.ws.addressing.map.fault.name",
                         "NoneAddress");

    aggregator.mediate(message, false);
}
 
Example 3
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testReplyToWithAnonymousAddressRetained() throws Exception {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    exchange.setOutMessage(message);
    setUpMessageProperty(message,
                         REQUESTOR_ROLE,
                         Boolean.TRUE);
    AddressingProperties maps = new AddressingProperties();
    EndpointReferenceType replyTo = new EndpointReferenceType();
    replyTo.setAddress(ContextUtils.getAttributedURI(Names.WSA_ANONYMOUS_ADDRESS));
    maps.setReplyTo(replyTo);
    AttributedURIType id =
        ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(""));
    setUpMessageProperty(message,
                         CLIENT_ADDRESSING_PROPERTIES,
                         maps);
    aggregator.mediate(message, false);
    AddressingProperties props =
        (AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
    assertSame(replyTo, props.getReplyTo());
}
 
Example 4
Source File: InternalContextUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Construct and store MAPs for partial response.
 *
 * @param partialResponse the partial response message
 * @param namespaceURI the current namespace URI
 */
private static void ensurePartialResponseMAPs(Message partialResponse,
                                             String namespaceURI) {
    // ensure there is a MAPs instance available for the outbound
    // partial response that contains appropriate To and ReplyTo
    // properties (i.e. anonymous & none respectively)
    AddressingProperties maps = new AddressingProperties();
    maps.setTo(EndpointReferenceUtils.getAnonymousEndpointReference());
    maps.setReplyTo(ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType());
    maps.getReplyTo().setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS));
    maps.setAction(ContextUtils.getAttributedURI(""));
    maps.exposeAs(namespaceURI);
    ContextUtils.storeMAPs(maps, partialResponse, true, true, false);
}
 
Example 5
Source File: InternalContextUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Construct and store MAPs for partial response.
 *
 * @param partialResponse the partial response message
 * @param namespaceURI the current namespace URI
 */
private static void ensurePartialResponseMAPs(Message partialResponse,
                                             String namespaceURI) {
    // ensure there is a MAPs instance available for the outbound
    // partial response that contains appropriate To and ReplyTo
    // properties (i.e. anonymous & none respectively)
    AddressingProperties maps = new AddressingProperties();
    maps.setTo(EndpointReferenceUtils.getAnonymousEndpointReference());
    maps.setReplyTo(ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType());
    maps.getReplyTo().setAddress(ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS));
    maps.setAction(ContextUtils.getAttributedURI(""));
    maps.exposeAs(namespaceURI);
    ContextUtils.storeMAPs(maps, partialResponse, true, true, false);
}
 
Example 6
Source File: ServantTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Message createTestCreateSequenceMessage(Expires expires, OfferType offer) {
        Message message = new MessageImpl();
        Exchange exchange = new ExchangeImpl();
        exchange.setInMessage(message);
//        exchange.setOutMessage(new MessageImpl());

        message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);

        AddressingProperties maps = new AddressingProperties();
        String msgId = "urn:uuid:12345-" + Math.random();
        AttributedURIType id = ContextUtils.getAttributedURI(msgId);
        maps.setMessageID(id);

        maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getCreateSequenceAction()));
        maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));

        maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));

        message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);

        CreateSequenceType cs = new CreateSequenceType();
        cs.setAcksTo(org.apache.cxf.ws.addressing.VersionTransformer
            .convert(RMUtils.createReference(DECOUPLED_URL)));

        cs.setExpires(expires);
        cs.setOffer(offer);

        MessageContentsList contents = new MessageContentsList();
        contents.add(cs);
        message.setContent(List.class, contents);

        RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM10WSA200408);

        return message;
    }
 
Example 7
Source File: ServantTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Message createTestTerminateSequenceMessage(String sidstr, ProtocolVariation protocol) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);

    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);

    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);

    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));

    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));

    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);

    TerminateSequenceType ts = new TerminateSequenceType();
    Identifier sid = new Identifier();
    sid.setValue(sidstr);
    ts.setIdentifier(sid);
    Object tst = ProtocolVariation.RM10WSA200408.getWSRMNamespace().equals(protocol.getWSRMNamespace())
        ? ts : ProtocolVariation.RM10WSA200408.getCodec().convertReceivedTerminateSequence(ts);
    MessageContentsList contents = new MessageContentsList();
    contents.add(tst);
    message.setContent(List.class, contents);

    RMContextUtils.setProtocolVariation(message, protocol);

    return message;
}
 
Example 8
Source File: ServantTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Message createTestCloseSequenceMessage(String sidstr) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);

    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);

    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);

    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));

    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));

    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);

    CloseSequenceType cs = new CloseSequenceType();
    org.apache.cxf.ws.rm.v200702.Identifier sid = new  org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue(sidstr);
    cs.setIdentifier(sid);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);

    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);

    return message;
}
 
Example 9
Source File: RMOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private AddressingProperties createMAPs(String action, String to, String replyTo) {
    AddressingProperties maps = new AddressingProperties();
    AttributedURIType actionuri = new AttributedURIType();
    actionuri.setValue(action);
    maps.setAction(actionuri);
    maps.setTo(RMUtils.createReference(to));
    EndpointReferenceType epr = RMUtils.createReference(replyTo);
    maps.setReplyTo(epr);
    return maps;

}
 
Example 10
Source File: MAPCodecTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private AddressingProperties getMAPs(boolean requestor, boolean outbound, String uri) {
    AddressingProperties maps = new AddressingProperties();
    boolean exposeAsNative = Names.WSA_NAMESPACE_NAME.equals(uri);
    boolean exposeAs200408 = Names200408.WSA_NAMESPACE_NAME.equals(uri);
    boolean exposeAs200403 = Names200403.WSA_NAMESPACE_NAME.equals(uri);

    AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
    maps.setMessageID(id);
    AttributedURIType to = ContextUtils.getAttributedURI("foobar");
    EndpointReferenceType toEpr = EndpointReferenceUtils.getEndpointReference(to);
    maps.setTo(toEpr);
    EndpointReferenceType replyTo = new EndpointReferenceType();
    String anonymous = exposeAsNative ? Names.WSA_ANONYMOUS_ADDRESS : exposeAs200408
        ? Names200408.WSA_ANONYMOUS_ADDRESS
        : Names200403.WSA_ANONYMOUS_ADDRESS;
    replyTo.setAddress(ContextUtils.getAttributedURI(anonymous));
    maps.setReplyTo(replyTo);
    EndpointReferenceType from = EndpointReferenceUtils.getEndpointReference("snafu");
    maps.setFrom(from);
    EndpointReferenceType faultTo = new EndpointReferenceType();
    anonymous = exposeAsNative ? Names.WSA_ANONYMOUS_ADDRESS : exposeAs200408
        ? Names200408.WSA_ANONYMOUS_ADDRESS
        : Names200403.WSA_ANONYMOUS_ADDRESS;
    faultTo.setAddress(ContextUtils.getAttributedURI(anonymous));
    maps.setFaultTo(faultTo);
    RelatesToType relatesTo = null;
    if (expectRelatesTo) {
        String correlationID = "urn:uuid:67890";
        relatesTo = new RelatesToType();
        relatesTo.setValue(correlationID);
        maps.setRelatesTo(relatesTo);
        if (nonReplyRelationship == null) {
            correlatedExchange = new ExchangeImpl();
            codec.uncorrelatedExchanges.put(correlationID, correlatedExchange);
        } else {
            relatesTo.setRelationshipType(nonReplyRelationship);
        }
    }
    AttributedURIType action = ContextUtils.getAttributedURI("http://foo/bar/SEI/opRequest");
    maps.setAction(action);
    maps.exposeAs(uri);
    expectedNamespaceURI = uri;

    expectedNames = new QName[] {
        new QName(uri, Names.WSA_ACTION_NAME),
        new QName(uri, Names.WSA_MESSAGEID_NAME),
        new QName(uri, Names.WSA_TO_NAME),
        new QName(uri, Names.WSA_REPLYTO_NAME),
        new QName(uri, Names.WSA_RELATESTO_NAME),
        new QName(uri, Names.WSA_FROM_NAME),
        new QName(uri, Names.WSA_FAULTTO_NAME),
    };
    if (exposeAsNative) {
        expectedValues = new Object[] {
            action, id, to, replyTo, relatesTo, from, faultTo
        };
    } else if (exposeAs200408) {
        expectedValues = new Object[] {
            org.apache.cxf.ws.addressing.VersionTransformer.convert(action),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(id),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(to),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(replyTo),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(relatesTo),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(from),
            org.apache.cxf.ws.addressing.VersionTransformer.convert(faultTo),
        };
        if (!outbound) {
            // conversion from 2004/08 to 2005/08 anonymous address
            // occurs transparently in VersionTransformer
            Names200408.EPR_TYPE.cast(expectedValues[3]).getAddress()
                .setValue(Names.WSA_ANONYMOUS_ADDRESS);
            Names200408.EPR_TYPE.cast(expectedValues[5]).getAddress()
                .setValue(Names.WSA_ANONYMOUS_ADDRESS);
        }
    } else if (exposeAs200403) {
        expectedValues = new Object[] {
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(action),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(id),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(to),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(replyTo),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(relatesTo),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(from),
            org.apache.cxf.ws.addressing.VersionTransformer.convertTo200403(faultTo),
        };
        if (!outbound) {
            // conversion from 2004/03 to 2005/08 anonymous address
            // occurs transparently in VersionTransformer
            Names200403.EPR_TYPE.cast(expectedValues[3]).getAddress()
                .setValue(Names.WSA_ANONYMOUS_ADDRESS);
            Names200403.EPR_TYPE.cast(expectedValues[5]).getAddress()
                .setValue(Names.WSA_ANONYMOUS_ADDRESS);
        }
    } else {
        fail("unexpected namespace URI: " + uri);
    }
    return maps;
}
 
Example 11
Source File: MAPAggregatorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void setUpResponder(Message message,
                            Exchange exchange,
                            SetupResponderArgs args,
                            Endpoint endpoint) throws Exception {

    setUpMessageProperty(message,
                         REQUESTOR_ROLE,
                         Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    EndpointReferenceType replyTo = new EndpointReferenceType();
    replyTo.setAddress(
        ContextUtils.getAttributedURI(args.decoupled
                                      ? "http://localhost:9999/decoupled"
                                      : Names.WSA_ANONYMOUS_ADDRESS));
    maps.setReplyTo(replyTo);
    EndpointReferenceType faultTo = new EndpointReferenceType();
    faultTo.setAddress(
        ContextUtils.getAttributedURI(args.decoupled
                                      ? "http://localhost:9999/fault"
                                      : Names.WSA_ANONYMOUS_ADDRESS));
    maps.setFaultTo(faultTo);

    if (!args.noMessageId) {
        AttributedURIType id =
            ContextUtils.getAttributedURI("urn:uuid:12345");
        maps.setMessageID(id);
    }

    if (args.zeroLengthAction) {
        maps.setAction(ContextUtils.getAttributedURI(""));
    }
    setUpMessageProperty(message,
                         ADDRESSING_PROPERTIES_INBOUND,
                         maps);
    if (!args.outbound) {
        setUpOneway(message, exchange, args.oneway);
        if (args.oneway || args.decoupled) {
            setUpRebase(message, exchange, endpoint);
        }
    }

    if (args.outbound || ((DefaultMessageIdCache) aggregator.getMessageIdCache())
        .getMessageIdSet().size() > 0) {
        if (!args.zeroLengthAction) {
            Method method = SEI.class.getMethod("op", new Class[0]);
            setUpMethod(message, exchange, method);
            setUpMessageProperty(message,
                                 REQUESTOR_ROLE,
                                 Boolean.FALSE);

            if (args.fault) {
                message.setContent(Exception.class, new SoapFault("blah",
                        new Exception(), Fault.FAULT_CODE_SERVER));
                expectedAction = "http://foo/bar/SEI/op/Fault/Exception";
            } else {
                expectedAction = "http://foo/bar/SEI/opResponse";
            }
        }
        setUpMessageProperty(message,
                             REQUESTOR_ROLE,
                             Boolean.FALSE);
        setUpMessageProperty(message,
                             ADDRESSING_PROPERTIES_INBOUND,
                             maps);
        if (args.fault) {
            // REVISIT test double rebase does not occur
            setUpRebase(message, exchange, endpoint);
        }
        expectedTo = args.decoupled
                     ? args.fault
                       ? "http://localhost:9999/fault"
                       : "http://localhost:9999/decoupled"
                     : Names.WSA_ANONYMOUS_ADDRESS;

        if (maps.getMessageID() != null && maps.getMessageID().getValue() != null) {
            expectedRelatesTo = maps.getMessageID().getValue();
        } else {
            expectedRelatesTo = Names.WSA_UNSPECIFIED_RELATIONSHIP;
        }
        // Now verified via verifyMessage()
        //EasyMock.eq(SERVER_ADDRESSING_PROPERTIES_OUTBOUND);
        //EasyMock.reportMatcher(new MAPMatcher());
        //message.put(SERVER_ADDRESSING_PROPERTIES_OUTBOUND,
        //            new AddressingPropertiesImpl());
        //EasyMock.expectLastCall().andReturn(null);
    }
}