import javax.jws.WebMethod; import javax.jws.WebService; @WebService public interface WebServiceI { @WebMethod String sayHello(String name); }
import javax.jws.WebService; @WebService public class WebServiceImpl implements WebServiceI{ @Override public String sayHello(String name) { // TODO Auto-generated method stub return "你好-"+name; } }
發佈html
import javax.xml.ws.Endpoint; public class WebServicePublish { public static void main(String[] args) { String address = "http://192.168.1.53:12345/UserService/getService"; Endpoint.publish(address, new WebServiceImpl()); System.out.println("webService發佈成功"); } }
http://cxf.apache.org/download.html下載cfx項目解壓,配置系統環境java
maven web項目裏添加cfxweb
怎麼調用這些方法參考 http://www.javashuo.com/article/p-ymcktlrn-go.htmlapache