WordPress – there I Fixed That For You

I’ve been having a problem with Windows Live Writer after I installed a WordPress plugin, Now Reading. That plugin allows me to show the books I’m currently reading on the sidebar.

Windows Live Writer-Error

If I have that plugin enabled, I would get the error above, “Invalid Server Response – The response to the blogger.getUsersBlogs method received from the blog server was invalid: Invalid response document returned from XmlRpc server”. Many people have encountered that error and I was able to find several solutions but none of them fixed my problem. Being a rock star programmer, I decided that I would lick this problem and continue to use my plugin with Windows Live Writer. I believe in bending computers to my will instead of living with their problems.

In plain English the error message means the XML response from WordPress does not validate because it is not valid XML. I don’t know why they could not say that in the error message. You can tell it was written by a Microsoft employee!

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. That’s right, I used VBScript! VBScript is perfect for simple tasks that do not warrant a lot of effort.

   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: 'MsgBox oXMLHTTP.responseText,vbInformation, "XMLRPC Response"
  15:  
  16: Set fso = WScript.CreateObject("Scripting.FileSystemObject")
  17: strWorkingDirectory = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName,"\")-1)
  18: ' unicode format designator -1 solves the "Invalid procedure call or argument" error
  19: Set objOutputFile = fso.CreateTextFile(strWorkingDirectory & "\wp-response.xml", True, -1)
  20: objOutputFile.Write oXMLHTTP.responseText
  21: Set objOutputFile =  Nothing
  22:  
  23: MsgBox  "Done Processing!"

This script calls a XmlRpc method, it does not matter which one, and saves the result to a file. I was able to determine that the XML was invalid because 2 characters where truncated from the end of the last tag.

I’m not exactly sure why two characters get truncated with that plugin enabled but I did find the closing tag in the class-IXR.php file in the wp-includes directory. This file uses a XML template contained within within a nowdoc string, a PHP string that is not parsed. Apparently this is a PHP version of the <![CDATA[ ]]> construct but is meant to exclude quotes from parsing. Anyway, I was able to solve my problem by adding two more line breaks before the closing EOD;. This may not be the only problem with your XML. I also had a problem with a BOM (Byte Order Mark) that Microsoft Expression Web sneakily added to a PHP file I edited (Thanks, Expression Web, that was real sly of you). But I recently upgraded WordPress and I only had to apply my hack to the class-IXR.php file to get Windows Live Writer to accept the XML response from my WordPress blog.

8 Comments

  • Please let me know if you're looking for a writer for your weblog. You have some really good articles and I believe I would be a good asset. If you ever want to take some of the load off, I'd absolutely love to write some content for your blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Many thanks!

  • I'm gone to convey my little brother, that he should also go to see this webpage on regular basis to get updated from latest reports.

  • If you desire to take a great deal from this article then you have to
    apply such techniques to your won website.

  • You actually make it seem so easy along with your presentation however
    I find this topic to be really something that I feel I would never understand.

    It seems too complicated and very vast for me. I'm looking forward to your next publish, I'll
    try to get the hold of it!

  • I think this is among the most significant information for me.
    And i'm glad studying your article. But want to remark on some general issues, The web site taste is great, the articles is in point of fact excellent : D. Just right activity, cheers

  • I'm not sure where you are getting your info, but good topic. I needs to spend some time learning much more or understanding more. Thanks for wonderful information I was looking for this information for my mission.

  • Its such as you read my thoughts! You appear to understand a lot approximately this, like you wrote
    the e-book in it or something. I feel that you just can do with some p.
    c. to pressure the message home a bit, however other than that, that
    is wonderful blog. An excellent read. I'll certainly be back.

  • you're truly a just right webmaster. The web site loading speed is incredible. It sort of feels that you're
    doing any distinctive trick. Furthermore, The contents are masterwork.
    you've performed a excellent activity on this subject!

Comments have been disabled for this content.