如何在 Apache XML-RPC 服务器应用程序中实现自省?
我们有一个 Java 服务器后端,它使用 Apache XML-RPC 来提供其服务PHP 应用程序(不要问我,当我到达时它已经以这种方式构建),并希望它遵守 非官方XML-RPC 自省规范。理论上,Apache XML-RPC 对此支持,但是其页面上给出的示例 :
public class MyXmlRpcServlet extends XmlRpcServlet {
protected XmlRpcHandlerMapping newXmlRpcHandlerMapping()
throws XmlRpcException {
PropertyHandlerMapping mapping =
(PropertyHandlerMapping) newXmlRpcHandlerMapping();
XmlRpcSystemImpl.addSystemHandler(mapping);
}
}
不会编译。它显然缺少 return
语句,并且我尝试返回创建的“映射”,但是在第一个请求时,服务器(递归地?)重复调用 newXmlRpcHandlerMapping()
直到抛出java.lang.StackOverflowError
。
问题是:有谁知道如何向这样的应用程序添加内省功能?要么修复这个例子,要么提供一个可用的例子,那就太棒了。它实际上并不需要是那个规范(任何允许我们生成方法及其参数列表的东西都很好),但它似乎是一个很酷的标准(在其他非-XML-RPC 的酷世界:-) )
谢谢!
We have a Java server back-end that uses Apache XML-RPC to make its services available to PHP apps (don't ask me, it was already built this way when I arrived), and wished it to adhere to the unofficial XML-RPC introspection spec. In theory, Apache XML-RPC has support for that, but the example given on their page:
public class MyXmlRpcServlet extends XmlRpcServlet {
protected XmlRpcHandlerMapping newXmlRpcHandlerMapping()
throws XmlRpcException {
PropertyHandlerMapping mapping =
(PropertyHandlerMapping) newXmlRpcHandlerMapping();
XmlRpcSystemImpl.addSystemHandler(mapping);
}
}
will not compile. It is clearly missing a return
statement, and I've tried to return the created 'mapping', but then at the first request the server (recursively?) repeats the call to newXmlRpcHandlerMapping()
until throwing a java.lang.StackOverflowError
.
Question is: Does anyone know how to add introspection to such an app? Either fixing this example, or providing a working one would be awesome. It doesn't really need to be that spec (anything that would allow us to generate a listing of methods and their parameters would be nice), but it seems to be a cool standard (in the otherwise non-cool world of XML-RPC. :-) )
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢同事的提示,我得到了答案:重写方法正在调用自身,而不是超类的版本。这是固定代码:
一旦添加该代码并用此版本替换 web.xml 中的 XmlRpcServlet,您就可以调用内省方法!
Thanks to a coworker's tip I got the answer: the overriden method is calling itself, not the superclass' version. Here is the fixed code:
Once you add that and replace XmlRpcServlet in your web.xml with this version, you can call introspection methods!