Example usage for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY

List of usage examples for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY

Introduction

In this page you can find the example usage for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.

Prototype

String ENDPOINT_ADDRESS_PROPERTY

To view the source code for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.

Click Source Link

Document

Standard property: Target service endpoint address.

Usage

From source file:com.evolveum.midpoint.pwdfilter.opendj.PasswordPusher.java

ModelPortType setupMidPointConnection() {

    System.out.println("Pwd Sync Endpoint is " + endPoint);

    ModelService modelService = new ModelService();
    ModelPortType modelPort = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) modelPort;
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);

    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
    org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

    Map<String, Object> outProps = new HashMap<String, Object>();

    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);

    outProps.put(WSHandlerConstants.USER, username);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new MidPointPasswordCallback(password));
    System.out.println("After pwd");
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    cxfEndpoint.getOutInterceptors().add(wssOut);

    return modelPort;
}

From source file:com.evolveum.midpoint.testing.wstest.AbstractWebserviceTest.java

/**
 * Creates webservice client connecting to midpoint
 * *///from w  ww  . j  a  v a2  s.co  m
protected static ModelPortType createModelPort(String username, String password, String passwordType) {

    String endpoint = ENDPOINT;
    if (System.getProperty("midpoint.endpoint") != null) {
        endpoint = System.getProperty("midpoint.endpoint");
    }
    LOGGER.info("Creating model client endpoint: {} , username={}, password={}",
            new Object[] { endpoint, username, password });

    ModelService modelService = new ModelService();
    ModelPortType modelPort = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) modelPort;
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);

    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
    org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

    Map<String, Object> outProps = new HashMap<String, Object>();
    if (username != null) {
        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
        outProps.put(WSHandlerConstants.USER, username);
        outProps.put(WSHandlerConstants.PASSWORD_TYPE, passwordType);
        ClientPasswordHandler.setPassword(password);
        outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());

        WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
        cxfEndpoint.getOutInterceptors().add(wssOut);
    }

    cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
    cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());

    return modelPort;
}

From source file:be.fedict.trust.client.XKMS2Client.java

private void setEndpointAddress(String location) {
    LOG.debug("ws location: " + location);
    if (null == location) {
        throw new IllegalArgumentException("XKMS2 location URL cannot be null");
    }/*from  w  w w  . ja va2 s  .  co  m*/
    BindingProvider bindingProvider = (BindingProvider) this.port;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);
}

From source file:org.apache.camel.component.cxf.cxfbean.CxfBeanTest.java

@Test
public void testJaxWsBeanFromCxfRoute() throws Exception {
    URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
    PersonService ss = new PersonService(wsdlURL,
            new QName("http://camel.apache.org/wsdl-first", "PersonService"));
    Person client = ss.getSoap();//w w w. j  ava 2  s  .  c om
    ((BindingProvider) client).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            "http://localhost:" + CXFTestSupport.getPort1() + "/CxfBeanTest/PersonService/");

    Holder<String> personId = new Holder<String>();
    personId.value = "hello";
    Holder<String> ssn = new Holder<String>();
    Holder<String> name = new Holder<String>();
    client.getPerson(personId, ssn, name);
    assertEquals("Get a wrong personId", "hello", personId.value);
    assertEquals("Get a wrong SSN", "000-000-0000", ssn.value);
    assertEquals("Get a wrong name", "Bonjour", name.value);
}

From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactServiceClient.java

private void setEndpointAddress(String sslHostname) {

    LOG.debug("ws location: " + location);
    if (null == location) {
        throw new IllegalArgumentException("SAML Artifact " + "Service location URL cannot be null");
    }//  w  w  w .  j  ava 2  s  .co m

    BindingProvider bindingProvider = (BindingProvider) this.port;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);
    bindingProvider.getRequestContext().put(JAXWSProperties.HOSTNAME_VERIFIER,
            new CustomHostnameVerifier(sslHostname));

}

From source file:com.snaplogic.snaps.firstdata.Create.java

@Override
protected void process(Document document, String viewname) {
    Object requestObj;/* ww w  . j a  v a2s.c  o  m*/
    Object data;
    if ((data = document.get()) != null) {
        /*
         * Process the input data if and only if it is of Map
         */
        if (data instanceof Map) {
            String claszPath = getGMFReqClassType();
            Object map = Map.class.cast(data).get(getGMFReqClassName());
            Map<String, Object> inputMap = Map.class.cast(map);
            requestObj = getObject(claszPath, inputMap);
            if (inputMap.containsKey(ADDTL_AMT_GRP)) {
                try {
                    List<Map<String, Object>> inputList = List.class.cast(inputMap.get(ADDTL_AMT_GRP));
                    if (inputList != null) {
                        requestObj = prepareListObj(requestObj, claszPath, ADDTL_AMT_GRP, inputList);
                    }
                } catch (ClassCastException e) {
                    Map<String, Object> inputPair = Map.class.cast(inputMap.get(ADDTL_AMT_GRP));
                    requestObj = prepareListObj(requestObj, claszPath, ADDTL_AMT_GRP, inputPair);
                }
            }
            if (inputMap.containsKey(PROD_CODE_DET_GRP)) {
                try {
                    List<Map<String, Object>> inputList = List.class.cast(inputMap.get(PROD_CODE_DET_GRP));
                    if (inputList != null) {
                        requestObj = prepareListObj(requestObj, claszPath, PROD_CODE_DET_GRP, inputList);
                    }
                } catch (ClassCastException e) {
                    Map<String, Object> inputPair = Map.class.cast(inputMap.get(PROD_CODE_DET_GRP));
                    requestObj = prepareListObj(requestObj, claszPath, PROD_CODE_DET_GRP, inputPair);
                }
            }

            String xmlData = null;
            try {
                /* Using Reflection and JAXB to prepare SOAP request XML */
                Class<?> gmfmv = Class.forName(GMF_MESSAGE_VARIANTS);
                Object gmfmvObj = gmfmv.newInstance();
                Method gmfMethod = gmfmv.getMethod(String.format(SETTER, getGMFVarient(resourceType)),
                        getClassType(claszPath));
                gmfMethod.invoke(gmfmvObj, requestObj);
                /* converting simple java objects into XML format using JAXB */
                xmlData = getGMFXMLRequestData((GMFMessageVariants) gmfmvObj);
                xmlData = xmlData.replaceAll(GMF_MESSAGE_VARIANTS_TAG, GMF_TAG);
                xmlData = xmlData.replaceAll(NAMESPACE_NS1, StringUtils.EMPTY);
                xmlData = xmlData.replaceAll(NAMESPACE_NS2, StringUtils.EMPTY);
                log.debug(xmlData);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                writeToErrorView(e.getMessage(), REQUEST_FAILED, ERROR_RESOLUTION, e);
                return;
            }
            AccountBean bean = account.connect();
            try {
                /*
                 * Create the instance of the RequestType that is a class generated from the
                 * Rapid connect Transaction Service WSDL file [rc.wsdl]
                 */
                RequestType requestType = new RequestType();
                /* Set client timeout value of request object. */
                requestType.setClientTimeout(new BigInteger(String.valueOf(bean.getTimeOut())));
                /*
                 * Create the instance of the ReqClientIDType that is a class generated from the
                 * Rapid connect Transaction Service WSDL file [rc.wsdl]
                 */
                ReqClientIDType reqClientIDType = new ReqClientIDType();
                reqClientIDType.setApp(bean.getAppID());
                reqClientIDType.setAuth(bean.getAuthString());
                String clientRef = getClientRef(requestObj, claszPath);
                reqClientIDType.setClientRef(clientRef);
                reqClientIDType.setDID(bean.getDatawireId());
                /* Assign ReqClientID value to the requesttype object */
                requestType.setReqClientID(reqClientIDType);
                /*
                 * Create the instance of the TransactionType that is a class generated from the
                 * Rapid connect Transaction Service WSDL file [rc.wsdl]
                 */
                TransactionType transactionType = new TransactionType();
                /*
                 * Create the instance of the PayloadType that is a class generated from the
                 * Rapid connect Transaction Service WSDL file [rc.wsdl]
                 */
                PayloadType payloadType = new PayloadType();
                payloadType.setEncoding(CDATA);
                payloadType.setValue(xmlData); // actual xml request
                transactionType.setPayload(payloadType);
                transactionType.setServiceID(String.valueOf(bean.getServiceID()));
                /* Set transaction type */
                requestType.setTransaction(transactionType);
                /* Set version number of the request */
                requestType.setVersion(VERSION);
                /* The response to be returned. */
                String gmfResponse = null;
                /*
                 * Create the instance of the RcService that is a class generated from the Rapid
                 * connect Transaction Service WSDL file [rc.wsdl]
                 */
                URL wsdlUrl = new URL(bean.getServiceWSDLURL());
                RcService.setWsdlURL(wsdlUrl);
                RcService rcService = new RcService();
                /*
                 * Create the instance of the RcPortType that is a class generated from the
                 * Rapid connect Transaction Service WSDL file [rc.wsdl]
                 */
                RcPortType port = rcService.getRcServicePort();
                /* The URL that will receive the XML request data. */
                /* Bind the URL using Binding Provider */
                ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                        bean.getServiceURL());
                /* Perform actual send operation for the request. */
                ResponseType responseType = port.rcTransaction(requestType);
                /* Parse the response received from the URL */
                StatusType statusType;
                if (responseType != null && (statusType = responseType.getStatus()) != null) {
                    String statuCode = statusType.getStatusCode();
                    if (statuCode != null && statuCode.equals(STATUS_OK)) {
                        TransactionResponseType trType = responseType.getTransactionResponse();
                        PayloadType pType;
                        if (trType != null && (pType = trType.getPayload()) != null) {
                            String encoding = pType.getEncoding();
                            if (encoding != null && encoding.equals(CDATA)) {
                                /*
                                 * Extract pay load - the response from data wire for cdata
                                 * encoding.
                                 */
                                gmfResponse = pType.getValue();
                            } else if (encoding.equalsIgnoreCase(XML_ESCAPE)) {
                                /*
                                 * Extract pay load - the response from data wire for xml_escape
                                 * encoding.
                                 */
                                gmfResponse = pType.getValue().replaceAll(GT, GT_SYM).replaceAll(LT, LT_SYM)
                                        .replaceAll(AMP, AMP_SYM);
                            }
                            outputViews.write(documentUtility.newDocument(getJsonFromXML(gmfResponse)));
                            counter.inc();
                        } else {
                            writeToErrorView(NULL_TRANSACTION_RESPONSE,
                                    responseType.getStatus().getStatusCode(), VALIDATE_INPUT_DATA,
                                    responseType.getStatus().getValue());
                        }
                    } else {
                        writeToErrorView(INVALID_RESPONSE, responseType.getStatus().getStatusCode(),
                                VALIDATE_INPUT_DATA, responseType.getStatus().getValue());
                    }
                } else {
                    writeToErrorView(EMPTY_RESPONSE, IMPROPER_INPUT, VALIDATE_INPUT_DATA, NULL_OBJECT);
                }
            } catch (Exception ex) {
                writeToErrorView(ERRORMSG, ex.getMessage(), ERROR_RESOLUTION, ex);
            }
        } else {
            writeToErrorView(NO_DATA_ERRMSG, NO_DATA_WARNING, NO_DATA_REASON, NO_DATA_RESOLUTION);
        }
    } else {
        writeToErrorView(NO_DATA_ERRMSG, NO_DATA_WARNING, NO_DATA_REASON, NO_DATA_RESOLUTION);
    }
}

From source file:com.evolveum.midpoint.testing.model.client.sample.RunScript.java

public static ModelPortType createModelPort(CommandLine cmdLine) {
    String endpointUrl = cmdLine.getOptionValue(OPT_URL, DEFAULT_ENDPOINT_URL);
    String user = cmdLine.getOptionValue(OPT_USER, ADM_USERNAME);
    ClientPasswordHandler.setPassword(cmdLine.getOptionValue(OPT_PASSWORD, ADM_PASSWORD));
    System.out.println("Endpoint URL: " + endpointUrl);

    ModelService modelService = new ModelService();
    ModelPortType modelPort = modelService.getModelPort();
    BindingProvider bp = (BindingProvider) modelPort;
    Map<String, Object> requestContext = bp.getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);

    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort);
    org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();

    Map<String, Object> outProps = new HashMap<>();

    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, user);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
    outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName());

    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    cxfEndpoint.getOutInterceptors().add(wssOut);

    return modelPort;
}

From source file:test.integ.be.fedict.hsm.ws.WebServiceSecurityTest.java

private DigitalSignatureServicePortType getPort() {
    DigitalSignatureService digitalSignatureService = DigitalSignatureServiceFactory.getInstance();
    DigitalSignatureServicePortType dssPort = digitalSignatureService.getDigitalSignatureServicePort();
    BindingProvider bindingProvider = (BindingProvider) dssPort;
    String location = this.baseURL.toString() + "dss";
    LOG.debug("location: " + location);
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(new LoggingSOAPHandler());
    binding.setHandlerChain(handlerChain);

    return dssPort;
}

From source file:se.inera.axel.riv2ssek.internal.RivSsekRouteBuilderTest.java

protected RegisterMedicalCertificateResponderInterface getRegisterMedicalCertificateResponderInterface() {
    RegisterMedicalCertificateResponderService registerMedicalCertificateResponderService = new RegisterMedicalCertificateResponderService();
    RegisterMedicalCertificateResponderInterface registerMedicalCertificateResponderPort = registerMedicalCertificateResponderService
            .getRegisterMedicalCertificateResponderPort();

    Client client = ClientProxy.getClient(registerMedicalCertificateResponderPort);
    Endpoint cxfEndpoint = client.getEndpoint();
    cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
    cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor());
    String riv2ssekEndpoint = System.getProperty("riv2ssekEndpoint");
    String riv2ssekEndpointPath = System.getProperty("riv2ssekEndpoint.path");
    if (riv2ssekEndpoint.startsWith("jetty://")) {
        riv2ssekEndpoint = riv2ssekEndpoint.substring("jetty://".length());
    }//from  w  w w  .j a  v a2 s. c o  m
    ((BindingProvider) registerMedicalCertificateResponderPort).getRequestContext()
            .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, riv2ssekEndpoint + riv2ssekEndpointPath);
    return registerMedicalCertificateResponderPort;
}

From source file:be.agiv.security.AGIVSecurity.java

/**
 * Enable the AGIV security on the given JAX-WS binding provider. Each
 * JAX-WS port can be casted to a JAX-WS binding provider. The JAX-WS port
 * will also be configured to use the service at the given service location.
 * /* w  ww  .  j  a va2  s.c  om*/
 * @param bindingProvider
 *            the JAX-WS binding provider on which to enable the AGIV
 *            security framework.
 * @param serviceLocation
 *            the location of the web service.
 * @param useWsSecureConversation
 *            set to <code>true</code> if WS-SecureConversation should be
 *            used.
 * @param serviceRealm
 *            the optional service realm.
 * @see AGIVSecurity#enable(BindingProvider)
 * @see AGIVSecurity#disable(BindingProvider)
 */
public void enable(BindingProvider bindingProvider, String serviceLocation, boolean useWsSecureConversation,
        String serviceRealm) {
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceLocation);
    enable(bindingProvider, useWsSecureConversation, serviceRealm);
}