2014-09-02 61 views
2

使用此代碼可以使用openerp向服務器獲取數據查詢,並與下面的代理進行協商,但返回此錯誤,我是新手。故障響應包含一個字符串值,其中整數是預期的

[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); 
    } 

ERROR:類型的未處理的異常「CookComputing.XmlRpc.XmlRpcTypeMismatchException」發生在CookComputing.XmlRpcV2.dll

其他信息:故障響應包含字符串值,其中整數預期[故障響應:STRUCT映射到類型錯誤:成員faultCode映射到Int32類型]

+0

我只是猜測。 XML-RPC不是很流行。該消息表明問題在於服務器正在接收您的請求,但返回錯誤作爲響應。錯誤響應似乎在'faultCode'字段中有一個字符串,但是.NET上的XML/RPC期望在那裏有一個整數。我建議你使用Fiddler或類似的東西來查看網絡並查看返回的內容。 – 2014-09-02 22:25:31

回答

1

OpenErp錯誤地返回faultCode作爲字符串消息,它應該是整數。

所有,如果你想繼續使用XmlRpc.NET是從here下載3.0.0.270 beta版,這種情況下,在建238更好地處理,但一定要設置AllowStringFaultCode您XmlRpcProxy你可以這樣做:

clientProxy.NonStandard = XmlRpcNonStandard.AllowStringFaultCode; 
相關問題