Cook Computing

XML-RPC Problem with WordPress

March 19, 2006 Written by Charles Cook

A few days ago David Ashwood reported an XML-RPC problem when accessing a blog at WordPress. When the metaWeblog.getRecentPosts method is called, WordPress returns an invalid HTTP response.

The error message from XML-RPC.NET is "Response from server does not contain valid XML." Fiddler shows that that a valid XML-RPC response is returned in the body of the HTTP response, albeit with a trailing linefeed, but the response stream of the System.Net.HttpWebResponse instance ends with "</methodReponse" followed by the linefeed, i.e. missing the closing angle bracket. This causes the XML-RPC.NET exception. However the value returned in the Content-Length response header is several hundred bytes greater than the actual size of the XML-RPC response. You could argue that HttpWebResponse should return exactly what was sent or throw an exception to report that the content-length header was wrong, but the root cause of the problem seems to be WordPress - its returning an invalid HTTP response.