1

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.

Giusepe
  • 655
  • 5
  • 15
  • Do you control the creation of such response? I mean... That's just solvable with code = codigo_erro status variable and the message, and having just one type. The response always returns at least 1 item in the array (no matter if it is a success or a fail). – HiperiX Nov 12 '13 at 20:27
  • No, unfortunately I don´t have any control over the response. This is provided by a external server. – Giusepe Nov 13 '13 at 11:59

0 Answers0