Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define optional parameters for a method using XML-RPC.NET

I'm developing a XML-RPC service in C# using the XML-RPC.NET library. The service will be used to expose a forum to Tapatalk users

The Tapatalk API documentation states which methods should be implemented. Sometimes a parameter is specified as optional.

E.g. get_topic has 4 parameters: forum_id, start_num, last_num and mode

The method is invoked by the Tapatalk app with either all parameters or only the first 3 (so mode is omitted).

I defined the methods as follows:

[XmlRpcMethod("get_topic"]
public GetTopicResult GetTopic(string forum_id, int? start_num, int? last_num, string mode)
    

When the method is invoked with all 4 parameters specified all goes well. When mode is omitted I get the following error: Request contains too few param elements based on method signature.

Specifing mode as an optional parameter doesn't seem to do the trick:

[XmlRpcMethod("get_topic"]
public GetTopicResult GetTopic(string forum_id, int? start_num, int? last_num, string mode = "")

Trying to overload the method results in this error: Method GetTopic in type Mobiquo has duplicate XmlRpc method name get_topic

[XmlRpcMethod("get_topic"]
public GetTopicResult GetTopic(string forum_id, int? start_num, int? last_num)

[XmlRpcMethod("get_topic"]
public GetTopicResult GetTopic(string forum_id, int? start_num, int? last_num, string mode)

Any idea how I specify a parameter as optional?

Niels

like image 288
Niels R. Avatar asked Nov 11 '22 13:11

Niels R.


1 Answers

Does this help? Justing getting into the world of xml-rpc myself.

http://xml-rpc.net/faq/xmlrpcnetfaq-3-0-0.html#1.15

like image 158
Scott Decker Avatar answered Nov 14 '22 21:11

Scott Decker