使用 xwiki 和 Apache xml-rpc 抛出异常

Exception thrown using xwiki and Apache xml-rpc

我正在使用以下代码更新汇合页面:

public void publish() throws IOException {
    XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(CONFLUENCE_URI);

    try {
        rpc.login(USER_NAME, PASSWORD);
        //The info macro would get rendered an info box in the Page
        Page page = new Page();
        page.setSpace("ATF");
        page.setTitle("New Page");
        page.setContent("New Page Created \\ {{info}}This is XMLRPC Test{{/info}}");
        page.setParentId("demo UTF Home");

            rpc.storePage(page);
        } catch (XmlRpcException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

}

当我尝试 运行 程序时,出现以下异常:

org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse server's response: Expected methodResponse element, got html

这看起来像是 Apache xml-rpc 客户端中的一个错误,该客户端使用此 JIRA: https://issues.apache.org/jira/browse/XMLRPC-159

说是在库的3.1.2中修复了,我用的是3.1.3。

有人以前看过这个吗?

也许服务器真的返回了HTML;有时它只是 returns 一个 200,因为那里总是会产生 HTML。在这种情况下,您链接到的 XMLRPC 库中的错误修正不适用。

要检查这种可能性,您可以查看请求的 url 和状态代码(应该是 200)的服务器访问日志;使用此信息,您可以重播请求,例如在浏览器或命令行客户端中,如 wgetcurl,查看真正返回的响应。