1 22 package org.jboss.test.ws.jaxws.webserviceref; 23 24 import java.util.ArrayList ; 25 26 import javax.ejb.Remote ; 27 import javax.ejb.Stateless ; 28 import javax.naming.InitialContext ; 29 import javax.xml.ws.WebServiceException; 30 import javax.xml.ws.WebServiceRef; 31 import javax.xml.ws.WebServiceRefs; 32 33 import org.jboss.annotation.ejb.RemoteBinding; 34 import org.jboss.logging.Logger; 35 36 @Remote (EJB3Remote.class) 38 @RemoteBinding(jndiBinding = "/ejb3/EJB3Client") 39 @Stateless 40 41 @WebServiceRef(name = "service1", value = TestEndpointService.class, wsdlLocation = "META-INF/wsdl/TestEndpoint.wsdl") 43 44 @WebServiceRefs( { 46 @WebServiceRef(name = "service2", value = TestEndpointService.class), 47 @WebServiceRef(name = "port1", value = TestEndpointService.class, type = TestEndpoint.class) }) 48 public class EJB3Client implements EJB3Remote 49 { 50 private static Logger log = Logger.getLogger(EJB3Client.class); 52 53 @WebServiceRef(name = "TestEndpointService3") 55 public TestEndpointService service3; 56 57 @WebServiceRef 59 public TestEndpointService service4; 60 61 @WebServiceRef(name = "TestEndpointService5") 63 public void setServiceSetter5(TestEndpointService service) 64 { 65 this.service5 = service; 66 } 67 private TestEndpointService service5; 68 69 @WebServiceRef 71 public void setServiceSetter6(TestEndpointService service) 72 { 73 this.service6 = service; 74 } 75 private TestEndpointService service6; 76 77 @WebServiceRef(name = "Port2", value = TestEndpointService.class) 79 public TestEndpoint port2; 80 81 @WebServiceRef(value = TestEndpointService.class) 83 public TestEndpoint port3; 84 85 public String echo(String inStr) 86 { 87 log.info("echo: " + inStr); 88 89 ArrayList <TestEndpoint> ports = new ArrayList <TestEndpoint>(); 90 try 91 { 92 InitialContext iniCtx = new InitialContext (); 93 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service1")).getTestEndpointPort()); 94 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service2")).getTestEndpointPort()); 95 ports.add((TestEndpoint)service3.getPort(TestEndpoint.class)); 96 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/TestEndpointService3")).getTestEndpointPort()); 97 ports.add((TestEndpoint)service4.getPort(TestEndpoint.class)); 98 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/" + getClass().getName() + "/service4")).getTestEndpointPort()); 99 ports.add((TestEndpoint)service5.getPort(TestEndpoint.class)); 100 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/TestEndpointService5")).getTestEndpointPort()); 101 ports.add((TestEndpoint)service6.getPort(TestEndpoint.class)); 102 ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/" + getClass().getName() + "/serviceSetter6")).getTestEndpointPort()); 103 ports.add((TestEndpoint)iniCtx.lookup("java:comp.ejb3/env/port1")); 104 ports.add(port2); 105 ports.add((TestEndpoint)iniCtx.lookup("java:comp.ejb3/env/Port2")); 106 ports.add(port3); 107 ports.add((TestEndpoint)iniCtx.lookup("java:comp.ejb3/env/" + getClass().getName() + "/port3")); 108 } 109 catch (Exception ex) 110 { 111 log.error("Cannot add port", ex); 112 throw new WebServiceException(ex); 113 } 114 115 for (TestEndpoint port : ports) 116 { 117 String outStr = port.echo(inStr); 118 if (inStr.equals(outStr) == false) 119 throw new WebServiceException("Invalid echo return: " + inStr); 120 } 121 122 return inStr; 123 } 124 } 125 | Popular Tags |