XML-RPC体验详解

黄舟
Libérer: 2017-03-16 16:53:40
original
2159 Les gens l'ont consulté

今天上园子发现园子已经支持Office2007WebBlog功能,于是看了一下使用的是XML-RPC技术。打开dudu XML-RPCPRCAPI感觉就像是WebService,但是深入看看原来不是,这是才注意到原来XML-PRC在起作用。XML-RPC是什么东东(不要笑我孤陋寡闻),幸好有google才知道XML-RPC原来是这个样子:

What’s XML-RPC?
It's a spec and a set of implementations that allow software running on disparate operating systems, 
running in different environments to make procedure calls over the Internet.
It's remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, 
while allowing complex data structures to be transmitted, processed and returned.
Copier après la connexion


简单的说就是使用了HTTP作为传输协议、XML作为数据内容实现了远程方法调用的一个标准(和WebService非常象)。具体可以参见XML-PRC的标准 http://www.xmlrpc.com/ 在这里我就不多说了。

既然是标准那就一定会有人实现了,到 http://sourceforge.net/ 找了一下果然如此,但是遗憾的是没有.Net的实现,还是看看dudu的实现吧。在duduAPI中发现了这个CookComputing.XmlRpc .NET CLR 1.1.4322,哈哈应该是他了。Google我太爱你了,是你帮助了我找到了 http://www.cookcomputing.com/blog/index.html ,呵呵原来是cookcomuting.Net下实现了XML-PRC,让我来体验一下XML-PRC

下载源代码后,运行里面的Math这个SampleVery Cool使用这个Liberry非常简单,感觉比Remoting还要简单,遗憾的是现在的版本由于.Net Framework的原因现在只支持Framework 1.1不支持Framework 2.0,在说明中会在以后版本支持 Framework 2.0

哈哈,大家赶快去体验吧。

体验之后发现XML-PRC.Net客户端实现代理模式挺有意思,决定研究一下。打开源代码发现使用的是动态创建Assembly的技术,也就是该技术导致了不支持Framework2.0的原故。


从上面的图(画的不好请见谅)看出客户端通过
XmlRpcProxyGenCreate方法创建了一个实现YourInterface的类,同时继承XmlRpcClientProtocol,在这里使用了AssemblyBuilder具体可以查看MSDN。然后把YourInterface的方法全部由XmlRpcClientProtocol的一个Invoke的方法代理,该函数的签名如下:

public object Invoke(string MethodName,params object[]Parameters)
Copier après la connexion

哈哈,这回终于找到关键所在了,在Invoke方法里面就可以按照XML-RPC的标准通过WebRequest对象调用远程的方法了。

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!