Java Code Examples for org.apache.cxf.ws.addressing.EndpointReferenceType#getReferenceParameters()

The following examples show how to use org.apache.cxf.ws.addressing.EndpointReferenceType#getReferenceParameters() . 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: AbstractMultiplexDestination.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Builds an new endpoint reference using the current target reference as a template.
 * The supplied id is endcoded using a reference parameter.
 * This requires the ws-a interceptors to propagate the reference parameters
 * on subsequent invokes using the returned reference.
 * @param id the id to encode in the new reference
 * @return the new reference with the id encoded as a reference parameter
 * @see org.apache.cxf.transport.MultiplexDestination#getAddressWithId(java.lang.String)

 */
public EndpointReferenceType getAddressWithId(String id) {
    EndpointReferenceType epr = EndpointReferenceUtils.duplicate(
        EndpointReferenceUtils.mint(reference, bus));
    ReferenceParametersType newParams = new org.apache.cxf.ws.addressing.ObjectFactory()
        .createReferenceParametersType();

    ReferenceParametersType existingParams = epr.getReferenceParameters();
    if (null != existingParams) {
        newParams.getAny().addAll(existingParams.getAny());
    }

    newParams.getAny().add(new JAXBElement<String>(MULTIPLEX_ID_QNAME, String.class, id));
    epr.setReferenceParameters(newParams);
    return epr;
}
 
Example 2
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void encodeReferenceParameters(AddressingProperties maps,
                                       SoapMessage msg,
                                       JAXBContext ctx) throws JAXBException {
    Element header = null;

    EndpointReferenceType toEpr = maps.getToEndpointReference();
    if (null != toEpr) {
        ReferenceParametersType params = toEpr.getReferenceParameters();
        if (null != params) {
            for (Object o : params.getAny()) {
                if (o instanceof Element || o instanceof JAXBElement) {
                    if (header == null) {
                        header = getHeaderFactory().getHeader(msg.getVersion());
                    }
                    JAXBElement<?> jaxbEl = null;
                    if (o instanceof Element) {
                        Element e = (Element)o;
                        Node importedNode = header.getOwnerDocument().importNode(e, true);
                        header.appendChild(importedNode);
                    } else {
                        jaxbEl = (JAXBElement<?>) o;
                        ctx.createMarshaller().marshal(jaxbEl, header);
                    }

                    Element lastAdded = (Element)header.getLastChild();
                    header.removeChild(lastAdded);
                    addIsReferenceParameterMarkerAttribute(lastAdded, maps.getNamespaceURI());


                    Header holder = new Header(new QName(lastAdded.getNamespaceURI(),
                                                         lastAdded.getLocalName()),
                                                         lastAdded);
                    msg.getHeaders().add(holder);
                } else {
                    LOG.log(Level.WARNING, "IGNORE_NON_ELEMENT_REF_PARAM_MSG", o);
                }
            }
        }
    }
}
 
Example 3
Source File: AbstractMultiplexDestination.java    From cxf with Apache License 2.0 5 votes vote down vote up
private String extractStringElementFromAny(QName elementQName, EndpointReferenceType epr) {
    String elementStringValue = null;
    if (null != epr.getReferenceParameters()) {
        for (Object o : epr.getReferenceParameters().getAny()) {
            if (o instanceof JAXBElement) {
                JAXBElement<?> el = (JAXBElement<?>)o;
                if (el.getName().equals(elementQName)) {
                    elementStringValue = (String)el.getValue();
                }
            }
        }
    }
    return elementStringValue;
}