Package javax.xml.rpc

Examples of javax.xml.rpc.Call


        /* Now use those QNames as pointers into the WSDL doc */
        /******************************************************/
        Service service = ServiceFactory.newInstance().createService(
                new URL("file:samples/stock/GetQuote.wsdl"), servQN);
        Call call = service.createCall(portQN, "getQuote");

        /* Strange - but allows the user to change just certain portions of */
        /* the URL we're gonna use to invoke the service.  Useful when you  */
        /* want to run it thru tcpmon (ie. put  -p81 on the cmd line).      */
        /********************************************************************/
        opts.setDefaultURL(call.getTargetEndpointAddress());
        call.setTargetEndpointAddress(opts.getURL());

        /* Define some service specific properties */
        /*******************************************/
        call.setProperty(Call.USERNAME_PROPERTY, opts.getUser());
        call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword());

        /* Get symbol and invoke the service */
        /*************************************/
        Object result = call.invoke(new Object[] {symbol = args[0]});

        /* Reuse the Call object for a different call */
        /**********************************************/
        call.setOperationName(new QName("urn:xmltoday-delayed-quotes", "test"));
        call.removeAllParameters();
        call.setReturnType(XMLType.XSD_STRING);

        System.out.println(call.invoke(new Object[]{}));
        return ((Float) result).floatValue();
    } // getQuote3
View Full Code Here


            System.exit(1);
        }

        String  symbol  = args[0];
        Service service = ServiceFactory.newInstance().createService(null);
        Call    call    = service.createCall();

        call.setTargetEndpointAddress(opts.getURL());
        call.setOperationName(new QName("urn:cominfo", "getInfo"));
        call.addParameter("symbol", XMLType.XSD_STRING, ParameterMode.IN);
        call.addParameter("info", XMLType.XSD_STRING, ParameterMode.IN);
        call.setReturnType(XMLType.XSD_STRING);
        call.setProperty(Call.USERNAME_PROPERTY, opts.getUser());
        call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword());

        String res = (String) call.invoke(new Object[] {args[0], args[1]});

        System.out.println(symbol + ": " + res);
    } // main
View Full Code Here

        Port port = selectPort(service.getPorts(), portName);
        if (portName == null) {
            portName = port.getName();
        }
        Binding binding = port.getBinding();
        Call call = dpf.createCall(QName.valueOf(portName),
                                   QName.valueOf(operationName));
        ((org.apache.axis.client.Call)call).setTimeout(new Integer(15*1000));
        // Output types and names
        Vector outNames = new Vector();

        // Input types and names
        Vector inNames = new Vector();
        Vector inTypes = new Vector();
        SymbolTable symbolTable = wsdlParser.getSymbolTable();
        BindingEntry bEntry =
                symbolTable.getBindingEntry(binding.getQName());
        Parameters parameters = null;
        Iterator i = bEntry.getParameters().keySet().iterator();

        while (i.hasNext()) {
            Operation o = (Operation) i.next();
            if (o.getName().equals(operationName)) {
                operation = o;
                parameters = (Parameters) bEntry.getParameters().get(o);
                break;
            }
        }
        if ((operation == null) || (parameters == null)) {
            throw new RuntimeException(operationName + " was not found.");
        }

        // loop over paramters and set up in/out params
        for (int j = 0; j < parameters.list.size(); ++j) {
            Parameter p = (Parameter) parameters.list.get(j);

            if (p.getMode() == 1) {           // IN
                inNames.add(p.getQName().getLocalPart());
                inTypes.add(p);
            } else if (p.getMode() == 2) {    // OUT
                outNames.add(p.getQName().getLocalPart());
            } else if (p.getMode() == 3) {    // INOUT
                inNames.add(p.getQName().getLocalPart());
                inTypes.add(p);
                outNames.add(p.getQName().getLocalPart());
            }
        }

        // set output type
        if (parameters.returnParam != null) {
            // Get the QName for the return Type
            QName returnType = org.apache.axis.wsdl.toJava.Utils.getXSIType(
                    parameters.returnParam);
            QName returnQName = parameters.returnParam.getQName();

            outNames.add(returnQName.getLocalPart());
        }

        if (inNames.size() != args.length - 2)
            throw new RuntimeException("Need " + inNames.size() + " arguments!!!");

        for (int pos = 0; pos < inNames.size(); ++pos) {
            String arg = args[pos + 2];
            Parameter p = (Parameter) inTypes.get(pos);
            inputs.add(getParamData((org.apache.axis.client.Call) call, p, arg));
        }
        System.out.println("Executing operation " + operationName + " with parameters:");
        for (int j = 0; j < inputs.size(); j++) {
            System.out.println(inNames.get(j) + "=" + inputs.get(j));
        }
        Object ret = call.invoke(inputs.toArray());
        Map outputs = call.getOutputParams();
        HashMap map = new HashMap();

        for (int pos = 0; pos < outNames.size(); ++pos) {
            String name = (String) outNames.get(pos);
            Object value = outputs.get(name);
View Full Code Here

    //~ Methods ----------------------------------------------------------------

    public Call createCall()
        throws ServiceException
    {
        Call call = super.createCall();
        call.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
        call.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
        return call;
    }
View Full Code Here

   public void testEchoQName() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(TARGET_NAMESPACE, "echoQName"));
      call.addParameter("QName_1", Constants.TYPE_LITERAL_QNAME, ParameterMode.INOUT);
      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      QNameHolder holder = new QNameHolder(new QName("http://somens", "localPart", "ns1"));
      Object retObj = call.invoke(new Object[]{holder});
      assertNull(retObj);
      assertEquals("{http://somens}localPartResponse", holder.value.toString());
   }
View Full Code Here

   public void testEchoShort() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(TARGET_NAMESPACE, "echoShort"));
      call.addParameter("short_1", Constants.TYPE_LITERAL_SHORT, ParameterMode.INOUT);
      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      ShortHolder holder = new ShortHolder((short)1);
      Object retObj = call.invoke(new Object[]{holder});
      assertNull(retObj);
      assertEquals(2, holder.value);
   }
View Full Code Here

   public void testEchoShortWrapper() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(TARGET_NAMESPACE, "echoShortWrapper"));
      call.addParameter("Short_1", Constants.TYPE_LITERAL_SHORT, ParameterMode.INOUT);
      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      ShortWrapperHolder holder = new ShortWrapperHolder(new Short((short)1));
      Object retObj = call.invoke(new Object[]{holder});
      assertNull(retObj);
      assertEquals(2, holder.value.shortValue());
   }
View Full Code Here

   public void testEchoString() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(TARGET_NAMESPACE, "echoString"));
      call.addParameter("String_1", Constants.TYPE_LITERAL_STRING, ParameterMode.INOUT);
      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      StringHolder holder = new StringHolder("Hello world!");
      Object retObj = call.invoke(new Object[]{holder});
      assertNull(retObj);
      assertEquals("Hello world!Response", holder.value);
   }
View Full Code Here

   public void testBoundInHeader() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(NAMESPACE_URI, "testInHeader"));
      call.addParameter("String_1", Constants.TYPE_LITERAL_STRING, ParameterMode.IN);

      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      // Add a bound header to the call
      CallImpl mycall = (CallImpl)call;
      QName xmlName = new QName(HEADER_NAMESPACE_URI, "headerMsg");
      mycall.addParameter(xmlName, Constants.TYPE_LITERAL_STRING, String.class, ParameterMode.IN, true);

      Object retObj = call.invoke(new Object[]{"Hello world!", "IN header message"});
      assertNull(retObj);
   }
View Full Code Here

   public void testBoundInOutHeader() throws Exception
   {
      Service service = ServiceFactory.newInstance().createService(new QName("testService"));

      Call call = service.createCall();
      call.setOperationName(new QName(NAMESPACE_URI, "testInOutHeader"));
      call.addParameter("String_1", Constants.TYPE_LITERAL_STRING, ParameterMode.IN);

      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);

      // Add a bound header to the call
      CallImpl mycall = (CallImpl)call;
      QName xmlName = new QName(HEADER_NAMESPACE_URI, "headerMsg");
      mycall.addParameter(xmlName, Constants.TYPE_LITERAL_STRING, String.class, ParameterMode.INOUT, true);

      StringHolder holder = new StringHolder("INOUT header message");
      Object retObj = call.invoke(new Object[]{"Hello world!", holder});
      assertNull(retObj);

      Map outputParams = call.getOutputParams();
      Object headerValue = outputParams.get(xmlName.getLocalPart());
      assertEquals("INOUT header message - response", headerValue);
      assertEquals("INOUT header message - response", holder.value);
   }
View Full Code Here

TOP

Related Classes of javax.xml.rpc.Call

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.