1、建一个接口类



package ws;
import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface HelloWS {

@WebMethod
public String sayHello(String name);
}


2、建一个实现类



package ws;
import javax.jws.WebService;

@WebService
public class HelloWSImpl implements HelloWS {

@Override
public String sayHello(String name) {
// TODO Auto-generated method stub
System.out.println("Server" + name);
return "Hello"+name;
}
}


3、发布测试类



package ws;
import javax.xml.ws.Endpoint;

public class ServerTest {
public static void main(String[] args) {
String addreess = "http://localhost:8080/hellows";
Endpoint.publish(addreess, new HelloWSImpl());
System.out.println("发布成功");
}
}


4、调用成功

  浏览器访问:http://localhost:8080/hellows

使用JDK创建webService_测试类