我在 IBM Notes 中有一个 Java Web 提供程序。我尝试通过AgentBase访问当前的NotesSession:
import lotus.domino.AgentBase;
import lotus.domino.Session;
import lotus.domino.AgentContext;
import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.Document;
public class HwProvider extends AgentBase{
public String createOrder (String subject, String fio){
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database database = agentContext.getCurrentDatabase();
return subject + " " + fio;
}catch (Exception e) {
return e.toString();
}
}
}
我在 SOAP UI 中测试时收到此错误:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<createOrderReturn xmlns="urn:DefaultNamespace">java.lang.NullPointerException</createOrderReturn>
</soapenv:Body>
</soapenv:Envelope>
如何访问当前会话?
在 WS 提供程序中,不需要引用AgentBase
。您可以依靠Session s = WebServiceBase.getCurrentSession();
来获取当前会话。