helloclientjndi.java

来自「为大家提供了《精通EJB》(第三版)一书的源代码」· Java 代码 · 共 32 行

JAVA
32
字号
package examples;

import java.net.URL;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.naming.Context;
import javax.naming.InitialContext;

/**
 * This class is an example of client code which invokes
 * methods on a simple stateless session bean.
 */
public class HelloClientJNDI {

    public static void main(String[] args) 
        throws Exception 
    {        
        InitialContext ctx = new InitialContext();
        Service helloService = (Service)ctx.lookup("HelloWorldWS");

        HelloInterface hello =
            (examples.HelloInterface)helloService.getPort(examples.HelloInterface.class);               
        /*
         * Call the hello() method 
         */
        System.out.println(hello.hello());

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?