我是ws新手,正在研究官方的教材
我在用下面的客户端测试连接的时候  总是不能初始化HelloService实例
public class HelloClient {
    @WebServiceRef(wsdlLocation = "http://localhost:8080/helloservice/hello?wsdl")
    static HelloService service;
    public static void main(String[] args) {
        try {
            HelloClient client = new HelloClient();
            client.doTest(args);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }    public void doTest(String[] args) {
        try { // Call Web Service Operation
            System.out.println(
                    "Retrieving the port from the following service: "
                    + service);            Hello port = service.getHelloPort();            System.out.println("Invoking the sayHello operation on the port.");            String name;            if (args.length > 0) {
                name = args[0];
            } else {
                name = "No Name";
            }            String response = port.sayHello(name);
            System.out.println(response);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
运行结果如下:
java.lang.NullPointerException
at simpleclient.HelloClient.doTest(HelloClient.java:39)
at simpleclient.HelloClient.main(HelloClient.java:27)
这句是我java文件的39行代码 “ Hello port = service.getHelloPort();”但是当我把 下面代码
@WebServiceRef(wsdlLocation = "http://localhost:8080/helloservice/hello?wsdl")
    static HelloService service;
改成  static HelloService service = new HelloService();时就能正常运行。
拜求各位哥哥姐姐赐教。
下面是我发布的webservice  服务器端代码   发布在tomcat下,服务运行正常
package helloservice.endpoint;import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Hello {
    private String message = new String("Hello, ");    @WebMethod
    public String sayHello(String name) {
        return message + name + ".";
    }
}