KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > stock > GetInfo


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package samples.stock ;
18
19 import org.apache.axis.client.Call;
20 import org.apache.axis.client.Service;
21 import org.apache.axis.encoding.XMLType;
22 import org.apache.axis.utils.Options;
23
24 import javax.xml.namespace.QName JavaDoc;
25 import javax.xml.rpc.ParameterMode JavaDoc;
26
27 /**
28  *
29  * @author Doug Davis (dug@us.ibm.com.com)
30  */

31 public class GetInfo {
32
33   public static void main(String JavaDoc args[]) {
34     try {
35       Options opts = new Options( args );
36
37       args = opts.getRemainingArgs();
38
39       if ( args == null || args.length % 2 != 0 ) {
40         System.err.println( "Usage: GetInfo <symbol> <datatype>" );
41         System.exit(1);
42       }
43
44       String JavaDoc symbol = args[0] ;
45       Service service = new Service();
46       Call call = (Call) service.createCall();
47
48       call.setTargetEndpointAddress( new java.net.URL JavaDoc(opts.getURL()) );
49       call.setOperationName( new QName JavaDoc("urn:cominfo", "getInfo") );
50       call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
51       call.addParameter( "info", XMLType.XSD_STRING, ParameterMode.IN );
52       call.setReturnType( XMLType.XSD_STRING );
53       call.setUsername( opts.getUser() );
54       call.setPassword( opts.getPassword() );
55
56       String JavaDoc res = (String JavaDoc) call.invoke( new Object JavaDoc[] { args[0], args[1] } );
57
58       System.out.println( symbol + ": " + res );
59     }
60     catch( Exception JavaDoc e ) {
61       e.printStackTrace();
62     }
63   }
64
65 }
66
67
Popular Tags