我有一个有状态的WebService和一个无状态的WebService,它将EndPointReference返回给有状态Web服务的新实例。与此博客https://weblogs.java.net/blog/kohsuke/archive/2006/10/stateful_web_se.html
中的示例一样@Stateful
@WebService
@Addressing
class BankAccount {
protected final int id;
private int balance;
public BankAccount(int id) { this.id = id; }
@WebMethod
public void deposit(int amount) { balance+=amount; }
// either via a public static field
public static StatefulWebServiceManager<BankAccount> manager;
}
...
@WebService
class Bank { // this is ordinary stateless service
@WebMethod
public synchronized W3CEndpointReference login(int accountId) {
BankAccount acc = new BankAccount(accountId);
return BankAccount.manager.export(acc);
}
}
但是当我运行客户端并调用无状态服务方法“login”时,我得到以下异常:
javax.xml.ws.WebServiceException: No address is available for {http://server.stateful
/}BankAccountPort
我做错了什么?