【问题标题】:method with miltiple args - xml-rpc具有多个参数的方法 - xml-rpc
【发布时间】:2014-11-03 18:25:19
【问题描述】:

我对 XML-RPC 应用程序中具有多个参数的方法有疑问。实际上,我有对数字求和的方法......当我像这样声明这个方法时:

public Integer echo(int x, int y){

    return new Integer(x+y);

一切正常,服务器给了我正确的答案。但是有了这个:

public Integer echo(int... ys) { 
    int res = 0;
    for (int num : ys){
        res=res+num;    
    }
    return new Integer(res);
}

我有一个例外:

Klient XML-RPC: org.apache.xmlrpc.XmlRpcException: java.lang.NoSuchMethodException: xmlrpcserwer.serwerRPC.echo(int, int)

我说错了吗?

【问题讨论】:

    标签: java xml-rpc


    【解决方案1】:

    我认为您必须将服务器中的方法签名更改为:

    public Integer echo(Object[] ys) { 
      int res = 0;
      for (Object y : ys){
         if (y instanceof Integer){
            res=res+ (Integer) y;    
         }
      }
      return new Integer(res);
    }
    

    并且在客户端使用对象数组进行调用。

    我无法对其进行测试,但似乎 xmlrpc 正在寻找与您已实现的方法签名不同的方法签名。

    https://ws.apache.org/xmlrpc/types.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多