SimpleXMLRPCServe 其实里面xml的概念不是很强,主要是rpc !不用关心什么xml 。

  rpc 是就是远程调用,把函数什么的放到远程服务器上,本地调用就行了。用 SimpleXMLRPCServer实现起来非常简洁。

  服务器端:

    server = SimpleXMLRPCServer(("localhost", 8000))     监听一个ip:port

    注册函数,或者是class 实例都可以

    server.register_function(pow)

    server.register_function(lambda x,y: x+y, 'add')  注册add函数

    

class Calendar:
def getMonth(self, year, month):
return calendar.month(year, month)
def getYear(self, year):
return calendar.calendar(year)
calendar_object = Calendar()

    

    server.register_instance(calendar_object)  注册class实例

    server.serve_forever()   运行

客户端:

    import xmlrpclib

    server = xmlrpclib.ServerProxy("http://localhost:8888")

    

import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:8888")
month = server.getMonth(2002, 8)
print month

  

xml rpc SimpleXMLRPCServer [python]的更多相关文章

  1. 什么是XML RPC?

    # -*- coding: cp936 -*- #python 27 #xiaodeng #什么是XML RPC? #中文叫:远程过程调用 #使用http协议做传输协议的rpc机制,使用xml文本的方 ...

  2. Huge CSV and XML Files in Python, Error: field larger than field limit (131072)

    Huge CSV and XML Files in Python January 22, 2009. Filed under python twitter facebook pinterest lin ...

  3. The type javax.xml.rpc.ServiceException cannot be resolved.It is indirectly

    The type javax.xml.rpc.ServiceException cannot be resolved.It is indirectly 博客分类: 解决方案_Java   问题描述:T ...

  4. 使用minidom来处理XML的示例(Python 学习)(转载)

    作者网站:http://www.donews.net/limodou/archive/2004/07/15/43609.aspx  一.XML的读取.在 NewEdit 中有代码片段的功能,代码片段分 ...

  5. 遍历文件 创建XML对象 方法 python解析XML文件 提取坐标计存入文件

    XML文件??? xml即可扩展标记语言,它可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言. 里面的标签都是可以随心所欲的按照他的命名规则来定义的,文件名为roi.xm ...

  6. Python Web-第五周-Web Services and XML(Using Python to Access Web Data)

    1.Web Service Overview 1.Data on the Web Python Dictionary 和 Java HashMap间需要建立一个桥梁,可以用XML或是JSON 2.XM ...

  7. webservice接口测试wsdl,参数是xml格式。python,入参转化成str,返回值转化成dict调用

    1.用SoapUI测试webservice接口,传入参数是xml格式时.xml格式需要将xml的外围增加<![CDATA[xml]]> 2.但是用python去做webservice测试, ...

  8. supervisord支持扩展(xml RPC API & Third Party Applications and Libraries)

    XML-RPC API Documentation http://www.supervisord.org/api.html Third Party Applications and Libraries ...

  9. ActiveMQ与xml rpc

    最近项目在做平台间的消息传递,也让我对平台间消息的传递进行了深一步的探讨.先叙述一下概况 公司上一个版本用的是winform做的监控软件,主要做设备的通信和控制,基本的连接如下

随机推荐

  1. AWR发现TOP Event log file sequential read

    对客户DB进行巡检,发现TOP EVENT是LOG FILE Sequential read 等待事件说明 https://www.xuebuyuan.com/zh-hant/1743045.html ...

  2. SQLI-LABS学习笔记(一)

    逼话少说,如有错误,烦请指出,谢谢. 第一关 提示传个id的参数 后面跟个单引号 http://10.2.10.31/sqli/Less-1/?id=1’ 发现报错,这里看到是已经闭合了 You ha ...

  3. ansible的role(6)

    roles的优点 roles能够根据层次型结构自动的装载变化量文件,task,以及handles等. 要使用肉了是只需要在playbook中使用include引入即可. 主要使用场景复制代码较高的情况 ...

  4. Docker安装Alibaba Nacos教程(单机)

    SpringCloudAlibaba实战教程系列 阿里巴巴Nacos官方文档 docker:官网 docker:镜像官网:镜像官网可以所有应用,选择安装环境:会给出安装命令,例如:docker pul ...

  5. python连接mysql数据表查询表获取数据导入到txt中

    import pymysql'''连接mysql数据表查询表获取数据导入到txt中'''#查询结果写入数据到txtdef get_loan_number(file_txt): connect = py ...

  6. nginx经验分享

    如果我们在使用启动nginx时,遇到这样的提示: nginx: [alert] could not open error log file: open() "/usr/local/var/l ...

  7. 数学--数论--HDU1825(积性函数性质+和函数公式+快速模幂+非互质求逆元)

    As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a lit ...

  8. 图论--最长路--基于SPFA的调整模板

    #include<iostream> #include<queue> #include<algorithm> #include<set> #includ ...

  9. P2024 食物链(种类并查集)

    P2024 [NOI2001]食物链 题目描述 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A 吃 B,B吃 C,C 吃 A. 现有 N 个动物,以 1 - N 编号.每个动 ...

  10. 题解 CF588A 【Duff and Meat】

    题意 有一个人,想吃 $n$ 天肉,第 $i$ 天需要吃 $a[i]$ 块肉,第 $i$ 天超市肉价为每块 $b[i]$ 元,买来的肉可以留到后面吃,求这个人在每天都吃到肉的情况下花费的最小值. 题目 ...