创建 web project
如: 服务端
test
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class TestServer {
/**
* @param args
*/
public static void main(String[] args) {
Endpoint.publish("http://localhost:8888/testserver", new TestServer());
System.out.println("server success");
}
public String show(){
String ter="云涛你好吗?";
return ter;
}
}
Endpoint.publish("http://localhost:8888/testserver", new TestServer());
访问的地址 http://localhost:8888/testserver 8888 端口号不能占了,写个没占有的 ,testserver 这个是随意写的
new TestServer() // 这个是这个类名
客户端
创建 web project
如:testcli
建好就行了
在命令提示窗口执行生成命令
wsimport -s F:\w2017\works\\testcli\\src -p test -keep http://localhhost:8888/testserver?wsdl
-s 后面是 客户端项目的地址+项目+项目src
-p 是放在客户端 项目的那个包下
-keep 是服务端的那个配置的 必须要有wsdl
刷新项目 就生产了代码
创建一个类测试 TestCli
import test.TestServer;
import test.TestServerService;
public class Testcli {
/**
* @param args
*/
public static void main(String[] args) {
//调用 service
TestServer ter = new TestServerService().getTestServerPort();
String ters =ter.show();
System.out.println(ters);
}
}