Package org.apache.axis.utils

Examples of org.apache.axis.utils.Options


     * Arguments are of the form:
     *   -h localhost -p 8080 -s /soap/servlet/rpcrouter
     */
    public static void main(String args[]) throws Exception {
        // set up the call object
        Options opts = new Options(args);
        service = new Service();
        call = (Call) service.createCall();
        call.setTargetEndpointAddress( new URL(opts.getURL()) );
        call.setUseSOAPAction(true);
        call.setSOAPActionURI("http://www.soapinterop.org/Bid");

        // register the PurchaseOrder class
        QName poqn = new QName("http://www.soapinterop.org/Bid",
View Full Code Here


    // helper function; does all the real work
    public float getQuote (String args[]) throws Exception {
        Call.addTransportPackage("samples.transport");
        Call.setTransportForProtocol("tcp", TCPTransport.class);
       
        Options opts = new Options( args );
       
        args = opts.getRemainingArgs();
       
        if ( args == null ) {
            System.err.println( "Usage: GetQuote <symbol>" );
            System.exit(1);
        }
       
        String namespace = "urn:xmltoday-delayed-quotes";
        symbol = args[0] ;

        EngineConfiguration defaultConfig =
            (new DefaultEngineConfigurationFactory()).
            getClientEngineConfig();
        SimpleProvider config = new SimpleProvider(defaultConfig);
        SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
        config.deployTransport("tcp", c);

        Service service = new Service(config);
        Call call = (Call)service.createCall();
       
        call.setTransport(new TCPTransport());
       
        call.setTargetEndpointAddress( new URL(opts.getURL()) );
        call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") );
        call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
        call.setReturnType( XMLType.XSD_FLOAT );
       
        // TESTING HACK BY ROBJ
        if (symbol.equals("XXX_noaction")) {
            symbol = "XXX";
        }
       
        call.setUsername( opts.getUser() );
        call.setPassword( opts.getPassword() );
       
        // useful option for profiling - perhaps we should remove before
        // shipping?
        String countOption = opts.isValueSet('c');
        int count=1;
        if ( countOption != null) {
            count=Integer.valueOf(countOption).intValue();
            System.out.println("Iterating " + count + " times");
        }
View Full Code Here

     * that directory.
     */
    public static void main(String args[]) {
        try {

            Options opts = new Options(args);
            EchoAttachment echoattachment = new EchoAttachment(opts);

            args = opts.getRemainingArgs();
            int argpos = 0;

            if (args == null || args.length == 0) {
                System.err.println("Need a file or directory argument.");
                System.exit(8);
View Full Code Here

    }

    public TCPListener (String[] args) {
        // look for -p, -d arguments
        try {
            Options options = new Options(args);
            port = new URL(options.getURL()).getPort();
        } catch (MalformedURLException ex) {
            log.error("Hosed URL: "+ex);
            System.exit(1);
        }
View Full Code Here

    /**
     * This will use the WSDL to prefill all of the info needed to make
     * the call.  All that's left is filling in the args to invoke().
     */
    public float getQuote1(String args[]) throws Exception {
        Options opts = new Options(args);

        args = opts.getRemainingArgs();

        if (args == null) {
            System.err.println("Usage: GetQuote <symbol>");
            System.exit(1);
        }

        /* Define the service QName and port QName */
        /*******************************************/
        QName servQN = new QName("urn:xmltoday-delayed-quotes",
                "GetQuoteService");
        QName portQN = new QName("urn:xmltoday-delayed-quotes", "GetQuote");

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

View Full Code Here

    /**
     * This will do everything manually (ie. no WSDL).
     */
    public float getQuote2(String args[]) throws Exception {
        Options opts = new Options(args);

        args = opts.getRemainingArgs();

        if (args == null) {
            System.err.println("Usage: GetQuote <symbol>");
            System.exit(1);
        }

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

View Full Code Here

    /**
     * This method does the same thing that getQuote1 does, but in
     * addition it reuses the Call object to make another call.
     */
    public float getQuote3(String args[]) throws Exception {
        Options opts = new Options(args);

        args = opts.getRemainingArgs();

        if (args == null) {
            System.err.println("Usage: GetQuote <symbol>");
            System.exit(1);
        }

        /* Define the service QName and port QName */
        /*******************************************/
        QName servQN = new QName("urn:xmltoday-delayed-quotes",
                "GetQuoteService");
        QName portQN = new QName("urn:xmltoday-delayed-quotes", "GetQuote");

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

View Full Code Here

     * that directory.
     */
    public static void main(String args[]) {
        try {

            Options opts = new Options(args);
            TestRef echoattachment = new TestRef(opts);

            args = opts.getRemainingArgs();
            int argpos=0;

            if (echoattachment.testit()) {
                System.out.println("Attachments sent and received ok!");
                System.exit(0);
View Full Code Here

* @author Russell Butek (butek@us.ibm.com)
*/
public class GetInfo {

    public static void main(String args[]) throws Exception {
        Options opts = new Options(args);

        args = opts.getRemainingArgs();

        if (args == null || args.length % 2 != 0) {
            System.err.println("Usage: GetInfo <symbol> <datatype>");
            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

     * Arguments are of the form:
     *   -h localhost -p 8080 -s /soap/servlet/rpcrouter
     * -h indicats the host
     */
    public static void main(String args[]) throws Exception {
        Options opts = new Options(args);

        boolean testPerformance = opts.isFlagSet('k') > 0;
        boolean allTests = opts.isFlagSet('A') > 0;
        boolean onlyB    = opts.isFlagSet('b') > 0;
        boolean testMode = opts.isFlagSet('t') > 0;

        // set up tests so that the results are sent to System.out
        TestClient client;

        if (testPerformance) {
            client = new TestClient(testMode) {
               public void verify(String method, Object sent, Object gotBack) {
               }
            };
        } else {
            client = new TestClient(testMode) {
            public void verify(String method, Object sent, Object gotBack) {
                String message;
                if (this.equals(sent, gotBack)) {
                    message = "OK";
                } else {
                    if (gotBack instanceof Exception) {
                        if (gotBack instanceof AxisFault) {
                            message = "Fault: " +
                                ((AxisFault)gotBack).getFaultString();
                        } else {
                            StringWriter sw = new StringWriter();
                            PrintWriter pw = new PrintWriter(sw);
                            message = "Exception: ";
                            ((Exception)gotBack).printStackTrace(pw);
                            message += sw.getBuffer().toString();
                        }
                    } else {
                        message = "Fail:" + gotBack + " expected " + sent;
                    }
                }
                // Line up the output
                String tab = "";
                int l = method.length();
                while (l < 25) {
                    tab += " ";
                    l++;
                }
                System.out.println(method + tab + " " + message);
            }
        };
        }

        // set up the call object
        client.setURL(opts.getURL());

        if (testPerformance) {
            long startTime = System.currentTimeMillis();
            for (int i = 0; i < 10; i++) {
                if (allTests) {
View Full Code Here

TOP

Related Classes of org.apache.axis.utils.Options

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.