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: ' #################################################


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

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


  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>"


  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


  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.

8 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 …

  3. smrtinker says:

    has similar issue connecting from the live writer to wordpress – tried removing the preceding and trailing white spaces in several files, changing the paths names in the xmlrpc and reloading into the root folder, as mentioned by many people on numerous blogs. None of that really helped.

    For a few hours, I banged my head on to my laptop, pulled my hair till I almost lost all of it, and then suddenly – bang! found the solution…it’s actually very simple and I don’t the reason why. Anyways, here’s what I did.

    Just for the heck of it, to give it a try, simply created a new user id with admin rights, that’s it, it started working. But, there’s another error which I’m getting now i.e.,
    “The response to the metaWeblog.editPost method received from the blog server was invalid:Invalid response document returned from XmlRpc server”. Haven’t yet tried any of the tips/tricks out there…Hope this works!


  4. nerudo says:

    Well I tried to add the piece of code you showed in the post but I have actually ran into something I cant redeem myself from which. Im now getting 500 Internal Server Error. This happened after I had added the code. Is there a way you could help me as Im not in anyway familiar with code


    Robert S. Robbins Reply:

    The code in the post should not be added to any PHP file. It is VBScript code that is to be used to test the xmlrpc.php file.


  5. PhotoBlogger says:

    I guess it’s easy to use 😀 plus being able to manage multiple blogs seems like an awesome feature. 🙂


  6. jose says:

    Lol, I’m sitting here with this same problem and for the life of me, I don’t see the solution. what am I to do, exactly, to fix this? You said: ” I fixed that problem by adding some newlines to the class-IXR.php file in the wp-includes directory.” What lines did you add, and where in the files did you add them??? You also said: “I added newlines just before the EOD; on line 336.” What new lines did you add here, and what does EOD stand for? You also said: “Then I found that there was a BOM (Byte Order Mark) just before the first XML tag.” What does a BOM look like, and which file were you in, and what did you do when you found the BOM? I’m very sorry if I sound like a layman who didn’t go to ITT tech, but that just so happens to be the case. I’ve looked all over the place for the solution to this, and believe it or not, this was the least complex, but I still don’t understand exactly what to do to fix this. I didn’t use WLW to write this post because I get this message every time I try to use it:
    An unexpected error occurred while attempting to log in:
    Invalid Server Response- The response to the blogger.getUsersBlogs method received the blog server was in valid: Invalid response document returned from XmlRpc server


    Robert S. Robbins Reply:

    EOD stands for End of Data. Edit the class-IXR.php file in the wp-includes directory. You add blank lines before the EOD which results in newline characters. The BOM appears as three garbage characters (which includes an i with two dots and an upside-down question mark) which may be added by some Windows editing programs.


Leave a Reply

Your email address will not be published. Required fields are marked *