问题解决了。只需通过将URL从服务器更改为另一台服务器来修改存根。
我所做的是添加入存根
private static String serverID;
public static void setServer(String name){
serverID=name;
}
和改变构造方法的URL “loclhost:8080 /艺术/ ......”到“loclhost:8080 /” + serverID +“/ ......”。
在client.java我做
public class client {
private static ServerStub stub;
public static void main(String[] args) {
try {
stub.setServer("Art");
stub= new ServerStub();
Register reg= new Hello();
reg.setName("Art101");
RegisterResponse replay= stub.register(reg);
System.out.println(replay.get_return());
stub.setServer("Eng");
stub= new ServerStub();
Register reg= new Hello();
reg.setName("com201");
RegisterResponse replay= stub.register(reg);
System.out.println(replay.get_return());
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}