KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > NewClient


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
18 import org.apache.axis.client.Call;
19 import org.apache.axis.client.Service;
20 import org.apache.axis.encoding.XMLType;
21 import org.apache.axis.utils.Options;
22
23 import javax.xml.namespace.QName JavaDoc;
24 import javax.xml.rpc.ParameterMode JavaDoc;
25
26 /**
27  * Test soap client to access a test end point on the JasperServer WS interface
28  *
29  * Should be able to compile and run if $AXISCLASSPATH is on the class path
30  * the AXISCLASSPATH setting are set up by hand following the suggestion
31  * in the axis documentation.
32  *
33  */

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