Keywords : Invalid response document returned from XmlRpc server – System.Xml.XmlException: Unexpected end of file while parsing Name has occurred –

After moving my old Sharepoint based blog to WordPress, I have encountered some problems when trying to connect Windows Live Writer to WordPress. When trying to connect Live Writer to my blog, I received “Invalid response document returned from XmlRpc server”

The Windows Live Writer log file (Help – About Windows Live Writer – “Show log file”) indicated this :

Invalid response document returned from XmlRpc server
   at WindowsLive.Writer.BlogClient.BlogClientBase.CreateAuthenticatedCredential()
   at WindowsLive.Writer.BlogClient.BlogClientBase.Login()
   at WindowsLive.Writer.BlogClient.Clients.BloggerCompatibleClient.GetUsersBlogs()
   at WindowsLive.Writer.BlogClient.Detection.BlogAccountDetector.ValidateService()","   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at WindowsLive.Writer.CoreServices.Diagnostics.LogFileTraceListener.Fail(String message)
   at System.Diagnostics.TraceInternal.Fail(String message)
   at System.Diagnostics.Trace.Fail(String message)
   at WindowsLive.Writer.BlogClient.Detection.BlogAccountDetector.ReportError(Exception ex, MessageId errorMessageType, Object[] errorMessageParams)
   at WindowsLive.Writer.BlogClient.Detection.BlogAccountDetector.ValidateService()
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetector.AttemptRsdBasedDetection(IProgressHost progressHost, RsdServiceDescription rsdServiceDescription)
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetector.DetectBlogService(IProgressHost progressHost)
   at WindowsLive.Writer.CoreServices.Progress.ProgressWorker.DoWork()
   at WindowsLive.Writer.CoreServices.Progress.MultipartAsyncOperation.DoWork()
   at WindowsLive.Writer.CoreServices.AsyncOperation.InternalStart()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()"
WindowsLiveWriter,1.5428,Fail,00022,14-Oct-2008 22:21:10.930,"WindowsLive.Writer.BlogClient.Detection.BlogServiceDetectorBase+BlogAccountDetectorException: Blog account detector did not succeed
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetectorBase.ReportErrorAndFail(MessageId errorMessageType, Object[] errorMessageParams)
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetector.AttemptRsdBasedDetection(IProgressHost progressHost, RsdServiceDescription rsdServiceDescription)
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetector.DetectBlogService(IProgressHost progressHost)","   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at WindowsLive.Writer.CoreServices.Diagnostics.LogFileTraceListener.Fail(String message)
   at System.Diagnostics.TraceInternal.Fail(String message)
   at System.Diagnostics.Trace.Fail(String message)
   at WindowsLive.Writer.BlogClient.Detection.BlogServiceDetector.DetectBlogService(IProgressHost progressHost)
   at WindowsLive.Writer.CoreServices.Progress.ProgressWorker.DoWork()
   at WindowsLive.Writer.CoreServices.Progress.MultipartAsyncOperation.DoWork()
   at WindowsLive.Writer.CoreServices.AsyncOperation.InternalStart()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()"
WindowsLiveWriter,1.5428,None,00023,14-Oct-2008 22:22:10.060,"Exception parsing XML-RPC response:

WindowsLive.Writer.CoreServices.XmlRpcClientInvalidResponseException: Invalid response document returned from XmlRpc server —> System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 18, position 16.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
   at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String arg)
   at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
   at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
   at System.Xml.XmlTextReaderImpl.ParseEndElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.LoadXml(String xml)
   at WindowsLive.Writer.CoreServices.XmlRpcMethodResponse..ctor(String responseText)
   — End of inner exception stack trace —
   at WindowsLive.Writer.CoreServices.XmlRpcMethodResponse..ctor(String responseText)
   at WindowsLive.Writer.CoreServices.XmlRpcClient.CallMethod(String methodName, XmlRpcValue[] parameters)

<?xml version=""1.0""?>
<methodResponse>
  <params>
    <param>
      <value>
        <array><data>
  <value><struct>
  <member><name>isAdmin</name><value><boolean>1</boolean></value></member>
  <member><name>url</name><value><string>
http://www.corelan.be:8800/</string></value></member>
  <member><name>blogid</name><value><string>1</string></value></member>
  <member><name>blogName</name><value><string>Peter Van Eeckhoutte’s Blog</string></value></member>
  <member><name>xmlrpc</name><value><string>
http://www.corelan.be:8800/xmlrpc.php</string></value></member>
</struct></value>
</data></array>
      </value>
    </param>
  </params>
</methodRespons",""
WindowsLiveWriter,1.5428,Fail,00024,14-Oct-2008 22:22:10.061,"WindowsLive.Writer.Extensibility.BlogClient.BlogClientInvalidServerResponseException: Invalid Server Response – The response to the blogger.getUsersBlogs method received from the weblog server was invalid:

 

If you look at the output of the xml (at the bottom of the log file), and/or if you use a web-mitm-proxy (Paros) /sniffer to look at the http communication, you can see that the xml file is in fact truncated. The methodResponse element is not closed, which results in an error within Windows Live Writer

image

This is caused because something (a plugin ? my webserver (IIS) ? something else ?) decided to add UTF-8 BOM to the XML-RPC response. Result : the xml response is 3 bytes longer than expected, which causes the xml response to be truncated.

Solution : find the class.IXR.php file (under wp-includes), edit the file, and look for

function output($xml)

FInd the line that calculates the length 
$length = strlen($xml);

and replace it by

$length = strlen($xml)+3;

Save the file, and try again. Problem should now be solved.

© 2008, Peter Van Eeckhoutte. All rights reserved. Terms of use are applicable to this document.



Related Posts:

One Response to “Windows Live Writer unable to connect to WordPress Blog”


Meet me at Brucon 2010
Meet me at Brucon 2010 !

Corelan Team Merchandise
You can support Corelan Team by donating or purchasing items from the official Corelan Team merchandising store.

Peter says:
« All of the info and all tools on this blog are free. Keeping this blog in the air is quite expensive.
So if you like what I do and want to show your respect for my work, please consider donating (use the Donate link above)

There is no way I can keep this site up and running without your help.


»     ...     « If you have enjoyed a certain post or like one of my tools, don't forget to vote/rate it !

»     ...     « If you have questions about certain posts, content or tools published on this website, then please use the forums to post questions. Don't write your questions in the Comments section.

»     ...     « If you want to be the first to know about new posts/tools/tutorials on this blog, then subscribe to the mailinglist. Use the 'Subscribe to updates via email' link below (in the Stay posted section)

»
Categories