XML-RPC-1概述
- 中文名
- XML-RPC
- 外文名
- XML Remote Procedure Call
- 属 于
- 标准通用标记语言
- 类 型
- 一个子集
目录
- 1 关于XML-RPC
- ▪ 基本介绍
- ▪ Request example
- ▪ Response example
- 2 XML-RPC入门程序
- ▪ 基本做法
- ▪ 管理器类
- ▪ 服务器类
- ▪ 客户程序
- 3 RPC和RMI的简单比较
- ▪ 调用形式
- ▪ classname.methodname的形式
- ▪ methodname
- ▪ 匹配成功后
关于XML-RPC
基本介绍
Request example
|
1
2
3
4
5
6
7
8
9
10
11
|
<?xmlversion="1.0"?><methodCall><methodName>examples.getStateName</methodName><params><param><value><i4>41</i4></value></param></params></methodCall> |
Response example
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<?xmlversion="1.0"?><methodResponse><params><param><value><string>SouthDakota</string></value></param></params></methodResponse> |
XML-RPC入门程序
基本做法
管理器类
|
1
2
3
4
5
6
7
|
packagexmlRpc;/***@authortrier**<b><code>HelloHandler</code></b>isasimplehandlerthancan*beregisteredwithanXML-RPCserver*/publicclassHelloHandler{publicStringsayHello(Stringname){return"Hello"+name;}} |
服务器类
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
packagexmlRpc;/****<b><code>HelloServer</code></b>isasimpleXML-RPCserver*thatwilltakethe<code>HelloHandler</code>classavailable*forXML-PRCcalls.*<o:p*/importorg.apache.xmlrpc.WebServer;importorg.apache.xmlrpc.XmlRpc;importjava.IOException;publicclassHelloServer{publicstaticvoidmain(String[]args){if(args.length<1){System.out.println("Usage:javaHelloServer[port]");System.exit(-1);}try{XmlRpc.setDriver("org.apache.xerces.parsers.SAXParser");//starttheserverSystem.out.println("StartingXML-RPCServer......");WebServerserver=newWebServer(Integer.parseInt(args[0]));//registerourhandlerclassserver.addHandler("hello",newHelloHandler());System.out.println("Nowacceptingrequests......");}catch(ClassNotFoundExceptione){System.out.println("CouldnotlocateSAXDriver");}catch(IOExceptione){System.out.println("Couldnotstartserver:"+e.getMessage());}}} |
客户程序
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
packagexmlRpc;/****<b><code>HelloClient</code></b>isasimpleXML-RPCclient*thatmakesanXML-RPCrequestto<code>HelloServer</code>*/importjava.i.IOException;importjava.util.Vector;importorg.apache.xmlrpc.XmlRpc;importorg.apache.xmlrpc.XmlRpcClient;importjava.t.MalformedURLException;importorg.apache.xmlrpc.XmlRpcException;publicclassHelloClient{publicstaticvoidmain(String[]args){if(args.length<1){System.out.println("Usage:javaHelloClient[yourname]");System.exit(-1);}try{//UsetheApacheXerecesSAXDriverXmlRpc.setDriver("org.apache.xerces.parsers.SAXParser");//Specifytheserver//createrequestVectorparams=newVector();params.addElement(args[0]);//makearequestandprinttheresultStringresult=(String)client.execute("hello.sayHello",params);System.out.println("Responsefromserver:"+result);}catch(ClassNotFoundExceptione){System.out.println("CouldnotlocateSAXDriver");}catch(MalformedURLExceptione){System.out.println("IncorrectURLfroxml-rpcserverforamt:"+e.getMessage());}catch(XmlRpcExceptione){System.out.println("XmlRpcException:"+e.getMessage());}catch(IOExceptione){System.out.println("IOException:"+e.getMessage());}}} |
RPC和RMI的简单比较
调用形式
classname.methodname的形式
methodname
匹配成功后
XML-RPC-1概述的更多相关文章
- 什么是XML RPC?
# -*- coding: cp936 -*- #python 27 #xiaodeng #什么是XML RPC? #中文叫:远程过程调用 #使用http协议做传输协议的rpc机制,使用xml文本的方 ...
- 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 ...
- 【PHP XML与dtd概述【完整版】】
一.XML文件简介 关于XML的大多数人都知道一些,HTML->xhtml->xml,这个顺序本来应当是HTML发展的顺序. XML可以当做配置文件使用,还可以充当小型的数据库. vers ...
- 关于XML的DTD概述
1 DTD概述 1.1 什么是DTD DTD(Document Type Definition),文档类型定义,用来约束XML文档.或者可以把DTD理解为创建XML文档的结构!例如可以用DTD要求XM ...
- xml rpc SimpleXMLRPCServer [python]
SimpleXMLRPCServe 其实里面xml的概念不是很强,主要是rpc !不用关心什么xml . rpc 是就是远程调用,把函数什么的放到远程服务器上,本地调用就行了.用 SimpleXMLR ...
- [03] mapper.xml的基本元素概述
1.select 我们基于这个持久层接口 GirlDao: public interface GirlDao { List<Girl> findByAge(int age); Girl f ...
- alluxio源码解析-rpc调用概述(1)
alluxio中几种角色以及角色之间的rpc调用: 作为分布式架构的文件缓存系统,rpc调用必不可少 client作为客户端 master提供thrift rpc的服务,管理以下信息: block信息 ...
- xml的解析(概述)
使用java解析xml☆☆☆ 四个类:分别是针对dom和sax解析使用的类 -dom : DocumentBuilder:解析器类 -这个类是个抽象类,不能new, ...
- Android之布局androidmanifest.xml 资源清单 概述
转载:https://www.cnblogs.com/wytings/p/4083463.html AndroidManifest.xml配置文件对于Android应用开发来说是比较细但又很重要的基础 ...
- supervisord支持扩展(xml RPC API & Third Party Applications and Libraries)
XML-RPC API Documentation http://www.supervisord.org/api.html Third Party Applications and Libraries ...
随机推荐
- OpenJudge计算概论-找和为K的两个元素
/*============================================================== 找和为K的两个元素 总时间限制: 1000ms 内存限制: 65536 ...
- KA,连接池居然这么简单? 原创: 58沈剑 架构师之路 3月20日
KA,连接池居然这么简单? 原创: 58沈剑 架构师之路 3月20日
- git notes的使用
1. 获取notes git fetch origin refs/notes/*:refs/notes/* 2. 设置notes 2.1 git config --add core.notesRef ...
- linux内核中的__cpu_suspend是在哪里实现的呀?
1. 内核版本 4.19 2. 在arch/arm/kernel/sleep.S中实现如下: /* * Save CPU state for a suspend. This saves the CPU ...
- E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. 爆错解决办法
author :headsen chen date : 2019-06-06 10:09:06 root@ubuntu:~# apt-get remove java-1.8.0-openjdk E ...
- ISO/IEC 9899:2011 条款5——5.2.1 字符集
5.2.1 字符集 1.两个字符集和它们相关联的依次顺序应该被定义:写在源文件中的集合(源字符集),以及在执行环境中被解释的集合(执行字符集).每个集合此外被划分为一个基本字符集,其内容由本子条款给出 ...
- osg RTT 多相机-局部放大镜
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- JBPM使用
jbpm+mysql5.7 https://blog.csdn.net/tyn243222791/article/details/79033555
- ORM连表操作
连表操作分为以下三种情景: 一对多:models.ForeignKey(其他表) 多对多:models.ManyToManyField(其他表) 一对一:models.OneToOneField(其他 ...
- 日常工作问题解决:redhat6.9--解决yum功能不能正常使用和配置yum源
1.问题描述 解决RedHat6.9下yum功能不能用问题: 在redhat6.9下使用yum安装时,会提示:This system is not registered to Red Hat Subs ...