XML-RPC.NET with two different results in the same method

176 Views Asked by At

I need to consume a XML-RPC server with a method that return different types depending on the success or failure of the process.

Right now I´m using the xml-rpc lib from http://xml-rpc.net/

My proxy looks like this:

[XmlRpcUrl("http://someURL/")]
public interface IAccount : IXmlRpcProxy
{
    [XmlRpcMethod("create_account")]
    ReturnStatusResult CreateFreeAccount(FreeAccount account);
}

Where ReturnStatusResult is:

 public class ReturnStatusResult
{
    public string code { get; set; }
    public string message { get; set; }

    public ReturnStatusDetail[] detail { get; set; }
}

And ReturnStatusDetail:

   public class ReturnStatusDetail
{
    public string codigo_erro { get; set; }
    public string[] campo_nome { get; set; }
    public string[] campo_valor { get; set; }
    public string[] campo_tipo { get; set; }
    public string[] campo_tamanho { get; set; }
    public string[] campo_obrigatorio { get; set; }
    public string[] campo_erro { get; set; }
}

If the call to CreateFreeAccount is successfull, the server will return ReturnStatusDetail[]. But if the CreateFreeAccount fail, the return will be a ReturnStatusResult.

All that been said, anyone knows a way to solve this?

I tried to look in a way to postpone the the type binding by setting the CreateFreeAccount return type to an object, but I couldn't find the xml-rpc.net parser method.

0

There are 0 best solutions below