Search in sources :

Example 26 with HTTPMixIn

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

the class ServiceTransformationClient 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-smooks/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)

Example 27 with HTTPMixIn

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

the class RESTEasyBindingClient method main.

public static void main(String[] args) throws Exception {
    int port = DEFAULT_PORT;
    String portstr = System.getProperty(KEY_PORT);
    if (portstr != null) {
        port = Integer.parseInt(portstr);
    }
    String baseUrl = "http://localhost:" + port + "/rest-binding";
    String command = null;
    if (args.length == 0) {
        System.out.println("Usage: RESTEasyBindingClient new|get|add|del [orderId] [itemId]");
        System.out.println("  new - create a new Order");
        System.out.println("  get - retreive an Order");
        System.out.println("  add - add an item to an Order");
        System.out.println("  del - delete an item from an Order");
        System.out.println("\t CamelCxfRsBindingClient new");
        System.out.println("\t CamelCxfRsBindingClient get 1");
        System.out.println("\t CamelCxfRsBindingClient add 1 1 10");
        System.out.println("\t CamelCxfRsBindingClient del 1 3");
        return;
    } else {
        command = args[0];
        HTTPMixIn http = new HTTPMixIn();
        http.initialize();
        if (command.equals("new")) {
            String response = http.sendString(baseUrl + "/inventory", "", HTTPMixIn.HTTP_GET);
            if (response.equals("false")) {
                http.sendString(baseUrl + "/inventory/create", "", HTTPMixIn.HTTP_OPTIONS);
            }
            System.out.println(http.sendString(baseUrl + "/order", "", HTTPMixIn.HTTP_POST));
        } else if (command.equals("get")) {
            if (args.length != 2) {
                System.out.println("No orderId found!");
                System.out.println("Usage: get <orderId>");
            }
            System.out.println(http.sendString(baseUrl + "/order/" + args[1], "", HTTPMixIn.HTTP_GET));
        } else if (command.equals("add")) {
            if (args.length < 2) {
                System.out.println("No orderId found!");
                System.out.println("Usage: get <orderId> <itemId> <quantity>");
            }
            if (args.length < 3) {
                System.out.println("No itemId found!");
                System.out.println("Usage: get <orderId> <itemId> <quantity>");
            }
            if (args.length < 4) {
                System.out.println("No quantity found!");
                System.out.println("Usage: get <orderId> <itemId> <quantity>");
            }
            String order = "<order>" + "    <orderId>" + args[1] + "</orderId>" + "    <orderItem>" + "        <item>" + "            <itemId>" + args[2] + "</itemId>" + "         </item>" + "         <quantity>" + args[3] + "</quantity>" + "     </orderItem>" + "</order>";
            System.out.println(http.sendString(baseUrl + "/order/item", order, HTTPMixIn.HTTP_PUT));
        } else if (command.equals("del")) {
            if (args.length < 2) {
                System.out.println("No orderId found!");
                System.out.println("Usage: get <orderId> <itemId>");
            }
            if (args.length < 3) {
                System.out.println("No itemId found!");
                System.out.println("Usage: get <orderId> <itemId>");
            }
            System.out.println(http.sendString(baseUrl + "/order/" + args[1] + ":" + args[2], "", HTTPMixIn.HTTP_DELETE));
        }
    }
}
Also used : HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn)

Example 28 with HTTPMixIn

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

the class JAXBClient method main.

public static void main(String[] args) throws Exception {
    System.out.print("Give name for greeting: ");
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    HTTPMixIn http = new HTTPMixIn();
    http.initialize();
    String request = JAXBUtil.marshal(new GreetingRequest(reader.readLine()));
    System.out.println("Sending request\n" + request);
    String port = System.getProperty("org.switchyard.component.http.client.port", "8080");
    String reply = http.sendString("http://localhost:" + port + "/camel-binding", request, HTTPMixIn.HTTP_POST);
    System.out.println("Received response\n" + reply);
}
Also used : InputStreamReader(java.io.InputStreamReader) HTTPMixIn(org.switchyard.component.test.mixins.http.HTTPMixIn) BufferedReader(java.io.BufferedReader)

Example 29 with HTTPMixIn

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

the class BPELClient method main.

/**
     * Only execution point for this application.
     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
public static void main(final String[] args) throws Exception {
    HTTPMixIn soapMixIn = new HTTPMixIn();
    soapMixIn.initialize();
    String xmldir = args[0];
    try {
        String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
        String url = "http://localhost:" + port + "/xts_wsat/BusinessTravelService";
        String result = soapMixIn.postFile(url, xmldir + XML);
        System.out.println("SOAP Reply:\n" + result);
        result = soapMixIn.postFile(url, xmldir + XML_COMPLETE);
        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