KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > userguide > example3 > Client


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.userguide.example3;
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 public class Client
28 {
29     public static void main(String JavaDoc [] args)
30     {
31         try {
32             Options options = new Options(args);
33             
34             String JavaDoc endpointURL = options.getURL();
35             String JavaDoc textToSend;
36             
37             args = options.getRemainingArgs();
38             if ((args == null) || (args.length < 1)) {
39                 textToSend = "<nothing>";
40             } else {
41                 textToSend = args[0];
42             }
43             
44             Service service = new Service();
45             Call call = (Call) service.createCall();
46
47             call.setTargetEndpointAddress( new java.net.URL JavaDoc(endpointURL) );
48             call.setOperationName( new QName JavaDoc("http://example3.userguide.samples", "serviceMethod") );
49             call.addParameter( "arg1", XMLType.XSD_STRING, ParameterMode.IN);
50             call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );
51
52             String JavaDoc ret = (String JavaDoc) call.invoke( new Object JavaDoc[] { textToSend } );
53             
54             System.out.println("You typed : " + ret);
55         } catch (Exception JavaDoc e) {
56             System.err.println(e.toString());
57         }
58     }
59 }
60
Popular Tags