C# xml-rpc
所以我必须使用 Web 服务(xml-rpc),我使用 xml-rpc.net 库来执行此操作。我必须传递的参数之一必须是 .net 中没有此类变量的类型。目前我只是编写 XML 并发布,这不是一个令人满意的解决方案。
日期时间的 xml 看起来如何:
</param>
<param>
<value>
<dateTime.iso8601>20101117T09:42:00</dateTime.iso8601>
</value>
</param>
<param>
任何人都有任何聪明的想法,有人说创建一个类 dateTime.iso8601 的变量并将其用作参数类型。
so I have to hit a webservice (xml-rpc), im using xml-rpc.net library to do this. One of the parameters i have to pass must be of type of which there is no such thing in .net as a variable. At the moment i am just writing the XML and posting, this is not a satisfiable solution.
How the xml for the datetime looks:
</param>
<param>
<value>
<dateTime.iso8601>20101117T09:42:00</dateTime.iso8601>
</value>
</param>
<param>
anyone got any smart ideas, someone said make a variable of a class dateTime.iso8601 and use that as the parameter type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
xml-rpc.net 当然需要 System.Datetime 并转换为 dateTime.iso8601。我遇到的一个问题是 dateTime.iso8601 的各种解释。从您的 xml 模板中,支持您的日期时间输出 (20101117T09:42:00),并且您不会遇到相同的问题。我有一个非常严格的上游服务器,需要一些偏移量(例如+001),并且我必须扩展日期时间格式并将其传递到 xml-rpc.net。
编辑
是的,我修改了代码以实现新的 DateTimeFormat。我下载了源代码并进行了以下修改(我希望它能更好地托管并且可以提供修改)。
有一个 XmlRpcSerializer.cs,这是将类型序列化为 xml-rpc 格式的地方。您需要的方法自然是...
此方法中的某个位置是对 XmlRpcType.tDateTime 的检查:
故事的其余部分是如何将自定义日期时间格式传递给 XmlRpcSerializer 类。您只需向此类添加一个属性即可实现此目的。有一个可以使用的 XmlRpcFormatSettings,但这取决于您。
xml-rpc.net certainly takes a System.Datetime and converts to dateTime.iso8601. A gotcha I had was with the various interpretations of dateTime.iso8601. From your xml template, your datetime output is supported (20101117T09:42:00) and you won't have the same problem. I had a very strict upstream server that wanted some offset (e.g +001) and I had to extend and pass a datetime format to xml-rpc.net.
Edit
Yea I modified the code to achieve the new DateTimeFormat. I downloaded the source and made the following modifications (I wish it was better hosted and one could offer a modification).
There is an XmlRpcSerializer.cs, which is where the serialization of the type to xml-rpc format happens. The method you need is naturally...
Somewhere in this method, is a check for XmlRpcType.tDateTime:
The rest of the story is how to pass the custom datetime format to the XmlRpcSerializer class. You could just add a property to this class to make it happen. There is an XmlRpcFormatSettings that could be used but that's up to you.