I'm trying to create a class in XML-RPC, but it's giving an Exception, but I do not understand why. It's just a simple example:
server.py
from xmlrpc.server import SimpleXMLRPCServer
import pickle
class Animal:
def __init__(self, number_of_paws, color):
self.number_of_paws = number_of_paws
self.color = color
class Sheep(Animal):
def __init__(self, color):
Animal.__init__(self, 4, color)
def main():
print("This is a server!")
server = SimpleXMLRPCServer(("localhost", 8080))
server.register_function(Animal.__init__)
server.register_function(Sheep.__init__)
server.serve_forever()
if __name__ == "__main__":
main()
client.py
import xmlrpc.client
import time
import pickle
import server
def main():
print("This is a client!")
client = xmlrpc.client.ServerProxy("http://localhost:8080")
mary = client.server.Sheep("white")
my_pickled_mary = pickle.dumps(mary)
dolly = pickle.loads(my_pickled_mary)
dolly.color = "black"
print (str.format("Dolly is {0} ", dolly.color))
print (str.format("Mary is {0} ", mary.color))
if __name__ == "__main__":
start = time.time()
main()
tempo_total = ("--- %s seconds ---" % (time.time() - start))
print("Tempo Total: " + str(tempo_total))
The server runs normal, but when I run the client, this error occurs:
xmlrpc.client.Fault:: method "server.Sheep" is not supported '>
What does it mean that the method is not supported?