Search in sources :

Example 1 with MAPBuilder

use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.

the class ServerHandler method handleOutbound.

@Override
public boolean handleOutbound(SOAPMessageContext msgContext) {
    log.info("handleResponse");
    MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
    MAP inProps = builder.inboundMap(msgContext);
    MAP outProps = builder.newMap();
    outProps.initializeAsDestination(inProps.getReplyTo());
    outProps.installOutboundMapOnServerSide(msgContext, outProps);
    msgContext.setScope(builder.newConstants().getServerAddressingPropertiesOutbound(), Scope.APPLICATION);
    return true;
}
Also used : MAP(org.jboss.ws.api.addressing.MAP) MAPBuilder(org.jboss.ws.api.addressing.MAPBuilder)

Example 2 with MAPBuilder

use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.

the class ServerHandler method handleInbound.

@Override
public boolean handleInbound(SOAPMessageContext msgContext) {
    log.info("handleRequest");
    MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
    MAP addrProps = builder.inboundMap(msgContext);
    if (addrProps == null)
        throw new IllegalStateException("Cannot obtain AddressingProperties");
    String clientid = null;
    MAPEndpoint replyTo = addrProps.getReplyTo();
    for (Object obj : replyTo.getReferenceParameters()) {
        if (obj instanceof Element) {
            Element el = (Element) obj;
            QName qname = getElementQName(el);
            if (qname.equals(IDQN)) {
                clientid = getTextContent(el);
            }
        } else {
            log.warn("Unsupported reference parameter found: " + obj);
        }
    }
    if (clientid == null)
        throw new IllegalStateException("Cannot obtain client id");
    // put the clientid in the message context
    msgContext.put("clientid", clientid);
    msgContext.setScope("clientid", Scope.APPLICATION);
    return true;
}
Also used : MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) MAP(org.jboss.ws.api.addressing.MAP) MAPBuilder(org.jboss.ws.api.addressing.MAPBuilder)

Example 3 with MAPBuilder

use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.

the class CXFMAP method getRelatesTo.

public MAPRelatesTo getRelatesTo() {
    MAPBuilder builder = CXFMAPBuilder.getBuilder();
    RelatesToType relatesTo = implementation.getRelatesTo();
    if (relatesTo != null) {
        String type = relatesTo.getRelationshipType();
        QName relatesToType;
        int index = type.indexOf("}");
        if (index == -1) {
            relatesToType = new QName(type);
        } else {
            String ns = type.substring(1, index + 1);
            String name = type.substring(index + 1);
            relatesToType = new QName(ns, name);
        }
        return builder.newRelatesTo(relatesTo.getValue(), relatesToType);
    } else {
        return null;
    }
}
Also used : RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) QName(javax.xml.namespace.QName) MAPBuilder(org.jboss.ws.api.addressing.MAPBuilder) MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint)

Example 4 with MAPBuilder

use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.

the class AddressingPort method readClientID.

/**
 * This verifies the client ID is available in inbound messages
 */
@SuppressWarnings("unchecked")
private void readClientID() {
    BindingProvider bindingProvider = (BindingProvider) port;
    Map<String, Object> msgContext = bindingProvider.getResponseContext();
    MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
    MAP addrProps = builder.inboundMap(msgContext);
    if (addrProps == null)
        throw new IllegalStateException("Cannot obtain AddressingProperties");
    for (Object obj : addrProps.getReferenceParameters()) {
        if (// Native always uses Element for ref params
        obj instanceof Element) {
            Element el = (Element) obj;
            QName qname = DOMUtils.getElementQName(el);
            if (qname.equals(IDQN)) {
                clientID = DOMUtils.getTextContent(el);
            }
        } else if (// CXF also uses JAXBElement
        obj instanceof JAXBElement) {
            JAXBElement<String> el = (JAXBElement<String>) obj;
            if (IDQN.equals(el.getName())) {
                clientID = el.getValue();
            }
        }
    }
    if (clientID == null)
        throw new IllegalStateException("Cannot obtain clientid");
}
Also used : QName(javax.xml.namespace.QName) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) BindingProvider(javax.xml.ws.BindingProvider) JAXBElement(javax.xml.bind.JAXBElement) MAP(org.jboss.ws.api.addressing.MAP) MAPBuilder(org.jboss.ws.api.addressing.MAPBuilder)

Example 5 with MAPBuilder

use of org.jboss.ws.api.addressing.MAPBuilder in project jbossws-cxf by jbossws.

the class AddressingPort method setClientID.

/**
 * This installs the ID for this client in the outbound messages
 */
private void setClientID() {
    BindingProvider bindingProvider = (BindingProvider) port;
    Map<String, Object> msgContext = bindingProvider.getRequestContext();
    MAPBuilder builder = MAPBuilderFactory.getInstance().getBuilderInstance();
    MAPConstants ADDR = builder.newConstants();
    MAP outProps = builder.newMap();
    MAPEndpoint replyTo = builder.newEndpoint(ADDR.getAnonymousURI());
    outProps.setReplyTo(replyTo);
    outProps.setMessageID("urn:uuid:" + UUIDGenerator.generateRandomUUIDString());
    // Assign a new clientid
    if (clientID == null) {
        clientID = "clientid-" + (++maxClientId);
        log.info("New clientid: " + clientID);
    }
    try {
        replyTo.addReferenceParameter(DOMUtils.parse(getClientIdElement(clientID), getDocumentBuilder()));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    outProps.installOutboundMapOnClientSide(msgContext, outProps);
}
Also used : MAPEndpoint(org.jboss.ws.api.addressing.MAPEndpoint) MAPConstants(org.jboss.ws.api.addressing.MAPConstants) BindingProvider(javax.xml.ws.BindingProvider) IOException(java.io.IOException) MAP(org.jboss.ws.api.addressing.MAP) MAPBuilder(org.jboss.ws.api.addressing.MAPBuilder)

Aggregations

MAPBuilder (org.jboss.ws.api.addressing.MAPBuilder)5 MAP (org.jboss.ws.api.addressing.MAP)4 QName (javax.xml.namespace.QName)3 MAPEndpoint (org.jboss.ws.api.addressing.MAPEndpoint)3 BindingProvider (javax.xml.ws.BindingProvider)2 Element (org.w3c.dom.Element)2 IOException (java.io.IOException)1 JAXBElement (javax.xml.bind.JAXBElement)1 RelatesToType (org.apache.cxf.ws.addressing.RelatesToType)1 MAPConstants (org.jboss.ws.api.addressing.MAPConstants)1