1 /*
2  * @(#) $Id: EchoClient2.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10import javax.xml.namespace.QName;
11import javax.xml.rpc.ServiceFactory;
12import javax.xml.rpc.Service;
13import javax.xml.rpc.Call;
14
15public class EchoClient2 {
16    public static void main(String [] args) throws Exception {
17        String epAddr = "https://localhost:8443/axis/services/StringEchoPort1";
18        String wsdlAddr = epAddr + "?wsdl";
19        String nameSpaceUri = "http://www.pankaj-k.net/jsbook/examples/";
20        String svcName = "StringEchoService1";
21        String portName = "StringEchoPort1";
22
23        java.net.URL wsdlUrl = new java.net.URL(wsdlAddr);
24        ServiceFactory svcFactory = ServiceFactory.newInstance();
25        QName svcQName = new QName(nameSpaceUri, svcName);
26        Service svc = svcFactory.createService(wsdlUrl, svcQName);
27
28        Call call = (Call) svc.createCall();
29
30        call.setTargetEndpointAddress(epAddr);
31        call.setOperationName( new QName(nameSpaceUri, "echo") );
32        call.setPortTypeName( new QName(nameSpaceUri, portName) );
33
34        Object arg = "Hi, How are you?";
35        System.out.println("sending: " + arg );
36        String res = (String) call.invoke(new Object[] {arg});
37        System.out.println("received: " + res );
38    }
39}
40