Package javax.xml.rpc

Examples of javax.xml.rpc.Call


      File wsdlFile = new File("resources/webservice/jbws309/META-INF/wsdl/OrganizationService.wsdl");
      assertTrue("wsdl file exists", wsdlFile.exists());

      ServiceFactory factory = ServiceFactory.newInstance();
      Service service = factory.createService(wsdlFile.toURL(), new QName(nsURI, "OrganizationService"));
      Call call = service.createCall(new QName(nsURI, "BasicSecuredPort"), "getContactInfo");
      call.setTargetEndpointAddress(targetAddress);

      try
      {
         call.invoke(new Object[] { "mafia" });
         fail("Security exception expected");
      }
      catch (RemoteException ignore)
      {
         // ignore expected exception
      }

      call.setProperty(Stub.USERNAME_PROPERTY, USERNAME);
      call.setProperty(Stub.PASSWORD_PROPERTY, PASSWORD);

      Object retObj = call.invoke(new Object[] { "mafia" });
      assertEquals("The 'mafia' boss is currently out of office, please call again.", retObj);
   }
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

        /* 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]});

        return ((Float) result).floatValue();
    } // getQuote1
View Full Code Here

        }

        /* Create default/empty Service and Call object */
        /************************************************/
        Service service = ServiceFactory.newInstance().createService(null);
        Call call = service.createCall();

        /* 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("http://localhost:8080/axis/servlet/AxisServlet");

        /* Set all of the stuff that would normally come from WSDL */
        /***********************************************************/
        call.setTargetEndpointAddress(opts.getURL());
        call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
        call.setProperty(Call.SOAPACTION_URI_PROPERTY, "getQuote");
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY,
                "http://schemas.xmlsoap.org/soap/encoding/");
        call.setOperationName(new QName("urn:xmltoday-delayed-quotes", "getQuote"));
        call.addParameter("symbol", XMLType.XSD_STRING, ParameterMode.IN);
        call.setReturnType(XMLType.XSD_FLOAT);

        /* 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]});

        return ((Float) result).floatValue();
    } // getQuote2
View Full Code Here

        /* 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);
        if(opts.getUser()!=null)
            call.setProperty(Call.USERNAME_PROPERTY, opts.getUser());
        if(opts.getPassword()!=null)
            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

public class JaxRpcInBinding extends OutBinding {
    private JaxRpcMarshaler marshaler = new JaxRpcMarshaler();


    protected void process(MessageExchange messageExchange, NormalizedMessage inMessage) throws MessagingException {
        Call call = marshaler.createCall(inMessage);
        Object[] params = marshaler.getCallParams(inMessage);

        call.invokeOneWay(params);
        done(messageExchange);
    }
View Full Code Here

            ServiceFactory factory = ServiceFactory.newInstance();
            Service service = factory.createService(new QName(qnameService));
   
            QName port = new QName(qnamePort);
   
            Call call = service.createCall(port);

            call.setTargetEndpointAddress(args[0]);
            call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
            call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
            call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
            QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");

            call.setReturnType(QNAME_TYPE_STRING);

            call.setOperationName(new QName(BODY_NAMESPACE_VALUE, "sayHello"));
            call.addParameter("String_1", QNAME_TYPE_STRING, ParameterMode.IN);
            String[] params = { "Murph!" };

            String result = (String) call.invoke(params);

            System.out.println(result);

        } catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

      File wsdlFile = new File("resources/webservice/jbws309/META-INF/wsdl/OrganizationService.wsdl");
      assertTrue("wsdl file exists", wsdlFile.exists());

      ServiceFactory factory = ServiceFactory.newInstance();
      Service service = factory.createService(wsdlFile.toURL(), new QName(nsURI, "OrganizationService"));
      Call call = service.createCall(new QName(nsURI, "BasicSecuredPort"), "getContactInfo");
      call.setTargetEndpointAddress(targetAddress);

      try
      {
         call.invoke(new Object[] { "mafia" });
         fail("Security exception expected");
      }
      catch (RemoteException ignore)
      {
         // ignore expected exception
      }

      call.setProperty(Stub.USERNAME_PROPERTY, USERNAME);
      call.setProperty(Stub.PASSWORD_PROPERTY, PASSWORD);

      Object retObj = call.invoke(new Object[] { "mafia" });
      assertEquals("The 'mafia' boss is currently out of office, please call again.", retObj);
   }
View Full Code Here

       /*
  * Create an instance of the Service with the given service QName
  */
            Service service = factory.createService(new QName(serviceName));

            Call call = service.createCall(new QName(portName));

            call.setTargetEndpointAddress(address);

            QName intQName = new QName("http://www.w3.org/2001/XMLSchema", "int");            /*
       * Set operation name to invoke.
       */
            call.setOperationName(new QName(namespaceURI,"add"));
            /*
       * Add parameters definitions in the call object.
       */
            call.addParameter("number1", intQName, ParameterMode.IN);
            call.addParameter("number2", intQName, ParameterMode.IN);

            /*
       * Set definition of the return type.
       */
            call.setReturnType(intQName);

            Object[] inParams = new Object[2];
            inParams[0] = new Integer(num1);
            inParams[1] = new Integer(num2);

            int value= ((Integer)call.invoke(inParams)).intValue();
            System.out.println("Result of adding " + num1 + " and " +  num2  + " is: " + value);

        }
        catch (Exception e)
        {
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.