【问题标题】:Fault Response Contains a String value where an Integer was Expected故障响应包含一个字符串值,其中需要一个整数
【发布时间】:2014-10-27 00:05:09
【问题描述】:

使用此代码通过 o​​penerp 获取对服务器的数据查询,并咨询了下面的代理,但返回此错误,我是新手。

[XmlRpcUrl("//IP:port/xmlrpc/common")]
public interface IOpenERPRPCClient
{
    [XmlRpcMethod("login")]
    int autenticar(string db_name, string user, string passwd);

    [XmlRpcMethod("execute")]
    int[] buscar(string db_name, int uid, string passwd, string obj, string action, object[] filtro);

    [XmlRpcMethod("execute")]
    int [] eliminar(string db_name, int uid, string passwd, string obj, string action, int[] ids);

    [XmlRpcMethod("execute")]

    object[] read_objeto(string db_name, int uid, string passwd, string obj, string action, int[] ids, string[] campos);


}

   private void button1_Click(object sender, EventArgs e)
   {

   int uid = autenticar();
   IOpenERPRPCClient proxy_clientes =  IOpenERPRPCClient)XmlRpcProxyGen.Create<IOpenERPRPCClient>();
   IXmlRpcProxy cliente_rpc = (IXmlRpcProxy)proxy_clientes;
   cliente_rpc.Url = "//IP:port/xmlrpc/object";

   object[] filtro = { "'Active','=','True'" };

   proxy_clientes.buscar("sgsoft", uid, "openerp", "res.partner","search",filtro);
   }

错误:CookComputing.XmlRpcV2.dll 中出现“CookComputing.XmlRpc.XmlRpcTypeMismatchException”类型的未处理异常

附加信息:故障响应包含字符串值,其中预期为整数[故障响应:结构映射到故障类型:成员故障代码映射到 Int32 类型]

【问题讨论】:

  • 我只是在猜测。 XML-RPC 不是很流行。该消息表明问题在于服务器正在接收您的请求,但返回错误作为响应。错误响应似乎在faultCode 字段中有一个字符串,但.NET 上的XML/RPC 期望那里有一个整数。我建议您使用 Fiddler 或类似的工具来查看网络并查看返回的内容。

标签: c# xml-rpc


【解决方案1】:

OpenErp 错误地将 faultCode 作为字符串消息返回,它应该是整数。

如果您想继续使用 XmlRpc.NET,您所能做的就是从 here 下载 3.0.0.270 测试版,这种情况在 build 238 中处理得更好。但请务必在您的 XmlRpcProxy 上设置 AllowStringFaultCode:

clientProxy.NonStandard = XmlRpcNonStandard.AllowStringFaultCode;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-26
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 2020-11-02
    • 2012-09-20
    • 1970-01-01
    相关资源
    最近更新 更多