Package org.apache.wsif

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


                Output opOutput = op.getOutput();
                outputName = (opOutput.getName() == null) ? null : opOutput.getName();
            }
        }

        WSIFOperation operation =
            port.createOperation(operationName, inputName, outputName);
        WSIFMessage input = operation.createInputMessage();
        WSIFMessage output = operation.createOutputMessage();
        WSIFMessage fault = operation.createFaultMessage();

        // retrieve list of names and types for input and names for output
        List operationList = portType.getOperations();

        // find portType operation to prepare in/oout message w/ parts
        boolean found = false;
        String[] outNames = new String[0];
        Class[] outTypes = new Class[0];
        for (Iterator i = operationList.iterator(); i.hasNext();) {
            Operation op = (Operation) i.next();
            String name = op.getName();
            if (!name.equals(operationName)) {
                continue;
            }
            if (found) {
                throw new RuntimeException("overloaded operations are not supported in this sample");
            }
            found = true;

            //System.err.println("op = "+op);
            Input opInput = op.getInput();

            // first determine list of arguments
            String[] inNames = new String[0];
            Class[] inTypes = new Class[0];
            if (opInput != null) {
                List parts = opInput.getMessage().getOrderedParts(null);
                unWrapIfWrappedDocLit(parts, name, def);
                int count = parts.size();
                inNames = new String[count];
                inTypes = new Class[count];
                retrieveSignature(parts, inNames, inTypes);
            }
            // now prepare out parameters

            for (int pos = 0; pos < inNames.length; ++pos) {
                String arg = args[pos + argShift];
                Object value = null;
                Class c = inTypes[pos];
                if (c.equals(String.class)) {
                    value = arg;
                } else if (c.equals(Double.TYPE)) {
                    value = new Double(arg);
                } else if (c.equals(Float.TYPE)) {
                    value = new Float(arg);
                } else if (c.equals(Integer.TYPE)) {
                    value = new Integer(arg);
                } else if (c.equals(Boolean.TYPE)) {
                    value = new Boolean(arg);
                } else {
                    throw new RuntimeException("not know how to convert '" + arg + "' into " + c);
                }

                input.setObjectPart(inNames[pos], value);
            }

            Output opOutput = op.getOutput();
            if (opOutput != null) {
                List parts = opOutput.getMessage().getOrderedParts(null);
                unWrapIfWrappedDocLit(parts, name+"Response", def);
                int count = parts.size();
                outNames = new String[count];
                outTypes = new Class[count];
                retrieveSignature(parts, outNames, outTypes);
            }

        }
        if (!found) {
            throw new RuntimeException(
                "no operation "
                    + operationName
                    + " was found in port type "
                    + portType.getQName());
        }

        System.out.println("Executing operation " + operationName);
        operation.executeRequestResponseOperation(input, output, fault);

        HashMap map = new HashMap();
        for (int pos = 0; pos < outNames.length; ++pos) {
            String name = outNames[pos];
            map.put(name, output.getObjectPart(name));
View Full Code Here

        "ShoppingCart_JavaPortType" //  portTypeName
    );

        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();

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

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

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

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

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

        operation.executeInputOnlyOperation(inputMessage);

        // -----------------------------------------------------------------------------------------------------
        // First add something to the basket
        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", "100123");

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

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

        inputMessage.setIntPart("itemQuantity", 1);

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

        assertTrue("addItem test failed", operationSucceeded);

        if (operationSucceeded) {
          assertTrue(
                "addItemOperation (EJB) did not return an Item Object!!",
                outputMessage.getObjectPart("item") instanceof Item);
            debug(outputMessage.getObjectPart("item"));
            debug("Current total = " + outputMessage.getObjectPart("currentTotal"));
        } else {
            // Cannot get here since test would have already failed!
        }

        // -----------------------------------------------------------------------------------------------------
        // Test an "Input Only" operation by invoking the emptyBasket method
        operation = port.createOperation("emptyOrderOperation");
        inputMessage = operation.createInputMessage();

        debug("\n---> Invocation: public void emptyOrder(String customerNumber)");

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

        operation.executeInputOnlyOperation(inputMessage);

        // -----------------------------------------------------------------------------------------------------
        // Add to the basket again - the basket should be empty before this if previous operation worked!!
        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", "100123");

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

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

        inputMessage.setIntPart("itemQuantity", 5);

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

        assertTrue("addItem test failed", operationSucceeded);
View Full Code Here

        "ShoppingCart_EJBPortType" //  portTypeName
    );

        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);

        // -----------------------------------------------------------------------------------------------------
        // First add something to the basket
        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!");
                }
            }
        }

        // -----------------------------------------------------------------------------------------------------
        // Test an "Input Only" operation by invoking the emptyBasket method       
        operation = port.createOperation("emptyOrderOperation");
        inputMessage = operation.createInputMessage();

        debug("\n---> Invocation: public void emptyOrder(String customerNumber)");

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

        operation.executeInputOnlyOperation(inputMessage);

        // -----------------------------------------------------------------------------------------------------
        // Add to the basket again - the basket should be empty before this if previous operation worked!!
        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", 5);

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

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

                   "SingleTagResponse"),
               SingleTagResponse.class );

      WSIFPort port = service.getPort(portName);

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

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

            SingleTag_ElemType stet = new SingleTag_ElemType();
            stet.setSingleTag(new SingleTag_Type());
           
      inMsg.setObjectPart("parameters", stet);

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

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

                   "SimpleDocumentResponse"),
               SimpleDocumentResponse.class );

      WSIFPort port = service.getPort(portName);

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

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

            SimpleDocument_ElemType sdtet = new SimpleDocument_ElemType();
            SimpleDocument_Type sdt = new SimpleDocument_Type();
            sdt.setValue("petra");
            sdtet.setSimpleDocument(sdt);

      inMsg.setObjectPart("parameters", sdtet);

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

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

            context.setObjectPart(WSIFConstants.CONTEXT_OPERATION_STYLE, WSIFConstants.CONTEXT_OPERATION_STYLE_WRAPPED);
            service.setContext(context);

      WSIFPort port = service.getPort(portName);

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

      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();
     
      boolean ok =
        operation.executeRequestResponseOperation(
          inMsg,
          outMsg,
          faultMsg);

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

                   "ComplexDocumentResponse"),
               ComplexDocumentResponse.class );

      WSIFPort port = service.getPort(portName);

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

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

            ComplexDocument_ElemType cdtet = new ComplexDocument_ElemType();
            ComplexDocument_Type cdt = makeComplexDocument();
            checkComplexDocument(cdt);
            cdtet.setComplexDocument(cdt);

      inMsg.setObjectPart("parameters", cdtet);

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

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

               new javax.xml.namespace.QName("http/www.pointwsp.net/ws/finance", "currency"),
               Currency.class);

      WSIFPort port = service.getPort(portName);

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

      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();
     
      String inputDocument =
        "<GetRatesXML xmlns=\"http/www.pointwsp.net/ws/finance\"/>";

      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

          "phone"),
        Class.forName("addressbook.wsiftypes.Phone"));

      WSIFPort port = service.getPort(portName);

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

      // Create the messages
      WSIFMessage inputMessage = operation.createInputMessage();
      WSIFMessage outputMessage = operation.createOutputMessage();
      WSIFMessage faultMessage = operation.createFaultMessage();

      // Set the name to find in the addressbook
      String nameToLookup = "Chris P. Bacon";
      inputMessage.setObjectPart("name", nameToLookup);

      if ("SOAPJMSPort2".equals(portName)
        || "NativeJmsPort2".equals(portName)) {
        inputMessage.setObjectPart("syncTimeout", "" + sps2);
      }
      if ("SOAPJMSPort3".equals(portName)
        || "NativeJmsPort3".equals(portName)
        || "SOAPJMSPort6".equals(portName)
        || "NativeJmsPort6".equals(portName)) {
        WSIFMessage context = operation.getContext();
        context.setObjectPart(
          WSIFConstants.WSIF_PROP_SYNC_TIMEOUT,
          "" + sps3);
        operation.setContext(context);
      }

      // Execute the operation
      Date first = new Date();
      boolean operationSucceeded =
        operation.executeRequestResponseOperation(
          inputMessage,
          outputMessage,
          faultMessage);

      if (operationSucceeded) {
View Full Code Here

TOP

Related Classes of org.apache.wsif.WSIFOperation

Copyright © 2018 www.massapicom. 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.