【发布时间】:2016-03-31 17:54:38
【问题描述】:
尝试通过从计划的 Java 代理触发来让 Xagent 按计划运行。
以下是我的 xagentmail.xsp 的代码,它只是向我发送一封电子邮件:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
<xp:this.beforePageLoad><![CDATA[#{javascript:
// test send mail
doc = database.createDocument() ;
doc.replaceItemValue("Form", "memo");
doc.replaceItemValue("Subject", " from xagentmail.xsp");
doc.replaceItemValue("SendTo", "PDella-Nebbia@testdomain.com");
doc.send();
}]]></xp:this.beforePageLoad>
</xp:view>
使用 Devin Olson 的博客 Scheduled Xagents 中描述的 SSL-ENCRYPTED 连接方法,我创建了以下计划的 Domino Java 代理:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import javax.net.ssl.SSLSocketFactory;
import lotus.domino.AgentBase;
public class JavaAgent extends AgentBase {
// Change these settings below to your setup as required.
static final String hostName = "server1.testdomain.com";
static final String urlFilepath = "/test/poidemo.nsf/xagentmail.xsp";
static final int sslPort = 443;
public void NotesMain() {
try {
final SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
final Socket socket = factory.createSocket(JavaAgent.hostName, JavaAgent.sslPort);
final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
final BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
final StringBuilder sb = new StringBuilder();
sb.append("GET ");
sb.append(JavaAgent.urlFilepath);
sb.append(" HTTP/1.1\n");
final String command = sb.toString();
sb.setLength(0);
sb.append("Host: ");
sb.append(JavaAgent.hostName);
sb.append("\n\n");
final String hostinfo = sb.toString();
out.write(command);
out.write(hostinfo);
out.flush();
in.close();
out.close();
socket.close();
} catch (final Exception e) {
// YOUR_EXCEPTION_HANDLING_CODE
}
}
}
当我在浏览器中输入我的 xagentmail.xsp 的 URL 时,我收到了预期的邮件。
但我预定的 Java 代理没有触发 Xagent 发送邮件。
我确实使用代理和 xagent 为应用程序设置了对 Reader 的匿名访问。我在服务器上也有受限和非受限权限。
有什么想法吗?
【问题讨论】:
-
通过服务器控制台运行代理时收到什么消息?
-
您使用 (1, 2, 3) 运行代理的安全级别是多少?
-
实际上现在在客户开发服务器上盲目运行。控制台访问不是那里的选项。需要移动到测试服务器。
-
@Eric 我的 id 在服务器上具有受限和非受限权限。不知道是什么级别
-
我只是让代理调用本地主机上的 xagent(具有适当的 Internet 站点)。那么代理不需要ssl。请改用这种方法。