WordPress – Windows Live Writer Fix

I think I have finally solved the problem I have been having with WordPress and Windows Live Writer. Windows Live Writer is a free Microsoft program that allows you to write blog posts and submit them to your blog. It is a useful program if you maintain multiple blogs and don’t like the built-in text editors. Windows Live Writer uses XML-RPC, a remote procedure call protocol which uses XML to encode its calls and HTTP as a transport mechanism, to submit the blog post.

I’ve been getting the infamous “An error occurred while attempting to connect to your weblog: Invalid Server Response = The response to the blogger.getUsersBlogs method received from the weblog server was invalid: Invalid response document returned from XmlRpc server” error when my Now Reading plugin was enabled. I would have to disable that plugin before using Windows Live Writer. This required logging in to my WordPress administration and that defeats the whole purpose of using the program to avoid using the browser.

There are various solutions to this problem but eventually I found it came down to the XML response from the xmlrpc.php file. Windows Live Writer complains when the XML response cannot be parsed. In order to troubleshoot this problem you need to see the XML response. I did find a XML-RPC debugger at:  http://gggeek.raprap.it/debugger/ but it is not very helpful when the XML is malformed. It can give you some insight into the methods that are available though. In order to figure out exactly what was going on, I wrote a simple VBScript to submit a POST request to the xmlrpc.php file and saved the response to a file.

   1: ' #################################################

   2: ' # VBScript To Call WordPress XMLRPC             #

   3: ' # Need to examine XML response to troubleshoot  #

   4: ' # programmed by Robert S. Robbins on 06/10/2009 #

   5: ' #################################################

   6:

   7: Set oXMLHTTP = WScript.CreateObject("MSXML2.XMLHTTP")

   8: oXMLHTTP.open "POST", "http://www.williamsportwebdeveloper.com/cgi/wp/xmlrpc.php",False

   9:

  10: oXMLHTTP.setRequestHeader "Content-Type", "text/xml"

  11: 'oXMLHTTP.send "<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName><params></params></methodCall>"

  12: oXMLHTTP.send "<?xml version="1.0"?><methodCall><methodName>demo.sayHello</methodName><params></params></methodCall>"

  13:

  14: Set fso = WScript.CreateObject("Scripting.FileSystemObject")

  15: strWorkingDirectory = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName,"\")-1)

  16: ' Third parameter must be True for Unicode if the XML contains unicode characters

  17: Set objOutputFile = fso.CreateTextFile(strWorkingDirectory & "\wp-response.xml", True, True)

  18: objOutputFile.Write oXMLHTTP.responseText

  19: Set objOutputFile =  Nothing

  20:

  21: MsgBox  "Done Processing!"

My script revealed that the XML response was missing a few characters from the final closing tag. I fixed that problem by adding some newlines to the class-IXR.php file in the wp-includes directory. I added newlines just before the EOD; on line 336. Then I found that there was a BOM (Byte Order Mark) just before the first XML tag. This problem was caused by my use of Microsoft Expression Web which added the BOM to my wp-config.php file when I edited it in that crappy program.

After finally verifying that the XML response would be valid I was able to use Windows Live Writer without disabling any of my WordPress plugins. Who da man?

This blog post was written using Windows Live Writer and will serve as a test of my fix.

This entry was posted in PHP, Programming, Web and tagged , , , . Bookmark the permalink.

9 Responses to WordPress – Windows Live Writer Fix

  1. Pingback: » WordPress – Windows Live Writer Fix – Williamsport Web Developer … Wordpress Plugins: Just another WordPress weblog

  2. Pingback: WEBMASTERLIB.COM » Blog Archive » WordPress – Windows Live Writer Fix – Williamsport Web Developer …

Leave a Reply

Your email address will not be published.