Dalam banyak kasus wordpress seringkali mengalami overload disebabkan karena adanya serangan DDOS atau percobaan Brute Force pada salah satu modulnya xmlrpc.php, pada kebanyakan pengguna fungsi/fitur ini tidak diperlukan kecuali jika ingin menggunakan aplikasi Wordpress Mobile Blogger. Show Jika anda mencurigai wordpress anda mengalami overload, anda dapat menanyakannya pada support kami, atau jika memang tidak membutuhkan fitur tersebut dapat langsung menambahkan syntax berikut ini pada file .htaccess yang sudah ada di hosting wordpress anda: ############################################ # Jetpack XML-RPC DDoS & TRACKBACK/PINGBACK PROTECTION Jika anda mengalami kesulitan menambahkan syntax ini silakan hubungi kami melalui Live Chat atau Tiket Support untuk bantuan lebih lanjut. Kode sumber: Lib/xmlrpc/client.py XML-RPC adalah metode Pemanggilan Prosedur Jarak Jauh (Remote Procedure Call) yang menggunakan XML, dikirimkan melalui HTTP(S) sebagai sarana transportasi. Dengan itu, klien dapat memanggil metode dengan parameter di server jauh (server dinamai oleh URI) dan mendapatkan kembali data terstruktur. Modul ini mendukung penulisan kode klien XML-RPC; ia menangani semua detail penerjemahan antara objek Python yang sesuai dan XML pada kabel. Peringatan Modul Berubah pada versi 3.5: Untuk URI HTTPS, Availability: not Emscripten, not WASI. This module does not work or is not available on WebAssembly platforms Instance The following parameters govern the use of the returned proxy
instance. If allow_none is true, the Python constant Berubah pada versi 3.3: Penanda use_builtin_types ditambahkan. Berubah pada versi 3.8: Parameter headers ditambahkan Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: The returned instance is a proxy object with methods that can be used to invoke corresponding RPC calls on the remote server. If the remote server supports the introspection API, the proxy can also be used to query the remote server for the methods it supports (service discovery) and fetch other server-associated metadata. Types that are conformable (e.g. that can be marshalled through XML), include the following (and except where noted, they are unmarshalled as the same Python type):
This is the full set of data types supported by XML-RPC. Method calls may also raise a special When
passing strings, characters special to XML such as
Berubah pada versi 3.5: Menambahkan argumen context. Berubah pada versi 3.6: Added support of type
tags with prefixes (e.g. Lihat juga XML-RPC HOWTOA good description of XML-RPC operation and client software in several languages. Contains pretty much everything an XML-RPC client developer needs to know. Tinjauan XML-RPCDescribes the XML-RPC protocol extension for introspection. Spesifikasi XML-RPCSpesifikasi resmi Objek ServerProxy¶A Servers that support the XML introspection API support some common methods grouped under the reserved This method returns a list of strings, one for each (non-system) method supported by the XML-RPC server. ServerProxy.system.methodSignature(name)¶This method takes one parameter, the name of a method implemented by the XML-RPC server. It returns an array of possible signatures for this method. A signature is an array of types. The first of these types is the return type of the method, the rest are parameters. Because multiple signatures (ie. overloading) is permitted, this method returns a list of signatures rather than a singleton. Signatures themselves are restricted to the top level parameters expected by a method. For instance if a method expects one array of structs as a parameter, and it returns a string, its signature is simply "string, array". If it expects three integers and returns a string, its signature is "string, int, int, int". If no signature is defined for the method, a non-array value is returned. In Python this means that the type of the returned value will be something other than list. ServerProxy.system.methodHelp(name)¶This method takes one parameter, the name of a method implemented by the XML-RPC server. It returns a documentation string describing the use of that method. If no such string is available, an empty string is returned. The documentation string may contain HTML markup. Berubah pada versi 3.5: Instances of A working example follows. The server code: from xmlrpc.server import SimpleXMLRPCServer def is_even(n): return n % 2 == 0 server = SimpleXMLRPCServer(("localhost", 8000)) print("Listening on port 8000...") server.register_function(is_even, "is_even") server.serve_forever() The client code for the preceding server: import xmlrpc.client with xmlrpc.client.ServerProxy("http://localhost:8000/") as proxy: print("3 is even: %s" % str(proxy.is_even(3))) print("100 is even: %s" % str(proxy.is_even(100))) Objek DateTime¶class xmlrpc.client.DateTime¶This class may be initialized with seconds since the epoch, a time tuple, an ISO 8601 time/date string, or a Accept a string as the instance's new time value. Write the XML-RPC encoding of this It also supports certain of Python's built-in operators through rich comparison and A working example follows. The server code: import datetime from xmlrpc.server import SimpleXMLRPCServer import xmlrpc.client def today(): today = datetime.datetime.today() return xmlrpc.client.DateTime(today) server = SimpleXMLRPCServer(("localhost", 8000)) print("Listening on port 8000...") server.register_function(today, "today") server.serve_forever() The client code for the preceding server: import xmlrpc.client import datetime proxy = xmlrpc.client.ServerProxy("http://localhost:8000/") today = proxy.today() # convert the ISO8601 string to a datetime object converted = datetime.datetime.strptime(today.value, "%Y%m%dT%H:%M:%S") print("Today: %s" % converted.strftime("%d.%m.%Y, %H:%M")) Objek biner¶classxmlrpc.client.Binary¶This class may be initialized from bytes data (which may include NULs). The primary access to the content of a
The binary data encapsulated by the
Accept a base64 Write the XML-RPC base 64 encoding of this binary item to the out stream object. The encoded data will have newlines every 76 characters as per RFC 2045 section 6.8, which was the de facto standard base64 specification when the XML-RPC spec was written. It also supports certain of Python's built-in operators through Example usage of the binary objects. We're going to transfer an image over XMLRPC: from xmlrpc.server import SimpleXMLRPCServer import xmlrpc.client def python_logo(): with open("python_logo.jpg", "rb") as handle: return xmlrpc.client.Binary(handle.read()) server = SimpleXMLRPCServer(("localhost", 8000)) print("Listening on port 8000...") server.register_function(python_logo, 'python_logo') server.serve_forever() The client gets the image and saves it to a file: import xmlrpc.client proxy = xmlrpc.client.ServerProxy("http://localhost:8000/") with open("fetched_python_logo.jpg", "wb") as handle: handle.write(proxy.python_logo().data) Fault Objects¶class xmlrpc.client.Fault¶A An int indicating the fault type. faultString¶A string containing a diagnostic message associated with the fault. In the following example we're going to intentionally cause a from xmlrpc.server import SimpleXMLRPCServer # A marshalling error is going to occur because we're returning a # complex number def add(x, y): return x+y+0j server = SimpleXMLRPCServer(("localhost", 8000)) print("Listening on port 8000...") server.register_function(add, 'add') server.serve_forever() The client code for the preceding server: import xmlrpc.client proxy = xmlrpc.client.ServerProxy("http://localhost:8000/") try: proxy.add(2, 5) except xmlrpc.client.Fault as err: print("A fault occurred") print("Fault code: %d" % err.faultCode) print("Fault string: %s" % err.faultString) Objek ProtocolError¶class xmlrpc.client.ProtocolError¶A URI atau URL yang menyebabkan error. errcode¶Kode errornya errmsg¶Pesan error atau string diagnosanya A dict containing the headers of the HTTP/HTTPS request that triggered the error. In the following example we're going to intentionally cause a import xmlrpc.client # create a ServerProxy with a URI that doesn't respond to XMLRPC requests proxy = xmlrpc.client.ServerProxy("http://google.com/") try: proxy.some_method() except xmlrpc.client.ProtocolError as err: print("A protocol error occurred") print("URL: %s" % err.url) print("HTTP/HTTPS headers: %s" % err.headers) print("Error code: %d" % err.errcode) print("Error message: %s" % err.errmsg) Objek MultiCall¶The Create an
object used to boxcar method calls. server is the eventual target of the call. Calls can be made to the result object, but they will immediately return A usage example of this class follows. The server code: from xmlrpc.server import SimpleXMLRPCServer def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x // y # A simple server with simple arithmetic functions server = SimpleXMLRPCServer(("localhost", 8000)) print("Listening on port 8000...") server.register_multicall_functions() server.register_function(add, 'add') server.register_function(subtract, 'subtract') server.register_function(multiply, 'multiply') server.register_function(divide, 'divide') server.serve_forever() The client code for the preceding server: import xmlrpc.client proxy = xmlrpc.client.ServerProxy("http://localhost:8000/") multicall = xmlrpc.client.MultiCall(proxy) multicall.add(7, 3) multicall.subtract(7, 3) multicall.multiply(7, 3) multicall.divide(7, 3) result = multicall() print("7+3=%d, 7-3=%d, 7*3=%d, 7//3=%d" % tuple(result)) Fungsi yang memudahkan¶xmlrpc.client.dumps(params, methodname=None, methodresponse=None, encoding=None, allow_none=False)¶Convert
params into an XML-RPC request. or into a response if methodresponse is true. params can be either a tuple of arguments or an instance of the Convert an XML-RPC request or response into Python objects, a Penanda use_datetime yang obsolete mirip dengan use_builtin_types tetapi hanya berlaku untuk nilai tanggal/waktu. Berubah pada versi 3.3: Penanda use_builtin_types ditambahkan. Contoh penggunaan Client¶# simple test program (from the XML-RPC specification) from xmlrpc.client import ServerProxy, Error # server = ServerProxy("http://localhost:8000") # local server with ServerProxy("http://betty.userland.com") as proxy: print(proxy) try: print(proxy.examples.getStateName(41)) except Error as v: print("ERROR", v) Untuk mengakses server XML-RPC melalui proksi HTTP, Anda perlu menentukan transport khusus. Contoh berikut menunjukkan caranya import http.client import xmlrpc.client class ProxiedTransport(xmlrpc.client.Transport): def set_proxy(self, host, port=None, headers=None): self.proxy = host, port self.proxy_headers = headers def make_connection(self, host): connection = http.client.HTTPConnection(*self.proxy) connection.set_tunnel(host, headers=self.proxy_headers) self._connection = host, connection return connection transport = ProxiedTransport() transport.set_proxy('proxy-server', 8080) server = xmlrpc.client.ServerProxy('http://betty.userland.com', transport=transport) print(server.examples.getStateName(41)) Contoh penggunaan Client dan Server¶Lihat SimpleXMLRPCServer Example. Catatan kaki 1Pendekatan ini pertama kali ditampilkan pada sebuah diskusi pada xmlrpc.com. |