Java Reference
In-Depth Information
We shall use the first method. Create a remote business interface instance using
lookup with the mapped name:
CatalogSessionEJBRemote beanRemote =(CatalogSessionEJBRemote)context.
lookup("EJB3-SessionEJB#model.CatalogSessionEJBRemote");
Invoke the test() method of the session bean and return the String value returned
from the testClient method, which is a web service operation:
catalog=beanRemote.test();
The Web Service class is listed as follows:
import javax.jws.WebService;
@WebService
public class EJB3WSImpl {
public EJB3WSImpl() {
}
public String testClient() {
String catalog = "EJB 3.0 Web Service";
try {
Properties properties = new Properties();
properties.put("java.naming.factory.initial",
"weblogic.jndi.WLInitialContextFactory");
properties.put("java.naming.provider.url",
"t3://localhost:7001");
InitialContext context = new InitialContext(properties);
CatalogSessionEJB beanRemote =
(CatalogSessionEJB)context.lookup(
"EJB3-SessionEJB#model.CatalogSessionEJB");
catalog=beanRemote.test();
} catch (NamingException e) {catalog=e.getMessage();
}
return catalog;
}
}
Creating a web service client
Next, we create a JAX-RPC Java client for the web service. First, create a Java
class EJB3WSClient . In the Java client application, create an instance of the
EJB3WSImplService service:
EJB3WSImplService service = new EJB3WSImplService();
 
Search WWH ::




Custom Search