服务器端
接口
package test.cxf.server;
import javax.jws.WebService;
@WebService
public interface HelloCXF {
public String say(String name);
}
实现
package test.cxf.server;
import javax.jws.WebService;
@WebService(endpointInterface="test.cxf.server.HelloCXF")
public class HelloCXFImpl implements HelloCXF {
public String say(String name) {
String str="hello,"+name+",this is my first cxf!";
return str;
}
}
发布
package test.cxf.server;
import javax.xml.ws.Endpoint;
public class ServerMain {
public static void main(String[] args) {
HelloCXFImpl implementor = new HelloCXFImpl();
String address = "http://localhost:8080/hellocxf";
Endpoint.publish(address, implementor);
System.out.println("started");
}
}
命令:wsdl2java -client -p test.cxf.client -d e:/ http://localhost:8080/hellocxf?wsdl
生成客户端,放到项目里,运行xxxx_Client.java,可看到运行结果
生成的客户端的java文件:
所用jar包