KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > jaxrpchandler2 > JAXRPCHandler2TestCase


1 package test.wsdl.jaxrpchandler2;
2
3 import junit.framework.TestCase;
4
5 import javax.xml.namespace.QName JavaDoc;
6 import javax.xml.rpc.Call JavaDoc;
7 import javax.xml.rpc.Service JavaDoc;
8 import javax.xml.rpc.ServiceFactory JavaDoc;
9 import java.rmi.RemoteException JavaDoc;
10
11 public class JAXRPCHandler2TestCase extends TestCase {
12
13     public JAXRPCHandler2TestCase(String JavaDoc arg0) {
14         super(arg0);
15     }
16
17     public void testJAXRPCHandler2() throws Exception JavaDoc {
18         String JavaDoc serviceEndpointUrl =
19                 "http://localhost:8080/axis/services/EchoService2";
20         String JavaDoc qnameService = "EchoService2";
21         String JavaDoc qnamePort = "EchoServicePort";
22         Call JavaDoc call;
23         String JavaDoc echoString = "my echo string";
24         ServiceFactory JavaDoc serviceFactory = ServiceFactory.newInstance();
25         Service JavaDoc service = serviceFactory.createService(new QName JavaDoc(qnameService));
26         call = service.createCall(new QName JavaDoc(qnamePort));
27         call.setTargetEndpointAddress(serviceEndpointUrl);
28         call.setOperationName(new QName JavaDoc("http://soapinterop.org/", "echo"));
29         String JavaDoc returnString = null;
30         try {
31             returnString = (String JavaDoc) call.invoke(new Object JavaDoc[]{echoString});
32         } catch (RemoteException JavaDoc e) {
33             e.printStackTrace();
34             fail("Remote exception while calling invoke");
35         }
36         assertEquals("returnString does not match echoString",
37                 echoString,
38                 returnString);
39     }
40
41     public void testJAXRPCHandler3() throws Exception JavaDoc {
42         String JavaDoc serviceEndpointUrl =
43                 "http://localhost:8080/axis/services/EchoService3";
44         String JavaDoc qnameService = "EchoService3";
45         String JavaDoc qnamePort = "EchoServicePort";
46         Call JavaDoc call;
47         String JavaDoc echoString = "Joe";
48         ServiceFactory JavaDoc serviceFactory = ServiceFactory.newInstance();
49         Service JavaDoc service = serviceFactory.createService(new QName JavaDoc(qnameService));
50         call = service.createCall(new QName JavaDoc(qnamePort));
51         call.setTargetEndpointAddress(serviceEndpointUrl);
52         call.setOperationName(new QName JavaDoc("http://soapinterop.org/", "echo"));
53         String JavaDoc returnString = null;
54         try {
55             returnString = (String JavaDoc) call.invoke(new Object JavaDoc[]{echoString});
56         } catch (RemoteException JavaDoc e) {
57             e.printStackTrace();
58             fail("Remote exception while calling invoke");
59         }
60         assertEquals(
61                 "Sam",
62                 returnString);
63     }
64
65     protected void setUp() throws Exception JavaDoc {
66         super.setUp();
67     }
68
69 }
70
Popular Tags