Xmlrcp learning-use XMLRPC in Python

Source: Internet
Author: User
I. Introduction

In order to provide RPC services on port 80 of the system without affecting the web services being executed, people have come up with a way to transmit RPC packets over HTTP. For an HTTP protocol that is used to transmit text, the most convenient way to transmit RPC packets on it is to encode RPC packets into text formats, such as XML files.
XML-RPC (http://www.xml-rpc.com) is an RPC protocol specified by userland. It encodes RPC Information packets into XML and then transmits packets through HTTP;
Simple understanding:

Data is defined as XML for remote transmission over HTTP.

 

Ii. Benefits

1. Transmit complex data.

2. PassProgramLanguage encapsulation to call remote objects.

Iii. XMLRPC application in Python

Server:

Import Simplexmlrpcserver

class myobject:
def sayhello (Self):
return " Hello xmlprc "

OBJ=Myobject ()
Server=Simplexmlrpcserver. simplexmlrpcserver (("Localhost",80))
Server. register_instance (OBJ)

Print "Listening on port 80"
Server. serve_forever ()

Client:

Import xmlrpclib

server = xmlrpclib. serverproxy ( " HTTP: // localhost: 80 " )

words = server. sayhello ()

Print " result: " + words

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.