Examples of WSIFOperation


Examples of org.apache.wsif.WSIFOperation

    public java.util.Date echoDate(java.util.Date argInputDate)
        throws WSIFException {

        WSIFPort port = this.svc.getPort();

        WSIFOperation operation =
            port.createOperation("echoDate", "echoDateRequest", "echoDateResponse");

        WSIFMessage inputMessage = operation.createInputMessage();
        inputMessage.setName("echoDateRequest");

        WSIFMessage outputMessage = operation.createOutputMessage();
        outputMessage.setName("echoDateResponse");

        inputMessage.setObjectPart("inputDate", argInputDate);

        operation.executeRequestResponseOperation(inputMessage, outputMessage, null);

        port.close();

        return (java.util.Date) outputMessage.getObjectPart("return");
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
        WSIFService service = factory.getService(wsdl, null, null, null, null);

        WSIFPort port = service.getPort();

        WSIFOperation operation;
        WSIFMessage inputMessage;
        WSIFMessage outputMessage;
        WSIFMessage faultMessage;

        String tempString;

        Object part;
        boolean operationSucceeded;

        /**********************************************************
         * Test calling a service that takes a char as an argument
         **********************************************************/
        operation = port.createOperation("setCharOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        inputMessage.setObjectPart("in", "a");

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("setChar failed!!", operationSucceeded);

        if (operationSucceeded) {
            assertTrue(
                "setChar did not return a boolean",
                outputMessage.getObjectPart("out") instanceof Boolean);
            assertTrue("setChar did not return true", ((Boolean) outputMessage.getObjectPart("out")).booleanValue());
            debug("setChar returned "+ outputMessage.getObjectPart("out"));
        } else {
      debug("operation failed");
        }

        /**********************************************************
         * Test calling a service that returns a char
         **********************************************************/
        operation = port.createOperation("getCharOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        inputMessage.setBooleanPart("in", true);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("getChar failed!!", operationSucceeded);

        if (operationSucceeded) {
            assertTrue(
                "getChar did not return a String",
                outputMessage.getObjectPart("out") instanceof String);
            debug("getChar returned "+ outputMessage.getObjectPart("out"));
        } else {
      debug("operation failed");
        }
       
        /*************************************************************
         * Test calling a service that takes a char[][] as an argument
         *************************************************************/
        operation = port.createOperation("setCharArrayOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

    String[][] sa = new String[][] {{"a", "b"},{"d", "e", "g"}};

        inputMessage.setObjectPart("in", sa);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("setCharArray failed!!", operationSucceeded);

        if (operationSucceeded) {
            assertTrue(
                "setCharArray did not return a boolean",
                outputMessage.getObjectPart("out") instanceof Boolean);
            assertTrue("getCharArray did not return true", ((Boolean) outputMessage.getObjectPart("out")).booleanValue());               
            debug("setCharArray returned "+ outputMessage.getObjectPart("out"));
        } else {
      debug("operation failed");
        }
       
        /*************************************************************
         * Test calling a service that returns a char[][]
         *************************************************************/
        operation = port.createOperation("getCharArrayOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

    inputMessage.setBooleanPart("in", true);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("getCharArray failed!!", operationSucceeded);
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

     */
    public byte[] echoHexBinary(byte[] argInputHexBinary) throws WSIFException {

        WSIFPort port = this.svc.getPort();

        WSIFOperation operation =
            port.createOperation(
                "echoHexBinary",
                "echoHexBinaryRequest",
                "echoHexBinaryResponse");

        WSIFMessage inputMessage = operation.createInputMessage();
        inputMessage.setName("echoHexBinaryRequest");

        WSIFMessage outputMessage = operation.createOutputMessage();
        outputMessage.setName("echoHexBinaryResponse");

        inputMessage.setObjectPart("inputHexBinary", argInputHexBinary);

        operation.executeRequestResponseOperation(inputMessage, outputMessage, null);

        port.close();

        return (byte[]) outputMessage.getObjectPart("return");

View Full Code Here

Examples of org.apache.wsif.WSIFOperation

        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
        WSIFService dpf = factory.getService(def, service, portType);
        WSIFPort port = (portName == null) ? dpf.getPort() : dpf.getPort(portName);

        System.out.println("HeadersTest executing getQuote for \"\"" + operationName);
        WSIFOperation operation =
            port.createOperation("getQuote", inputName, outputName);
        WSIFMessage input = operation.createInputMessage();
        WSIFMessage output = operation.createOutputMessage();
        WSIFMessage fault = operation.createFaultMessage();
        input.setObjectPart("symbol", "");

        // set a basic authentication header
        WSIFMessage headers = operation.getContext();
        headers.setObjectPart(WSIFConstants.CONTEXT_HTTP_USER, "petra");
        headers.setObjectPart(WSIFConstants.CONTEXT_HTTP_PSWD, "washere");
        operation.setContext(headers);

        boolean ok = operation.executeRequestResponseOperation(input, output, fault);
        System.out.println("operation returned " + ok);

        float q = ((Float) output.getObjectPart("quote")).floatValue();

        if (q == -1.0F) {
            assertTrue(true);
        } else {
            assertTrue(false);
        }

        // do it agian without context so you can see the difference
        System.out.println(
            "HeadersTest no headers executing getQuote for \"\"" + operationName);
        operation = port.createOperation("getQuote", inputName, outputName);
        input = operation.createInputMessage();
        output = operation.createOutputMessage();
        fault = operation.createFaultMessage();
        input.setObjectPart("symbol", "");
        ok = operation.executeRequestResponseOperation(input, output, fault);
        q = ((Float) output.getObjectPart("quote")).floatValue();
        if (q == -1.0F) {
            assertTrue(true);
        } else {
            assertTrue(false);
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

    public java.math.BigDecimal echoDecimal(java.math.BigDecimal argInputDecimal)
        throws WSIFException {

        WSIFPort port = this.svc.getPort();

        WSIFOperation operation =
            port.createOperation(
                "echoDecimal",
                "echoDecimalRequest",
                "echoDecimalResponse");

        WSIFMessage inputMessage = operation.createInputMessage();
        inputMessage.setName("echoDecimalRequest");

        WSIFMessage outputMessage = operation.createOutputMessage();
        outputMessage.setName("echoDecimalResponse");

        inputMessage.setObjectPart("inputDecimal", argInputDecimal);

        operation.executeRequestResponseOperation(inputMessage, outputMessage, null);

        port.close();

        return (java.math.BigDecimal) outputMessage.getObjectPart("return");
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

     */
    public boolean echoBoolean(boolean argInputBoolean) throws WSIFException {

        WSIFPort port = this.svc.getPort();

        WSIFOperation operation =
            port.createOperation(
                "echoBoolean",
                "echoBooleanRequest",
                "echoBooleanResponse");

        WSIFMessage inputMessage = operation.createInputMessage();
        inputMessage.setName("echoBooleanRequest");

        WSIFMessage outputMessage = operation.createOutputMessage();
        outputMessage.setName("echoBooleanResponse");

        inputMessage.setObjectPart(
            "inputBoolean",
            new java.lang.Boolean(argInputBoolean));

        operation.executeRequestResponseOperation(inputMessage, outputMessage, null);

        port.close();

        return ((java.lang.Boolean) outputMessage.getObjectPart("return"))
            .booleanValue();
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

                    null,
                    "http://jms/",
                    "JmsFault");

            WSIFPort port = service.getPort("default");
            WSIFOperation operation = port.createOperation(method);

            WSIFMessage inputMessage = operation.createInputMessage();
            inputMessage.setIntPart("choice",choice);
            WSIFMessage outputMessage = operation.createOutputMessage();
            WSIFMessage faultMessage = operation.createFaultMessage();

            boolean operationSucceeded = false;
            if (blocks == SYNC) {
                operationSucceeded =
                    operation.executeRequestResponseOperation(
                        inputMessage,
                        outputMessage,
                        faultMessage);

            } else if (blocks == ASYNC) {
                WSIFMessage context = operation.getContext();
                context.setObjectPart(
                    WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
                    TestUtilities.getWsifProperty("wsif.async.replytoq2"));
                operation.setContext(context);

                WSIFCorrelationId id =
                    operation.executeRequestResponseAsync(inputMessage);
                System.out.println(
                    "async operation done, correlation id="
                        + id.getCorrelationId());

                Object jmsResponse =
                    TestUtilities.getJMSAsyncResponse(
                        id.getCorrelationId(),
                        TestUtilities.getWsifProperty("wsif.async.replytoq2"));

                operationSucceeded =
                    operation.processAsyncResponse(
                        jmsResponse,
                        outputMessage,
                        faultMessage);

            } else
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

            }
        }

        WSIFPort port = service.getPort();

        WSIFOperation operation;
        WSIFMessage inputMessage;
        WSIFMessage outputMessage;
        WSIFMessage faultMessage;

        String customerNumber;
        String tempString;
        Address address;
        ShoppingCart_Java shoppingCart;
        Item item;
        CreditCardInfo creditCardInfo;
        AirMilesContainer airMilesContainer;
        Integer currentTotal = null;
        Long orderConfirmationNumber;
        Integer itemQuantity;
        Object part;
        boolean operationSucceeded;

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("createOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public ShoppingCart_Java(String firstName, String lastName, Address address, String customerNumber)");

        tempString = "Albert";
        inputMessage.setObjectPart("firstName", tempString);

        tempString = "Einstein";
        inputMessage.setObjectPart("lastName", tempString);

        address = new Address("Berlin", "Unter den Linden");
        inputMessage.setObjectPart("address", address);

        customerNumber = "AE001";
        inputMessage.setObjectPart("customerNumber", customerNumber);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("Failed to create a ShoppingCart", operationSucceeded);

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("addItemOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)");

        tempString = "100123";
        inputMessage.setObjectPart("itemNumber", tempString);

        item = new Item();
        //inputMessage.setObjectPart("item", item);

        tempString = "Pocket calculator";
        inputMessage.setObjectPart("itemName", tempString);

        itemQuantity = new Integer(1);
        inputMessage.setObjectPart("itemQuantity", itemQuantity);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("addItem test failed", operationSucceeded);

        if (operationSucceeded) {
      assertTrue("Part is not an Item!!!",
        outputMessage.getObjectPart("item") instanceof Item);
            debug(outputMessage.getObjectPart("item"));
        } else {
            // Cannot get here since test would have already failed!
        }

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("addItemOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)");

        tempString = "234123";
        inputMessage.setObjectPart("itemNumber", tempString);

        item = new Item();
        inputMessage.setObjectPart("item", item);

        tempString = "Pencil";
        inputMessage.setObjectPart("itemName", tempString);

        itemQuantity = new Integer(12);
        inputMessage.setObjectPart("itemQuantity", itemQuantity);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue(
            "addItem succeeded when it should have thrown a outOfStockException",
            !operationSucceeded);

        if (operationSucceeded) {
            debug(outputMessage.getObjectPart("item"));
        } else {
            assertNotNull(
                "outputMessage should have contained outOfStockException",
                faultMessage.getObjectPart("outOfStockException"));

            // Extra steps useful for debugging
            /*            part = faultMessage.getObjectPart("invalidItemException");
                        if (part != null) {
                            debug(faultMessage.getName() + ":\n" + part);
                        } else {
                            part = faultMessage.getObjectPart("outOfStockException");
                            if (part != null) {
                                debug(faultMessage.getName() + ":\n" + part);
                            } else {
                                debug("ERROR: Unknown fault message!");
                            }
                        }
            */
        }

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("addItemOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public int addItem(String itemNumber, Item item, String itemName, int itemQuantity)");

        inputMessage.setObjectPart("itemNumber", "234123");

        item = new Item();
        inputMessage.setObjectPart("item", item);

        inputMessage.setObjectPart("itemName", "Pencil");

        inputMessage.setIntPart("itemQuantity", 8);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue("addItem failed when it should have succeeded", operationSucceeded);

        //Extra steps useful for debugging
        /*        part = faultMessage.getObjectPart("invalidItemException");
                if (operationSucceeded) {
                    debug(outputMessage.getObjectPart("item"));
                } else {
                    part = faultMessage.getObjectPart("invalidItemException");
                    if (part != null) {
                        debug(faultMessage.getName() + ":\n" + part);
                    } else {
                        part = faultMessage.getObjectPart("outOfStockException");
                        if (part != null) {
                            debug(faultMessage.getName() + ":\n" + part);
                        } else {
                            debug("ERROR: Unknown fault message!");
                        }
                    }
                }*/

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("submitOrderOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public long submitOrder(CreditCardInfo creditCardInfo, AirMilesContainer airMilesContainer)");

        creditCardInfo = new CreditCardInfo();
        inputMessage.setObjectPart("creditCardInfo", creditCardInfo);

        airMilesContainer = new AirMilesContainer();
        inputMessage.setObjectPart("airMilesContainer", airMilesContainer);

        inputMessage.setLongPart("orderConfirmationNumber", 0);

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue(
            "submitOrderOperation failed when it should have succeeded.",
            operationSucceeded);

        debug(
            "order confirmation no. = "
                + outputMessage.getObjectPart("orderConfirmationNumber"));
        debug(airMilesContainer);

        // -----------------------------------------------------------------------------------------------------
        operation = port.createOperation("queryOrdersOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation: public static Orders queryOrders(String customerNumber)");

        inputMessage.setObjectPart("customerNumber", "AE001");

        operationSucceeded =
            operation.executeRequestResponseOperation(
                inputMessage,
                outputMessage,
                faultMessage);

        assertTrue(
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

          "http://webservices.eraserver.net/",
          "ZipCodeResolverSoap");

      WSIFPort port = service.getPort(portName);

      WSIFOperation operation = port.createOperation("ShortZipCode");

      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();
      inMsg.setObjectPart("accessCode", "9999");
      inMsg.setObjectPart("address", "607 Trinity");
      inMsg.setObjectPart("city", "Austin");
      inMsg.setObjectPart("state", "TX");

      boolean ok =
        operation.executeRequestResponseOperation(
          inMsg,
          outMsg,
          faultMsg);

      assertTrue("operation returned false!!", ok);
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

                   "ShortZipCodeResponse"),
               ShortZipCodeResponse.class );

      WSIFPort port = service.getPort(portName);

      WSIFOperation operation = port.createOperation("ShortZipCode");

      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();

            ShortZipCode zc = new ShortZipCode();
            zc.setAccessCode("9999");
            zc.setAddress("607 Trinity");
            zc.setCity("Austin");
            zc.setState("TX");

      inMsg.setObjectPart("parameters", zc);

      boolean ok =
        operation.executeRequestResponseOperation(
          inMsg,
          outMsg,
          faultMsg);

      assertTrue("operation returned false!!", ok);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.