KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > ws > jaxws > webserviceref > ApplicationClient


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, Red Hat Middleware LLC, and individual contributors
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.test.ws.jaxws.webserviceref;
23
24 import java.util.ArrayList JavaDoc;
25
26 import javax.naming.InitialContext JavaDoc;
27 import javax.xml.ws.WebServiceException;
28 import javax.xml.ws.WebServiceRef;
29 import javax.xml.ws.WebServiceRefs;
30
31 import org.jboss.logging.Logger;
32
33 //Test on type with wsdlLocation
34
@WebServiceRef(name = "service1", value = TestEndpointService.class, wsdlLocation = "META-INF/wsdl/TestEndpoint.wsdl")
35
36 // Test multiple on type
37
@WebServiceRefs( {
38    @WebServiceRef(name = "service2", value = TestEndpointService.class),
39    @WebServiceRef(name = "port1", value = TestEndpointService.class, type = TestEndpoint.class) })
40 public class ApplicationClient
41 {
42    // Provide logging
43
private static Logger log = Logger.getLogger(ApplicationClient.class);
44    
45    // Test on field with name
46
@WebServiceRef(name = "TestEndpointService3")
47    public static TestEndpointService service3;
48
49    // Test on field without name
50
@WebServiceRef
51    public static TestEndpointService service4;
52
53    // Test on method with value
54
@WebServiceRef(name = "TestEndpointService5")
55    public static void setServiceSetter5(TestEndpointService service)
56    {
57       ApplicationClient.service5 = service;
58    }
59    private static TestEndpointService service5;
60    
61    // Test on method without name
62
@WebServiceRef
63    public static void setServiceSetter6(TestEndpointService service)
64    {
65       ApplicationClient.service6 = service;
66    }
67    private static TestEndpointService service6;
68    
69    // Test on field with name and value
70
@WebServiceRef(name = "Port2", value = TestEndpointService.class)
71    public static TestEndpoint port2;
72
73    // Test on field with value
74
@WebServiceRef(value = TestEndpointService.class)
75    public static TestEndpoint port3;
76
77    public static InitialContext JavaDoc iniCtx;
78    public static String JavaDoc retStr;
79
80    public static void main(String JavaDoc[] args)
81    {
82       String JavaDoc inStr = args[0];
83       log.info("echo: " + inStr);
84       
85       ArrayList JavaDoc<TestEndpoint> ports = new ArrayList JavaDoc<TestEndpoint>();
86       try
87       {
88          System.out.println("FIXME: EJBTHREE-760");
89          //ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service1")).getTestEndpointPort());
90
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service2")).getTestEndpointPort());
91
ports.add((TestEndpoint)service3.getPort(TestEndpoint.class));
92          //ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/TestEndpointService3")).getTestEndpointPort());
93
ports.add((TestEndpoint)service4.getPort(TestEndpoint.class));
94          //ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/" + ApplicationClient.class.getName() + "/service4")).getTestEndpointPort());
95
ports.add((TestEndpoint)service5.getPort(TestEndpoint.class));
96          //ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/TestEndpointService5")).getTestEndpointPort());
97
ports.add((TestEndpoint)service6.getPort(TestEndpoint.class));
98          //ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/" + ApplicationClient.class.getName() + "/serviceSetter6")).getTestEndpointPort());
99
//ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/port1"));
100
ports.add(port2);
101          //ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/Port2"));
102
ports.add(port3);
103          //ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/" + ApplicationClient.class.getName() + "/port3"));
104
}
105       catch (Exception JavaDoc ex)
106       {
107          log.error("Cannot add port", ex);
108          throw new WebServiceException(ex);
109       }
110       
111       for (TestEndpoint port : ports)
112       {
113          String JavaDoc outStr = port.echo(inStr);
114          if (inStr.equals(outStr) == false)
115             throw new WebServiceException("Invalid echo return: " + inStr);
116       }
117       
118       retStr = inStr;
119    }
120
121 }
122
Popular Tags