KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > samples > userguide > example1 > TestClient


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.example1;
18
19 import org.apache.axis.client.Call;
20 import org.apache.axis.client.Service;
21
22 import javax.xml.namespace.QName JavaDoc;
23
24 public class TestClient
25 {
26    public static void main(String JavaDoc [] args) {
27        try {
28            String JavaDoc endpoint =
29                     "http://nagoya.apache.org:5049/axis/services/echo";
30      
31            Service service = new Service();
32            Call call = (Call) service.createCall();
33
34            call.setTargetEndpointAddress( new java.net.URL JavaDoc(endpoint) );
35            call.setOperationName(new QName JavaDoc("http://soapinterop.org/", "echoString") );
36
37            // Call to addParameter/setReturnType as described in user-guide.html
38
//call.addParameter("testParam",
39
// org.apache.axis.Constants.XSD_STRING,
40
// javax.xml.rpc.ParameterMode.IN);
41
//call.setReturnType(org.apache.axis.Constants.XSD_STRING);
42

43            String JavaDoc ret = (String JavaDoc) call.invoke( new Object JavaDoc[] { "Hello!" } );
44
45            System.out.println("Sent 'Hello!', got '" + ret + "'");
46        } catch (Exception JavaDoc e) {
47            System.err.println(e.toString());
48        }
49    }
50 }
51
Popular Tags