ironthree / dxr

Declarative XML-RPC in Rust
Apache License 2.0
17 stars 8 forks source link

Getting Failed to parse XML data: duplicate field param #1

Closed speck0413 closed 2 years ago

speck0413 commented 2 years ago

python code:

import xmlrpc.client

with xmlrpc.client.ServerProxy("http://localhost:3000/",verbose=True) as proxy:
    print(proxy.init(1,1))

Error text:

$ python3 xml_rpc_client.py 
send: b'POST / HTTP/1.1\r\nHost: localhost:3000\r\nAccept-Encoding: gzip\r\nContent-Type: text/xml\r\nUser-Agent: Python-xmlrpc/3.8\r\nContent-Length: 188\r\n\r\n'
send: b"<?xml version='1.0'?>\n<methodCall>\n<methodName>init</methodName>\n<params>\n<param>\n<value><int>1</int></value>\n</param>\n<param>\n<value><int>1</int></value>\n</param>\n</params>\n</methodCall>\n"
reply: 'HTTP/1.1 200 OK\r\n'
header: content-type: text/xml
header: content-length: 268
header: date: Wed, 22 Jun 2022 18:07:47 GMT
body: b'<methodResponse><fault><value><struct><member><name>faultCode</name><value><i4>400</i4></value></member><member><name>faultString</name><value><string>Failed to parse XML data: duplicate field `param`</string></value></member></struct></value></fault></methodResponse>'
Traceback (most recent call last):
 File "xml_rpc_client.py", line 4, in <module>
   print(proxy.init(1,1))
 File "/usr/lib/python3.8/xmlrpc/client.py", line 1109, in __call__
   return self.__send(self.__name, args)
 File "/usr/lib/python3.8/xmlrpc/client.py", line 1450, in __request
   response = self.__transport.request(
 File "/usr/lib/python3.8/xmlrpc/client.py", line 1153, in request
   return self.single_request(host, handler, request_body, verbose)
 File "/usr/lib/python3.8/xmlrpc/client.py", line 1169, in single_request
   return self.parse_response(resp)
 File "/usr/lib/python3.8/xmlrpc/client.py", line 1341, in parse_response
   return u.close()
 File "/usr/lib/python3.8/xmlrpc/client.py", line 655, in close
   raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 400: 'Failed to parse XML data: duplicate field `param`'>
decathorpe commented 2 years ago

Ah, I see what's going on here, looks like I forgot to add a test case for more than one method parameter 😦 I'll fix that ASAP, though the next release that will have this fix will probably be 0.4.0 and not 0.3.2.

decathorpe commented 2 years ago

Should be fixed with commit https://github.com/ironthree/dxr/commit/24f63e413f78e4ba7d077449353a65221c72573e

I also added test cases for two request parameters, and an "add" function with two parameters to the example server, which now works correctly when called from Python's xmlrpc.client.

Since the changes that were necessary to fix this issue required changes public API changes, it will only be released as part of 0.4.0 (hopefully soon) and won't be backported to the 0.3 branch.

decathorpe commented 2 years ago

I just published version 0.4.0 to crates.io, which should contain the fix for this problem.