Search in sources :

Example 21 with HTTPMixIn

use of org.switchyard.component.test.mixins.http.HTTPMixIn 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 22 with HTTPMixIn

use of org.switchyard.component.test.mixins.http.HTTPMixIn 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 23 with HTTPMixIn

use of org.switchyard.component.test.mixins.http.HTTPMixIn in project quickstarts by jboss-switchyard.

the class HttpBindingClient method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("Usage: HttpBindingClient stock-quote-symbol");
        return;
    } else {
        int port = DEFAULT_PORT;
        String portstr = System.getProperty(KEY_PORT);
        if (portstr != null) {
            port = Integer.parseInt(portstr);
        }
        HTTPMixIn http = new HTTPMixIn();
        http.initialize();
        String endpointURL = "http://localhost:" + port + "/http-binding/quote";
        System.out.println(" Request: " + endpointURL + " -> " + args[0]);
        String response = http.sendString(endpointURL, args[0], HTTPMixIn.HTTP_POST);
        System.out.println("Response: " + response);
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn)

Example 24 with HTTPMixIn

use of org.switchyard.component.test.mixins.http.HTTPMixIn in project quickstarts by jboss-switchyard.

the class SoapBindingClient method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("Usage: SoapBindingClient <some_name>");
        return;
    } else {
        HTTPMixIn http = new HTTPMixIn();
        http.initialize();
        String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
        SOAPUtil.prettyPrint(http.postString("http://localhost:" + port + "/soap-binding-rpc/HelloWorldWSService", String.format(SOAP_TEMPLATE, args[0], "English")), System.out);
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn)

Example 25 with HTTPMixIn

use of org.switchyard.component.test.mixins.http.HTTPMixIn in project quickstarts by jboss-switchyard.

the class JAXBClient method main.

/**
     * Only execution point for this application.
     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
public static void main(final String[] ignored) throws Exception {
    HTTPMixIn soapMixIn = new HTTPMixIn();
    soapMixIn.initialize();
    try {
        String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
        String url = "http://localhost:" + port + "/quickstart-transform-jaxb/OrderService";
        String result = soapMixIn.postFile(url, XML);
        System.out.println("SOAP Reply:\n" + result);
    } finally {
        soapMixIn.uninitialize();
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn)

Aggregations

HTTPMixIn (org.switchyard.component.test.mixins.http.HTTPMixIn)29 StringPuller (org.switchyard.common.io.pull.StringPuller)7 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 File (java.io.File)1 IOException (java.io.IOException)1