import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class WebServiceUtil {
@WebMethod(operationName="sayHello")
@WebResult(name="helloName")
public String sayHello(@WebParam(name="oldName")String name,@WebParam(name="age")int i){
i++;
return "hello"+name;
}
@WebMethod(operationName="bye")
public void sayBye(@WebParam(name="flag")boolean f){
System.out.println("bye");
}
/**
* main方法中发布
* */
public static void main(String[] args) {
String address="http://localhost:9001/service/sayweb";
Endpoint.publish(address, new WebServiceUtil());
System.out.println("发布成功");
}
}
@WebParam表示方法的参数,@WebResult表示方法的返回值