JavaDude's Groovy Snippets

January 12, 2010

Debugging XML-RPC calls

Filed under: Groovy Tutorial — Tags: , , — admin @ 7:59 am

The Groovy XML-RPC library 0.5 allows me to do perform basic authorization, but my Trac Server now throws a error code 500 at me (stating XML declaration not well-formed). Since I  dont know how to check the XML request the library posts, I choose to dissect the messages at the network level using Wireshark. Luckily I have a Python library that works fine, so I can compare the working version of the XML-RPC request. (Remark: Dont forget to start wireshark as root user/sudo)

XML Error   
  1. 2010-01-07 09:03:03,095 Trac[main] DEBUG: Dispatching <Request "POST u'/login/xmlrpc'">
  2. 2010-01-07 09:03:03,117 Trac[main] ERROR: Internal Server Error:
  3. Traceback (most recent call last):
  4. File "/usr/local/Python-2.5.2/lib/python2.5/site-packages/trac/web/main.py", line 441, in _dispatch_request
  5. dispatcher.dispatch(req)
  6. File "/usr/local/Python-2.5.2/lib/python2.5/site-packages/trac/web/main.py", line 205, in dispatch
  7. resp = chosen_handler.process_request(req)
  8. File "/usr/local/Python-2.5.2/lib/python2.5/site-packages/TracXMLRPC-1.0.6-py2.5.egg/tracrpc/web_ui.py", line 163, in process_request
  9. self.process_xml_request(req, content_type)
  10. File "/usr/local/Python-2.5.2/lib/python2.5/site-packages/TracXMLRPC-1.0.6-py2.5.egg/tracrpc/web_ui.py", line 167, in process_xml_request
  11. args, method = xmlrpclib.loads(req.read(int(req.get_header('Content-Length'))))
  12. File "/usr/local/Python-2.5.2/lib/python2.5/xmlrpclib.py", line 1130, in loads
  13. p.feed(data)
  14. File "/usr/local/Python-2.5.2/lib/python2.5/xmlrpclib.py", line 547, in feed
  15. self._parser.Parse(data, 0)
  16. ExpatError: XML declaration not well-formed: line 1, column 30
  17. 2010-01-07 09:03:03,121 Trac[chrome] DEBUG: Prepare chrome data for request

Python Library/Call

XML-RPC   
  1. import xmlrpclib
  2. server = xmlrpclib.ServerProxy("http://user:password@sometracserver.com/login/xmlrpc")
  3. print server.wiki.getPage("WikiStart")

Result in Wireshark

Wireshark

Groovy Call

XML-RPC   
  1. def serverProxy = new XMLRPCServerProxy("http://sometracserver.com/project/login/xmlrpc")
  2. serverProxy.setBasicAuth("user","password")
  3. serverProxy.wiki.getPage("WikiStart")

Result in Wireshark

Wireshark

There is the problem: encoding=”+ENCODING+”
The Trac XML reader most likely will throw up the complete call because of this. Actually the comparison was not really required because the error is very obvious.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress