Example usage for javax.xml.ws Dispatch getRequestContext

List of usage examples for javax.xml.ws Dispatch getRequestContext

Introduction

In this page you can find the example usage for javax.xml.ws Dispatch getRequestContext.

Prototype

Map<String, Object> getRequestContext();

Source Link

Document

Get the context that is used to initialize the message context for request messages.

Usage

From source file:org.apache.hise.engine.jaxws.HISEJaxWSClient.java

@Transactional
public Node invoke(Node message, Node epr) {
    try {//from  w  w w. ja  v  a  2  s . co m

        Dispatch<SOAPMessage> dispatch = destinationService.createDispatch(destinationPort, SOAPMessage.class,
                Service.Mode.MESSAGE);

        String address = getAddressFromEpr(epr);
        if (!address.equals("")) {
            __log.debug("sending to address " + address);
            dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, address);
        }

        SOAPMessage m;
        m = messageFactory.createMessage();
        Document doc = m.getSOAPBody().getOwnerDocument();
        m.getSOAPBody().appendChild(doc.importNode(message, true));
        return dispatch.invoke(m).getSOAPBody();
    } catch (SOAPException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.codice.ddf.security.claims.attributequery.common.AttributeQueryClaimsHandler.java

/**
 * Creates a dispatcher for dispatching requests.
 *//*from  ww  w . j  a  v a  2s  .c  o m*/
protected Dispatch<StreamSource> createDispatcher(Service service) {
    Dispatch<StreamSource> dispatch = null;
    if (service != null) {
        dispatch = service.createDispatch(QName.valueOf(portName), StreamSource.class, Service.Mode.MESSAGE);
        dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, externalAttributeStoreUrl);
        dispatch.getRequestContext().put("ws-security.signature.properties", signatureProperties);
        dispatch.getRequestContext().put("ws-security.encryption.properties", encryptionProperties);
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingInInterceptor());
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingOutInterceptor());
    }
    return dispatch;
}

From source file:org.wso2.carbon.connector.rm.ReliableMessage.java

/**
 * This method used to create dispatcher
 *
 * @param inputParams input parameters./* w  ww. j a  v  a2 s.co m*/
 * @return Dispatch source dispatcher
 * @throws ConnectException
 */
private Dispatch<Source> createDispatch(RMParameters inputParams, MessageContext messageContext)
        throws ConnectException {
    String portName = inputParams.getPortName();
    String serviceName = inputParams.getServiceName();
    String nameSpace = inputParams.getNamespace();

    QName serviceQName = new QName(nameSpace, serviceName);
    QName portQName = new QName(nameSpace, portName);
    Service service = Service.create(serviceQName);

    if (service == null) {
        String message = "Service instance cannot initialize";
        log.error(message);
        throw new ConnectException(message);
    }

    if (RMConstants.SOAP_V_11.equals(inputParams.getSoapVersion())) {
        service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, inputParams.getEndpoint());
    } else {
        service.addPort(portQName, SOAPBinding.SOAP12HTTP_BINDING, inputParams.getEndpoint());
    }

    Dispatch<Source> sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.MESSAGE);
    if (messageContext.getSoapAction() != null && !messageContext.getSoapAction().isEmpty()) {
        sourceDispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
                messageContext.getSoapAction());
    }
    return sourceDispatch;
}