一、类上添加注解,参数内添加注解
package SOAP;
import java.util.HashMap;
import java.util.Map;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public class MySoap {
private Map<String, Double> prices;
public MySoap() {
prices=new HashMap<String ,Double>();
prices.put("aaa", 11.11);
prices.put("bbb", 22.22);
}
public double getPrice(@WebParam(name="my")String my){
Double price=prices.get(my);
return price==null?0:price;
}
}
二、发布
package SOAP;
import javax.xml.ws.Endpoint;
public class PubTest {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/Mysoap/my", new MySoap());
}
}
三、结果