复制并改名
清空src内容
新建 一个接口
OrderWS .java
package com.day01.spring.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import com.day01.spring.bean.Order;
@WebService
public interface OrderWS {
@WebMethod
public Order getOrderById(int id);
}
新建 一个Order.java
package com.day01.spring.bean;
public class Order {
private int id;
private String name;
private double price;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public String toString() {
return "Order [id=" + id + ", name=" + name + ", price=" + price + "]";
}
public Order(int id, String name, double price) {
super();
this.id = id;
this.name = name;
this.price = price;
}
public Order() {
super();
}
}
定义实现
OrderWSImpl.java
package com.day01.spring.ws;
import javax.jws.WebService;
import com.day01.spring.bean.Order;
@WebService
public class OrderWSImpl implements OrderWS {
@Override
public Order getOrderById(int id) {
System.out.println("服务器端getOrderById被调用了,id="+id);
return new Order(id,"飞机",100000);
}
}
发布
新建 一个web工程