Package org.apache.wsif

Examples of org.apache.wsif.WSIFOperation


      if (!port.supportsAsync()) {
        return;
      }

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

      AsyncResponseHandler abHandler = new AsyncResponseHandler(1);
      // 1 async call

      WSIFMessage inMsg = op.createInputMessage();
      inMsg.setObjectPart("name", "fred");

      WSIFMessage outmsg = op.createOutputMessage();
      WSIFMessage faultMsg = op.createFaultMessage();

      WSIFMessage context = op.getContext();
      context.setObjectPart(
        WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
        TestUtilities.getWsifProperty("wsif.async.replytoq"));

      if ("SOAPJMSPort2".equals(portName)
        || "NativeJmsPort2".equals(portName)) {
        inMsg.setObjectPart("asyncTimeout", "" + spa2);
      }
      if ("SOAPJMSPort3".equals(portName)
        || "NativeJmsPort3".equals(portName)
        || "SOAPJMSPort6".equals(portName)
        || "NativeJmsPort6".equals(portName)) {
        context.setObjectPart(
          WSIFConstants.WSIF_PROP_ASYNC_TIMEOUT,
          "" + spa3);
      }

      op.setContext(context);

      WSIFCorrelationId id =
        op.executeRequestResponseAsync(inMsg, abHandler);
      assertTrue(
        "null correlation id returned from async request!",
        id != null);

      int i = 30;
View Full Code Here


          null,
                    "http://mime/",
                    "Mime");

      WSIFPort port = service.getPort(portName);
      WSIFOperation operation = port.createOperation("stringToDataHandler");
      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();

            String content = "The owl and the pussy cat went to sea in a beautiful pea-green boat,";

            String inputDoc =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                " <soapenv:Body>" +
                "    <ns1:stringToDataHandler soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"http://mime/\">" +
                "       <ns1:buff xsi:type=\"xsd:string\">" +
                content +
                "</ns1:buff>" +
                "    </ns1:stringToDataHandler>" +
                " </soapenv:Body>" +
                "</soapenv:Envelope>";           

      DOMParser parser = new DOMParser();

      parser.parse(new InputSource(new StringReader(inputDoc)));
      Element element = parser.getDocument().getDocumentElement();
      NodeList l = element.getChildNodes();
      Element e1 = (Element)l.item(1);
      l = e1.getChildNodes();
      element = (Element)l.item(1);
      Node n = e1.getFirstChild();
      n = n.getNextSibling();
            element = (Element) n;
//      printElement(element);
                 
      inMsg.setObjectPart("buff", element);

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

          null,
                    "http://mime/",
                    "Mime");

      WSIFPort port = service.getPort(portName);
      WSIFOperation operation = port.createOperation("bounceImage4");
      WSIFMessage inMsg = operation.createInputMessage();
      WSIFMessage outMsg = operation.createOutputMessage();
      WSIFMessage faultMsg = operation.createFaultMessage();

            String inputDoc =
                  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                  "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                  " <soapenv:Body>" +
                  "  <ns1:bounceImage4 soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"http://mime/\">" +
                  "   <ns1:shouldBounce xsi:type=\"xsd:boolean\">true</ns1:shouldBounce>" +
                  "   <ns1:file href=\"cid:413B07CE410E48EB9D89DC0A4DDD715D\"/>" +
                  "  </ns1:bounceImage4>" +
                  " </soapenv:Body>" +
                  "</soapenv:Envelope>";

      DOMParser parser = new DOMParser();

      parser.parse(new InputSource(new StringReader(inputDoc)));
      Element element = parser.getDocument().getDocumentElement();
      NodeList l = element.getChildNodes();
      Element e1 = (Element)l.item(1);
      l = e1.getChildNodes();
      element = (Element)l.item(1);
      Node n = e1.getFirstChild();
      n = n.getNextSibling();
            element = (Element) n;
//      printElement(element);
                 
      inMsg.setObjectPart("shouldBounce", element);
     
            DataHandler dh1 = new DataHandler(new FileDataSource(IMAGE_LOCATION));
      inMsg.setObjectPart("file", dh1);

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

    private static void addFirstAddress(WSIFPort port) {
  try {
      // create the operation
      // note that we have two operations with the same name, so we need to specify the
      // name of the input and output messages as well
      WSIFOperation operation = port.createOperation("addEntry","AddEntryWholeNameRequest",null);
      // create the input message associated with this operation
      WSIFMessage input = operation.createInputMessage();
      // populate the input message
      input.setObjectPart("name","John Smith");
      // create an address object to populate the input
      Address address = new Address();
      address.setStreetNum(25);
      address.setStreetName("Willow Road");
      address.setCity("MyTown");
      address.setState("PA");
      address.setZip(28382);
      Phone phone = new Phone();
      phone.setAreaCode(288);
      phone.setExchange("555");
      phone.setNumber("9891");
      address.setPhoneNumber(phone);
      input.setObjectPart("address",address);
      // do the invocation
      System.out.println("Adding address for John Smith...");
      operation.executeInputOnlyOperation(input);
  } catch (WSIFException we) {
      System.out.println("Got exception from WSIF, details:");
      we.printStackTrace();
  }
    }
View Full Code Here

    private static void addSecondAddress(WSIFPort port) {
  try {
      // create the operation
      // note that we have two operations with the same name, so we need to specify the
      // name of the input and output messages as well
      WSIFOperation operation = port.createOperation("addEntry","AddEntryFirstAndLastNamesRequest",null);
      // create the input message associated with this operation
      WSIFMessage input = operation.createInputMessage();
      // populate the input message
      input.setObjectPart("firstName","Jane");
      input.setObjectPart("lastName","White");
      // create an address object to populate the input
      Address address = new Address();
      address.setStreetNum(20);
      address.setStreetName("Peachtree Avenue");
      address.setCity("Atlanta");
      address.setState("GA");
      address.setZip(39892);
      Phone phone = new Phone();
      phone.setAreaCode(701);
      phone.setExchange("555");
      phone.setNumber("8721");
      address.setPhoneNumber(phone);
      input.setObjectPart("address",address);
      // do the invocation
      System.out.println("Adding address for Jane White...");
      operation.executeInputOnlyOperation(input);
  } catch (WSIFException we) {
      System.out.println("Got exception from WSIF, details:");
      we.printStackTrace();
  }
    }
View Full Code Here

    }

    private static void queryAddresses(WSIFPort port) {
  try {
      // create the operation
      WSIFOperation operation = port.createOperation("getAddressFromName");
      // create the input message associated with this operation
      WSIFMessage input = operation.createInputMessage();
      WSIFMessage output = operation.createOutputMessage();
      WSIFMessage fault = operation.createFaultMessage();
      // populate the input message
      input.setObjectPart("name","John Smith");
      // do the invocation
      System.out.println("Querying address for John Smith...");
      if (operation.executeRequestResponseOperation(input,output,fault)) {
    // invocation succeeded
    // extract the address from the output message
    Address address = (Address) output.getObjectPart("address");
    System.out.println("Service returned the following address:");
    System.out.println(address.getStreetNum()+" "+address.getStreetName()+
           ", "+address.getCity()+" "+address.getState()+" "+
           address.getZip()+"; Phone: ("+
           address.getPhoneNumber().getAreaCode()+") "+
           address.getPhoneNumber().getExchange()+"-"+
           address.getPhoneNumber().getNumber());
      } else {
    // invocation failed, check fault message
      }
      // create the operation
      operation = port.createOperation("getAddressFromName");
      // create the input message associated with this operation
      input = operation.createInputMessage();
      output = operation.createOutputMessage();
      fault = operation.createFaultMessage();
      // populate the input message
      input.setObjectPart("name","Jane White");
      // do the invocation
      System.out.println("Querying address for Jane White...");
      if (operation.executeRequestResponseOperation(input,output,fault)) {
    // invocation succeeded
    // extract the address from the output message
    Address address = (Address) output.getObjectPart("address");
    System.out.println("Service returned the following address:");
    System.out.println(address.getStreetNum()+" "+address.getStreetName()+
View Full Code Here

            WSIFPort port = null;

            port = service.getPort(portName);

            WSIFOperation operation =
                port.createOperation("addEntry", "AddEntryWholeNameRequest", null);

            WSIFMessage inputMessage = operation.createInputMessage();
            WSIFMessage outputMessage = operation.createOutputMessage();
            WSIFMessage faultMessage = operation.createFaultMessage();

            // Create a name and address to add to the addressbook
            String nameToAdd = "Chris P. Bacon";
            Address addressToAdd =
                new Address(
                    1,
                    "The Waterfront",
                    "Some City",
                    "NY",
                    47907,
                    new Phone(765, "494", "4900"));

            // Add the name and address to the input message
            inputMessage.setObjectPart("name", nameToAdd);
            inputMessage.setObjectPart("address", addressToAdd);

            // Execute the operation, obtaining a flag to indicate its success
            operation.executeInputOnlyOperation(inputMessage);

            // Start from fresh
            operation = null;
            inputMessage = null;
            outputMessage = null;
            faultMessage = null;

            operation = port.createOperation("getAddressFromName");

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

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

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

            if (operationSucceeded) {
                System.out.println(
                    "Successfull lookup of name '" + nameToLookup + "' in addressbook");

                // We can obtain the address that was found by querying the output message
                Address addressFound = (Address) outputMessage.getObjectPart("address");
                System.out.println("The address found was:");
                System.out.println(addressFound);
            } else {
                System.out.println("Failed to lookup name in addressbook");
            }

            // Check that we can't reuse an operation.           
            boolean caughtException = false;
            try {
                operationSucceeded =
                    operation.executeRequestResponseOperation(
                        inputMessage,
                        outputMessage,
                        faultMessage);
            } catch (WSIFException we) {
                caughtException = true;
View Full Code Here

            if (!port.supportsAsync() ) {
              return;
            }   

            WSIFOperation op = port.createOperation( "getAddressFromName" );
           
            AsyncResponseHandler abHandler = new AsyncResponseHandler( 1 ); // 1 async call

            WSIFMessage inMsg = op.createInputMessage();
            inMsg.setObjectPart( "name", name );

            WSIFMessage outmsg = op.createOutputMessage();
            WSIFMessage faultMsg = op.createFaultMessage();

            WSIFMessage context = op.getContext();
            context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo",
                                   TestUtilities.getWsifProperty("wsif.async.replytoq") );
            op.setContext( context );

            WSIFCorrelationId id = op.executeRequestResponseAsync(inMsg, abHandler);
            assertTrue("null correlation id returned from async request!", id != null );

            int i = 10;
            while (i-- > 0 && !abHandler.isDone()) {
                System.out.println( "waiting for async responses - " + i );
View Full Code Here

   * Query Stockquote sample
   */
  public void doitStockquote(String portName, String protocol, String fakeFile, String error) {
    float value;
    WSIFPort port;
    WSIFOperation operation;
    WSIFMessage input, output, fault, context;

    if (portName.toUpperCase().indexOf("JMS") != -1
        && !TestUtilities.areWeTesting("jms")) {
        return;
    }

    TestUtilities.setProviderForProtocol( protocol );

    System.out.println("\n=== StockQuote");
    try {
      WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
        WSIFService service = factory.getService( WSDL_LOCATION,
          null, // serviceNS
        null, // serviceName
            "http://wsifservice.stockquote/", // portTypeNS
        "StockquotePT" ); // portTypeName

      port = service.getPort(portName);

      // Executing executeRequestResponseAsync(input)
      operation = port.createOperation( "getQuote" );

      context = operation.getContext();
      context.setObjectPart(
         WSIFConstants.CONTEXT_JMS_PREFIX + "WSIF_FAKE",
         "\"" + fakeFile + "\"" );

      input = operation.createInputMessage();
      input.setName("GetQuoteInput");
      input.setObjectPart("symbol", "" );
      output = operation.createOutputMessage();

      //output = doAsyncOpNoHandler( operation, input, context );
      doSyncOp( operation, input, output, context );
     
      Object o;
View Full Code Here

                new javax.xml.namespace.QName(
                    "http://wsiftypes.addressbook/",
                    "phone"),
                Class.forName("addressbook.wsiftypes.Phone"));                   
            WSIFPort port = service.getPort(server+"Port");
            WSIFOperation op = port.createOperation("addEntry", "AddEntryWholeNameRequest", null);           
            doItPort(port, "WSIFPort_ApacheSOAP");
            WSIFOperation op2 = port.createOperation("addEntry", "AddEntryWholeNameRequest", null);
            WSIFMessage inputMessage = op2.createInputMessage();
            WSIFMessage outputMessage = op2.createOutputMessage();
            WSIFMessage faultMessage = op2.createFaultMessage();

            // Create a name and address to add to the addressbook
            String nameToAdd = "Chris P. Bacon";
            Address addressToAdd =
                new Address(
                    1,
                    "The Waterfront",
                    "Some City",
                    "NY",
                    47907,
                    new Phone(765, "494", "4900"));

            // Add the name and address to the input message
            inputMessage.setObjectPart("name", nameToAdd);
            inputMessage.setObjectPart("address", addressToAdd);

            // Execute the operation, obtaining a flag to indicate its success
            op2.executeInputOnlyOperation(inputMessage);             
        } catch (Exception e) {
            System.out.println(
                "\nAn error occured when running testWSIFPort_ApacheSOAP " + e);
            assertTrue(false);
        }
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.