Examples of WSIFOperation


Examples of org.apache.wsif.WSIFOperation

                System.out.println((String) it.next());
            }
        }

        WSIFPort port = service.getPort();
        WSIFOperation operation;
        WSIFMessage inputMessage;
        WSIFMessage outputMessage;
        WSIFMessage faultMessage;

        String customerNumber;
        String tempString;
        Address address;
        ShoppingCart shoppingCart;
        Item item = null;
        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 (home): public ShoppingCart create(java.lang.String firstName, java.lang.String lastName, org.apache.wsif.ejb.sample.shop.Address address, java.lang.String customerNumber) throws org.apache.wsif.ejb.sample.shop.CreateException, javax.ejb.CreateException, java.rmi.RemoteException");

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

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

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

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

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

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

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

        debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException");

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

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

        inputMessage.setIntPart("itemQuantity", 1);

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

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

        if (operationSucceeded) {
            assertTrue(
                "addItemOperation (EJB) did not return an Item Object!!",
                outputMessage.getObjectPart("item") instanceof Item);
            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("addItemOperation");
        inputMessage = operation.createInputMessage();
        outputMessage = operation.createOutputMessage();
        faultMessage = operation.createFaultMessage();

        debug("\n---> Invocation (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException");

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

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

        inputMessage.setIntPart("itemQuantity", 12);

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

        assertTrue(
            "addItemOperation succeeded when it should have thrown an outOfStockException",
            !operationSucceeded);

        if (operationSucceeded) {
            assertTrue(
                "addItemOperation (EJB) did not return an Item Object!!",
                outputMessage.getObjectPart("item") instanceof Item);
            debug(outputMessage.getObjectPart("item"));
        } else {
            assertNotNull(
                "outputMessage should have contained outOfStockException",
                faultMessage.getObjectPart("outOfStockException"));

            /*            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 (remote): public Item addItem(java.lang.String itemNumber, java.lang.String itemName, int itemQuantity) throws org.apache.wsif.ejb.sample.shop.OutOfStockException, java.rmi.RemoteException, org.apache.wsif.ejb.sample.shop.InvalidItemException");

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

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

        inputMessage.setIntPart("itemQuantity", 8);

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

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

        if (operationSucceeded) {
            assertTrue(
                "addItemOperation (EJB) did not return an Item Object!!",
                outputMessage.getObjectPart("item") instanceof Item);
            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 (remote): public SubmitOrderResult submitOrder(org.apache.wsif.ejb.sample.shop.CreditCardInfo creditCardInfo, org.apache.wsif.ejb.sample.shop.AirMilesContainer airMilesContainer) throws java.rmi.RemoteException");

        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!!", operationSucceeded);
View Full Code Here

Examples of org.apache.wsif.WSIFOperation

          null,
          "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();

      String inputDocument =
        "<ShortZipCode xmlns=\"http://webservices.eraserver.net/\">"
          + "<accessCode>9999</accessCode>"
          + "<address>607 Trinity</address>"
          + "<city>Austin</city>"
          + "<state>TX</state>"
          + "</ShortZipCode>";

      DOMParser parser = new DOMParser();
      String xmlString = "<?xml version=\"1.0\"?>\n" + inputDocument;
      parser.parse(new InputSource(new StringReader(xmlString)));
      Element element = parser.getDocument().getDocumentElement();
      //printElement(element);

      inMsg.setObjectPart("parameters", element);

      boolean ok =
        operation.executeRequestResponseOperation(
          inMsg,
          outMsg,
          faultMsg);
      assertTrue("operation returned false!!", ok);
View Full Code Here

Examples of xsul.wsif.WSIFOperation

        wclient.addHandler(handler);
        wclient.useAsyncMessaging(correlator);
        wclient.setAsyncResponseTimeoutInMs(33000L);

        WSIFPort port = wclient.getPort();
        WSIFOperation operation = port.createOperation("Run");
        WSIFMessage inputMessage = operation.createInputMessage();
        WSIFMessage outputMessage = operation.createOutputMessage();
        WSIFMessage faultMessage = operation.createFaultMessage();

        // inputMessage.setObjectPart("InputParam1", "Hello");
        inputMessage.setObjectPart("InputParam1", "100");

        logger.info("inputMessage: "
                + XsulUtil.safeXmlToString((XmlElement) inputMessage));
        boolean success = operation.executeRequestResponseOperation(
                inputMessage, outputMessage, faultMessage);

        XmlElement result;
        if (success) {
            result = (XmlElement) outputMessage;
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.