org.apache.cxf.ws.addressing.AddressingProperties Java Examples

The following examples show how to use org.apache.cxf.ws.addressing.AddressingProperties. 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: MAPAggregatorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean compareExpected(AddressingProperties other) {
    boolean ret = false;
    if (expectedMAPs == null || expectedMAPs == other) {
        boolean toOK =
            expectedTo == null
            || expectedTo.equals(other.getTo().getValue());
        boolean replyToOK =
            expectedReplyTo == null
            || expectedReplyTo.equals(
                   other.getReplyTo().getAddress().getValue());
        boolean relatesToOK =
            expectedRelatesTo == null
            || expectedRelatesTo.equals(
                   other.getRelatesTo().getValue());
        boolean actionOK =
            expectedAction == null
            || expectedAction.equals(other.getAction().getValue());
        boolean messageIdOK = other.getMessageID() != null;
        ret = toOK
              && replyToOK
              && relatesToOK
              && actionOK
              && messageIdOK;
    }
    return ret;
}
 
Example #2
Source File: IssuedTokenInterceptorProvider.java    From steady with Apache License 2.0 6 votes vote down vote up
private SecurityToken getTokenFromSTS(
    Message message,
    STSClient client,
    AssertionInfoMap aim,
    AddressingProperties maps,
    IssuedToken itok,
    String appliesTo
) throws Exception {
    client.setTrust(getTrust10(aim));
    client.setTrust(getTrust13(aim));
    client.setTemplate(itok.getRstTemplate());
    if (maps == null) {
        return client.requestSecurityToken();
    } else {
        client.setAddressingNamespace(maps.getNamespaceURI());
        return client.requestSecurityToken(appliesTo);
    }
}
 
Example #3
Source File: RMSoapOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Encode the current RM properties in protocol-specific headers.
 *
 * @param message the SOAP message.
 * @param rmps the current RM properties.
 */
public static void encode(SoapMessage message, RMProperties rmps) {
    if (null == rmps) {
        return;
    }
    LOG.log(Level.FINE, "encoding RMPs in SOAP headers");
    try {

        AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, true);
        ProtocolVariation protocol = ProtocolVariation.findVariant(rmps.getNamespaceURI(), maps.getNamespaceURI());
        List<Header> headers = message.getHeaders();
        int startSize = headers.size();
        protocol.getCodec().buildHeaders(rmps, headers);
        if (startSize != headers.size() && MessageUtils.isPartialResponse(message)) {
            // make sure the response is returned as HTTP 200 and not 202
            message.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);
        }
    } catch (JAXBException je) {
        LOG.log(Level.WARNING, "SOAP_HEADER_ENCODE_FAILURE_MSG", je);
    }
}
 
Example #4
Source File: RMSoapOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Encode the SequenceFault in protocol-specific header.
 *
 * @param message the SOAP message.
 * @param sf the SequenceFault.
 */
public static void encodeFault(SoapMessage message, SequenceFault sf) {
    LOG.log(Level.FINE, "Encoding SequenceFault in SOAP header");
    try {
        Message inmsg = message.getExchange().getInMessage();
        RMProperties rmps = RMContextUtils.retrieveRMProperties(inmsg, false);
        AddressingProperties maps = RMContextUtils.retrieveMAPs(inmsg, false, false);
        ProtocolVariation protocol = ProtocolVariation.findVariant(rmps.getNamespaceURI(),
            maps.getNamespaceURI());
        Header header = protocol.getCodec().buildHeaderFault(sf);
        List<Header> headers = message.getHeaders();
        headers.add(header);
    } catch (JAXBException je) {
        LOG.log(Level.WARNING, "SOAP_HEADER_ENCODE_FAILURE_MSG", je);
    }
}
 
Example #5
Source File: SoapFaultFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
Fault createSoap12Fault(SequenceFault sf, Message msg) {
    SoapFault fault = (SoapFault)createSoap11Fault(sf);
    fault.setSubCode(sf.getFaultCode());
    Object detail = sf.getDetail();
    if (null == detail) {
        return fault;
    }

    try {
        RMProperties rmps = RMContextUtils.retrieveRMProperties(msg, false);
        AddressingProperties maps = RMContextUtils.retrieveMAPs(msg, false, false);
        EncoderDecoder codec = ProtocolVariation.findVariant(rmps.getNamespaceURI(),
            maps.getNamespaceURI()).getCodec();
        setDetail(fault, detail, codec);
    } catch (Exception ex) {
        LogUtils.log(LOG, Level.SEVERE, "MARSHAL_FAULT_DETAIL_EXC", ex);
        ex.printStackTrace();
    }
    return fault;
}
 
Example #6
Source File: RMSoapInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private SoapMessage setUpInboundMessage(String resource) throws XMLStreamException {
    Message message = new MessageImpl();
    SoapMessage soapMessage = new SoapMessage(message);
    RMProperties rmps = new RMProperties();
    rmps.exposeAs(RM10Constants.NAMESPACE_URI);
    RMContextUtils.storeRMProperties(soapMessage, rmps, false);
    AddressingProperties maps = new AddressingProperties();
    RMContextUtils.storeMAPs(maps, soapMessage, false, false);
    message.put(Message.SCHEMA_VALIDATION_ENABLED, false);
    InputStream is = RMSoapInInterceptorTest.class.getResourceAsStream(resource);
    assertNotNull(is);
    XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(is);
    soapMessage.setContent(XMLStreamReader.class, reader);
    ReadHeadersInterceptor rji = new ReadHeadersInterceptor(BusFactory.getDefaultBus());
    rji.handleMessage(soapMessage);
    StartBodyInterceptor sbi = new StartBodyInterceptor();
    sbi.handleMessage(soapMessage);
    return soapMessage;
}
 
Example #7
Source File: IntegrationBaseTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected Resource createClient(ReferenceParametersType refParams) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

    Map<String, Object> props = factory.getProperties();
    if (props == null) {
        props = new HashMap<>();
    }
    props.put("jaxb.additionalContextClasses",
            ExpressionType.class);
    factory.setProperties(props);

    factory.setBus(bus);
    factory.setServiceClass(Resource.class);
    factory.setAddress(RESOURCE_ADDRESS);
    Resource proxy = (Resource) factory.create();

    // Add reference parameters
    AddressingProperties addrProps = new AddressingProperties();
    EndpointReferenceType endpoint = new EndpointReferenceType();
    endpoint.setReferenceParameters(refParams);
    endpoint.setAddress(ContextUtils.getAttributedURI(RESOURCE_ADDRESS));
    addrProps.setTo(endpoint);
    ((BindingProvider) proxy).getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);

    return proxy;
}
 
Example #8
Source File: SCTInInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        String s = (String)message.get(SoapBindingConstants.SOAP_ACTION);
        AddressingProperties inProps = (AddressingProperties)message
            .getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
        if (inProps != null && s == null) {
            //MS/WCF doesn't put a soap action out for this, must check the headers
            s = inProps.getAction().getValue();
        }

        if (s != null
            && s.contains("/RST/SCT")
            && (s.startsWith(STSUtils.WST_NS_05_02)
                || s.startsWith(STSUtils.WST_NS_05_12))) {
            message.put(org.apache.cxf.ws.addressing.MAPAggregator.ACTION_VERIFIED, Boolean.TRUE);
        }
    }
 
Example #9
Source File: RMDeliveryInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void handle(Message message) throws SequenceFault, RMException {
    final AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false);
    //if wsrmp:RMAssertion and addressing is optional
    if (maps == null && isRMPolicyEnabled(message)) {
        return;
    }
    LOG.entering(getClass().getName(), "handleMessage");
    Destination dest = getManager().getDestination(message);
    final boolean robust =
        MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY, false);
    if (robust) {
        message.remove(RMMessageConstants.DELIVERING_ROBUST_ONEWAY);
        dest.acknowledge(message);
    }
    dest.processingComplete(message);

    // close InputStream of RMCaptureInInterceptor, to delete tmp files in filesystem
    Closeable closable = (Closeable)message.get("org.apache.cxf.ws.rm.content.closeable");
    if (null != closable) {
        try {
            closable.close();
        } catch (IOException e) {
            // Ignore
        }
    }
}
 
Example #10
Source File: ResourceTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected Resource createClient(ReferenceParametersType refParams) {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(Resource.class);
    factory.setAddress(RESOURCE_LOCAL_ADDRESS);
    Resource proxy = (Resource) factory.create();

    // Add reference parameters
    AddressingProperties addrProps = new AddressingProperties();
    EndpointReferenceType endpoint = new EndpointReferenceType();
    endpoint.setReferenceParameters(refParams);
    endpoint.setAddress(ContextUtils.getAttributedURI(RESOURCE_ADDRESS));
    addrProps.setTo(endpoint);
    ((BindingProvider) proxy).getRequestContext().put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);

    return proxy;
}
 
Example #11
Source File: MAPCodec.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean needsReplyTo(AddressingProperties maps, SoapMessage m) {
    if (!MessageUtils.getContextualBoolean(m, "ws-addressing.write.optional.replyto", true)) {
        if (ContextUtils.isNoneAddress(maps.getReplyTo())
            && m.getExchange().isOneWay()) {
            //one-way + none, not needed
            return false;
        }
        if (ContextUtils.isAnonymousAddress(maps.getReplyTo())) {
            //anonymous is the default if not specified, not needed
            return false;
        }
    }
    return maps.getReplyTo() != null
        && maps.getReplyTo().getAddress() != null
        && maps.getReplyTo().getAddress().getValue() != null
        && !(Names200408.WSA_NAMESPACE_NAME.equals(maps.getNamespaceURI())
            && maps.getReplyTo().getAddress().getValue()
            .equals(ContextUtils.getNoneEndpointReference().getAddress().getValue()));
}
 
Example #12
Source File: MAPCodec.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Encode message in exposed version.
 *
 * @param maps the MAPs, where getNamespceURI() specifies the WS-Addressing
 *  version to expose
 * @param message the SoapMessage
 * @param value the value to encode
 * @param name the QName for the header
 * @param clz the class
 * @param context the JAXB context to use
 */
private <T> void encodeAsExposed(AddressingProperties maps,
                                 SoapMessage message,
                                 T value,
                                 QName name,
                                 Class<T> clz,
                                 JAXBContext context) throws JAXBException {
    if (value != null) {
        LOG.log(Level.FINE,
                "{0} : {1}",
                new Object[] {name.getLocalPart(), getLogText(value)});

        boolean mu = maps.isRequired() || maps.getMustUnderstand().contains(name);

        transformer.encodeAsExposed(message,
                                    maps.getNamespaceURI(),
                                    value,
                                    name.getLocalPart(),
                                    clz,
                                    context,
                                    mu);
    }
}
 
Example #13
Source File: MAPCodec.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void decodeReferenceParameters(Set<Element> referenceParameterHeaders,
                                       AddressingProperties maps,
                                       Unmarshaller unmarshaller)
    throws JAXBException {
    EndpointReferenceType toEpr = maps.getToEndpointReference();
    if (null != toEpr) {
        for (Element e : referenceParameterHeaders) {
            if (DOMUtils.getChild(e, Node.ELEMENT_NODE) == null) {
                JAXBElement<String> el = unmarshaller.unmarshal(e, String.class);
                ContextUtils.applyReferenceParam(toEpr, el);
            } else {
                ContextUtils.applyReferenceParam(toEpr, e);
            }
        }
    }
}
 
Example #14
Source File: RMOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void testRMTerminateSequence(String wsrmnsuri, String wsansuri,
                                     String action, String breplyto, String areplyto)
    throws RMException, SequenceFault {
    AddressingProperties maps = createMAPs(action, "localhost:9000/GreeterPort", breplyto);

    Message message = control.createMock(Message.class);
    Exchange exchange = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
    EasyMock.expect(exchange.getOutMessage()).andReturn(message).anyTimes();
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
    EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND))
        .andReturn(maps).anyTimes();
    RMManager manager = control.createMock(RMManager.class);
    RMConfiguration config = new RMConfiguration();
    config.setRMNamespace(wsrmnsuri);
    config.setRM10AddressingNamespace(wsansuri);
    EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(config).anyTimes();
    control.replay();
    RMOutInterceptor rmi = new RMOutInterceptor();
    rmi.setManager(manager);
    rmi.handle(message);

    assertEquals(areplyto,
                 maps.getReplyTo().getAddress().getValue());
    control.verify();
}
 
Example #15
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiplexGetId() throws Exception {
    destination = setUpDestination();

    final String id = "ID3";
    EndpointReferenceType refWithId = destination.getAddressWithId(id);

    Map<String, Object> context = new HashMap<>();
    assertNull("fails with no context", destination.getId(context));

    AddressingProperties maps = EasyMock.createMock(AddressingProperties.class);
    maps.getToEndpointReference();
    EasyMock.expectLastCall().andReturn(refWithId);
    EasyMock.replay(maps);
    context.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    String result = destination.getId(context);
    assertNotNull(result);
    assertEquals("match our id", result, id);
}
 
Example #16
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Assemble the generic MAPs (for both requests and responses).
 *
 * @param message the current message
 * @return AddressingProperties containing the generic MAPs
 */
private AddressingProperties assembleGeneric(Message message) {
    AddressingProperties maps = getMAPs(message, true, true);
    // MessageID
    if (maps.getMessageID() == null) {
        String messageID = ContextUtils.generateUUID();
        maps.setMessageID(ContextUtils.getAttributedURI(messageID));
    }

    // Action
    if (ContextUtils.hasEmptyAction(maps)) {
        maps.setAction(InternalContextUtils.getAction(message));

        if (ContextUtils.hasEmptyAction(maps)
            && ContextUtils.isOutbound(message)) {
            maps.setAction(ContextUtils.getAttributedURI(getActionUri(message, true)));
        }
    }
    return maps;
}
 
Example #17
Source File: MAPCodecTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setUpEncode(boolean requestor, SoapMessage message, Element header,
                         AddressingProperties maps, String mapProperty, boolean invalidMAP,
                         boolean preExistingSOAPAction) throws Exception {
    message.put(mapProperty, maps);


    mimeHeaders = new HashMap<>();
    message.put(MIME_HEADERS, mimeHeaders);
    if (preExistingSOAPAction) {
        List<String> soapAction = new ArrayList<>();
        soapAction.add("\"foobar\"");
        mimeHeaders.put(SoapBindingConstants.SOAP_ACTION, soapAction);
    }
    if (invalidMAP) {
        message.put("org.apache.cxf.ws.addressing.map.fault.name", Names.DUPLICATE_MESSAGE_ID_NAME);
        message.put("org.apache.cxf.ws.addressing.map.fault.reason",
                    "Duplicate Message ID urn:uuid:12345");
    }
}
 
Example #18
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 #19
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 #20
Source File: Destination.java    From cxf with Apache License 2.0 6 votes vote down vote up
void ackImmediately(DestinationSequence seq, Message message) throws RMException {

        seq.scheduleImmediateAcknowledgement();

        // if we cannot expect an outgoing message to which the
        // acknowledgement
        // can be added we need to send an out-of-band
        // SequenceAcknowledgement message

        AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, false);
        String replyToAddress = null;
        if (null != maps.getReplyTo()) {
            replyToAddress = maps.getReplyTo().getAddress().getValue();
        }
        if (!(seq.getAcksTo().getAddress().getValue().equals(replyToAddress) || seq
            .canPiggybackAckOnPartialResponse())) {
            getReliableEndpoint().getProxy().acknowledge(seq);
        }
    }
 
Example #21
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Check for NONE ReplyTo value in request-response MEP
 * @param message the current message
 * @param maps the incoming MAPs
 */
private void checkReplyTo(Message message, AddressingProperties maps) {
    // if ReplyTo address is none then 202 response status is expected
    // However returning a fault is more appropriate for request-response MEP
    if (!message.getExchange().isOneWay()
        && !MessageUtils.isPartialResponse(message)
        && ContextUtils.isNoneAddress(maps.getReplyTo())) {
        String reason = MessageFormat.format(BUNDLE.getString("REPLYTO_NOT_SUPPORTED_MSG"),
                                             maps.getReplyTo().getAddress().getValue());
        throw new SoapFault(reason,
                            new QName(Names.WSA_NAMESPACE_NAME,
                                      Names.WSA_NONE_ADDRESS));
    }
}
 
Example #22
Source File: MAPAggregatorImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setupNamespace(AddressingProperties maps, Message message) {
    AssertionInfoMap aim = message.get(AssertionInfoMap.class);
    if (null == aim) {
        String ns = (String)message.getContextualProperty(MAPAggregator.ADDRESSING_NAMESPACE);
        if (ns != null) {
            maps.exposeAs(ns);
        }
        return;
    }
    Collection<AssertionInfo> aic = aim.getAssertionInfo(MetadataConstants.USING_ADDRESSING_2004_QNAME);
    if (aic != null && !aic.isEmpty()) {
        maps.exposeAs(Names200408.WSA_NAMESPACE_NAME);
    }
}
 
Example #23
Source File: DefaultLogEventMapper.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Get MessageId from WS Addressing properties
 *
 * @param message
 * @return message id
 */
private String getMessageId(Message message) {
    AddressingProperties addrProp = ContextUtils.retrieveMAPs(message, false,
                                                              MessageUtils.isOutbound(message), false);
    return addrProp != null && addrProp.getMessageID() != null
        ? addrProp.getMessageID().getValue() : UUID.randomUUID().toString();
}
 
Example #24
Source File: Client.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static AddressingProperties createMaps() {
    // get Message Addressing Properties instance
    AddressingProperties maps = new AddressingProperties();

    // set MessageID property
    AttributedURIType messageID = WSA_OBJECT_FACTORY.createAttributedURIType();
    messageID.setValue("urn:uuid:" + System.currentTimeMillis());
    maps.setMessageID(messageID);
    return maps;
}
 
Example #25
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Marks a message as partial response
 *
 * @param message the current message
 */
private void markPartialResponse(SoapMessage message, AddressingProperties maps) {
    if (ContextUtils.isRequestor(message) && null != maps
        && (null == maps.getRelatesTo()
            || (null != maps.getRelatesTo()
                && Names.WSA_UNSPECIFIED_RELATIONSHIP.equals(maps.getRelatesTo().getValue())))) {
        message.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
    }
}
 
Example #26
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Cache exchange for correlated response
 *
 * @param message the current message
 * @param maps the addressing properties
 */
private void cacheExchange(SoapMessage message, AddressingProperties maps) {
    if (ContextUtils.isRequestor(message) && !message.getExchange().isOneWay()) {
        uncorrelatedExchanges.put(maps.getMessageID().getValue(),
                                  message.getExchange());
    }
}
 
Example #27
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Discard any pre-existing MAP headers - this may occur if the runtime
 * re-uses a SOAP message.
 *
 * @param header the SOAP header
 * @param maps the current MAPs
 */
private void discardMAPs(List<Header> header, AddressingProperties maps) {
    Iterator<Header> iter = header.iterator();
    while (iter.hasNext()) {
        Header hdr = iter.next();
        if (Names.WSA_NAMESPACE_NAME.equals(hdr.getName().getNamespaceURI())
            || Names200408.WSA_NAMESPACE_NAME.equals(hdr.getName().getNamespaceURI())) {
            iter.remove();
        }
    }
}
 
Example #28
Source File: RMCaptureOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isResponseToAction(Message msg, String action) {
    AddressingProperties inMaps = RMContextUtils.retrieveMAPs(msg, false, false);
    String inAction = null;
    if (null != inMaps.getAction()) {
        inAction = inMaps.getAction().getValue();
    }
    return action.equals(inAction);
}
 
Example #29
Source File: GreeterImplA.java    From cxf with Apache License 2.0 5 votes vote down vote up
private String getMessageID() {
    String id = null;
    if (context.getMessageContext() != null) {
        String property =
            JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND;
        AddressingProperties maps = (AddressingProperties)
            context.getMessageContext().get(property);
        id = maps != null && maps.getMessageID() != null
             ? maps.getMessageID().getValue()
             : null;
    }
    return id;
}
 
Example #30
Source File: MAPCodecTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setUpDecode(SoapMessage message, List<Header> headers, AddressingProperties maps,
                         String mapProperty, boolean requestor) throws Exception {
    Unmarshaller unmarshaller = control.createMock(Unmarshaller.class);
    ContextJAXBUtils.getJAXBContext().createUnmarshaller();
    EasyMock.expectLastCall().andReturn(unmarshaller);
    String uri = maps.getNamespaceURI();
    boolean exposedAsNative = Names.WSA_NAMESPACE_NAME.equals(uri);
    boolean exposedAs200408 = Names200408.WSA_NAMESPACE_NAME.equals(uri);
    boolean exposedAs200403 = Names200403.WSA_NAMESPACE_NAME.equals(uri);
    assertTrue("unexpected namescape URI: " + uri, exposedAsNative || exposedAs200408 || exposedAs200403);
    setUpHeaderDecode(headers, uri, Names.WSA_ACTION_NAME, exposedAsNative
        ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
            ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 0, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_MESSAGEID_NAME, exposedAsNative
        ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
            ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 1, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_TO_NAME, exposedAsNative
        ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
            ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 2, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_REPLYTO_NAME, exposedAsNative
        ? EndpointReferenceType.class : exposedAs200408
            ? Names200408.EPR_TYPE : exposedAs200403
                ? Names200403.EPR_TYPE : null, 3, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_RELATESTO_NAME, exposedAsNative
        ? RelatesToType.class : exposedAs200408 ? Relationship.class : exposedAs200403
            ? org.apache.cxf.ws.addressing.v200403.Relationship.class : null, 4, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_FAULTTO_NAME, exposedAsNative
        ? EndpointReferenceType.class : exposedAs200408
            ? Names200408.EPR_TYPE : exposedAs200403
                ? Names200403.EPR_TYPE : null, 5, unmarshaller);
    setUpHeaderDecode(headers, uri, Names.WSA_FROM_NAME, exposedAsNative
        ? EndpointReferenceType.class : exposedAs200408
            ? Names200408.EPR_TYPE : exposedAs200403
                ? Names200403.EPR_TYPE : null, 6, unmarshaller);
}