[英]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 . 我正在使用XML-RPC.NET库在C#中开发XML-RPC服务。 The service will be used to expose a forum to Tapatalk users
该服务将用于向Tapatalk用户公开论坛
The Tapatalk API documentation states which methods should be implemented. Tapatalk API文档说明了应该实现哪些方法。 Sometimes a parameter is specified as optional.
有时将参数指定为可选参数。
Eg get_topic
has 4 parameters: forum_id
, start_num
, last_num
and mode
例如,
get_topic
有4个参数: forum_id
, start_num
, last_num
和mode
The method is invoked by the Tapatalk app with either all parameters or only the first 3 (so mode
is omitted). Tapatalk应用程序使用所有参数调用该方法,或仅调用前3个(因此省略了
mode
)。
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. 当使用指定的所有4个参数调用该方法时,一切顺利。 When
mode
is omitted I get the following error: Request contains too few param elements based on method signature.
省略
mode
出现以下错误: 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
尝试重载该方法会导致此错误:
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 尼尔斯
Does this help? 这有帮助吗? Justing getting into the world of xml-rpc myself.
只是自己进入xml-rpc的世界。
http://xml-rpc.net/faq/xmlrpcnetfaq-3-0-0.html#1.15 http://xml-rpc.net/faq/xmlrpcnetfaq-3-0-0.html#1.15
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.