Search in sources :

Example 6 with StringPuller

use of org.switchyard.common.io.pull.StringPuller in project quickstarts by jboss-switchyard.

the class WorkServiceMain method invokeWorkService.

private static void invokeWorkService(String scheme, int port, String context, String username) throws Exception {
    String soapRequest = new StringPuller().pull("/xml/soap-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
    HTTPMixIn http = new HTTPMixIn();
    soapRequest = soapRequest.replaceFirst("<!-- Username -->", username);
    http.initialize();
    try {
        String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
        //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
        LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
        String soapResponse = http.postString(endpoint, soapRequest);
        //LOGGER.info(String.format("Received work service response: %s", soapResponse));
        if (soapResponse.toLowerCase().contains("fault")) {
            throw new Exception("Error invoking work service (check server log)");
        }
    } finally {
        http.uninitialize();
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn) StringPuller(org.switchyard.common.io.pull.StringPuller)

Example 7 with StringPuller

use of org.switchyard.common.io.pull.StringPuller in project quickstarts by jboss-switchyard.

the class WorkServiceMain method invokeWorkService.

private static void invokeWorkService(String scheme, int port, String context, String[] userPass) throws Exception {
    String soapRequest = new StringPuller().pull("/xml/soap-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
    HTTPMixIn http = new HTTPMixIn();
    if (userPass != null && userPass.length == 2) {
        http.setRequestHeader("Authorization", "Basic " + Base64.encodeFromString(userPass[0] + ":" + userPass[1]));
    }
    http.initialize();
    try {
        String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
        //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
        LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
        String soapResponse = http.postString(endpoint, soapRequest);
        //LOGGER.info(String.format("Received work service response: %s", soapResponse));
        if (soapResponse.toLowerCase().contains("fault")) {
            throw new Exception("Error invoking work service (check server log)");
        }
    } finally {
        http.uninitialize();
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn) StringPuller(org.switchyard.common.io.pull.StringPuller)

Example 8 with StringPuller

use of org.switchyard.common.io.pull.StringPuller in project quickstarts by jboss-switchyard.

the class WorkServiceMain method invokeWorkService.

private static void invokeWorkService(String scheme, int port, String context, String[] userPass) throws Exception {
    String soapRequest = new StringPuller().pull("/xml/soap-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
    HTTPMixIn http = new HTTPMixIn();
    if (userPass != null && userPass.length == 2) {
        http.setRequestHeader("Authorization", "Basic " + Base64.encodeFromString(userPass[0] + ":" + userPass[1]));
    }
    http.initialize();
    try {
        String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
        //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
        LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
        String soapResponse = http.postString(endpoint, soapRequest);
        //LOGGER.info(String.format("Received work service response: %s", soapResponse));
        if (soapResponse.toLowerCase().contains("fault")) {
            throw new Exception("Error invoking work service (check server log)");
        }
    } finally {
        http.uninitialize();
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn) StringPuller(org.switchyard.common.io.pull.StringPuller)

Aggregations

StringPuller (org.switchyard.common.io.pull.StringPuller)8 HTTPMixIn (org.switchyard.component.test.mixins.http.HTTPMixIn)7 HashSet (java.util.HashSet)1 SSLContext (javax.net.ssl.SSLContext)1 Scheme (org.apache.http.conn.scheme.Scheme)1 SchemeRegistry (org.apache.http.conn.scheme.SchemeRegistry)1 SSLSocketFactory (org.apache.http.conn.ssl.SSLSocketFactory)1