作者:手机用户2602909537 | 来源:互联网 | 2023-10-12 12:59
Whatisactuallybeingproxiedistheserver,whichissetupbyinitializinganinstanceoftheS
What is actually being proxied is the server, which is set up by initializing an instance of theServerProxy class. We pass in the full URL of the remote server (you must include the URL scheme http:// ). Port 80 is the default, as usual. If
the remote server were instead listening on port 8080, we would use http://time.xmlrpc.com:8080 . The server proxy has all the actual remote objects they host as regular attributes, and in this way we get a handle to the remote object namedcurrentTime.
Now we can simply call the method on this proxy object, which returns the current time. The response is of a special XML-RPC type called a DateTime. To get a plain string representation of this object, we use itsvalue attribute.
One important clarification: the idea of distinct proxy objects within the server is really an illusion. XML-RPC allows method names to have periods in them, and it is a common convention to use method names such aspseudo_object.foo, that allows
clients to treat it as a call to a methodfoo on a remote object namedpseudo_object. However, as far as XML-RPC protocol is concerned, this is just a method namedpseudo_object.foo defined on the remote server. You'll see later
on why this distinction is important.
The result of running the script: