[From http://sanyuexx.spaces.live.com/Blog/cns! Bf32ccaae...]
Introduction to Windows Live writer and XML-RPC
Windows Live writer is a tool released by Microsoft to edit and publish blogs without a browser. It supports HTML and simple image editing and uploading, which greatly facilitates blog editing and publishing. currently, Windows Live writer supports large blog services outside China, such as live spaces and blogger. If you want to use Windows Live writer without using the services in the support list, you only need to add XML-RPC support to your blog.
XML-RPC is a remote call service similar to WebService, But it supports more platforms than WebService, windows Live writer and many other offline blog editing and publishing tools use XML-RPC to call the blogProgramMethod.
This document uses ASP. net is used as an example to add XML-RPC support for Windows Live writer to the blog. This allows us to edit, publish, and modify blog entries in live writer, if your blog is on another platform, see
Http://www.xmlrpc.com/directory/1568/implementatio... to find out how to implement XML-RPC on your platform. although the methods for implementing XML-RPC on different platforms are different, the steps for adding interfaces supported by Windows Live writer are similar.
Preparations
For the ASP. NET platform, first download the components supported by XML-rpc in the http://www.xml-rpc.net/, decompressCookcomputing. xmlrpcv2.dllCopy to the bin folder of the ASP. NET program andMetaweblogapi. CSCopy to the app_code folder (of course, other folders of the ASP. NET program can also be copied )..
Start
First modifyMetaweblogapi. CSFile. This is one of the interfaces supported by Windows Live writer, but you must add a method to it to normally support Windows Live writer.
Add a struct:
Public struct userblog {Public String URL; Public String blogid; Public String blogname ;}
This is the structure used to save the blog Information
ThenImetaweblogInterface to add a method:
[Xmlrpcmethod ("blogger. getusersblogs")] userblog [] getusersblogs (string appkey, string username, string password );
XmlrpcmethodThe method name specified in XML-RPC cannot be changed. The. client cannot identify and call the method.
The interface file is ready. Now the interface method is implemented.
Add an ashx file in the root directory of the ASP. NET program. Suppose it is rpc. ashx. An example of rpc. ashx is provided below:
<% @ Webhandler Language = "C #" class = "rpcservice" %> <! -- Registration class --> <% @ Assembly name = "cookcomputing. xmlrpcv2" %> <! -- Register cookcomputing for XMLRPC. xmlrpcv2.dll --> using system; using system. collections; using system. web; using cookcomputing. XMLRPC; // introduce xmlrpcusing cookcomputing. metaweblog; // introduce imetaweblog interface using dataaccess; // introduce your own blog Program Data Access namespace [xmlrpcservice (description = "metaweblog XML-RPC service")] public class rpcservice: xmlrpcservice, imetaweblog {# region imetaweblog member // obtain the blog site information public userblog [] getusersblogs (string appkey, string username, string password) {If (LOGIN (username, password )) // verify the username and password. You must implement this method by yourself in this class {userblog blog = new userblog (); blog. blogid = ""; // This is a blog. blogname = "lifebeta"; // blogname. url = "http://aspspider.org/lifebeta/"; // blog URL return New userblog [] {blog};} return NULL;} // Add blog Public String newpost (string blogid, string username, string password, post, bool publish) {If (LOGIN (username, password) {// use your own dataaccess to implement return dataaccess. addblog (post. title, post. description, 4, "", false, datetime. now. addhours (12 )). tostring () ;}return null ;}// edit blog public object editpost (string postid, string username, string password, post, bool publish) {If (LOGIN (username, password) {// use your own dataaccess. Pay attention to post. title is the title, post. description is the dataaccess content of the blog. editblog (convert. toint32 (postid), post. title, post. description, 4, "", false);} return NULL;} // obtain the category public categoryinfo [] getcategories (string blogid, string username, string password) {If (LOGIN (username, password) {// slightly} return NULL;} // getArticle Public Post getpost (string postid, string username, string password) {If (LOGIN (username, password) {// omitted} return New post ();}
// Obtain the latest published article
Public Post [] getrecentposts (string blogid, string username, string password, int numberofposts) {If (LOGIN (username, password) {// omitted} return NULL ;} // publish the media object public urldata newmediaobject (string blogid, string username, string password, filedata file) {If (LOGIN (username, password) return New urldata ();} return new urldata ();} // custom Method
Public bool login (string username, string pass) {// for user verification} # endregion}
OK .. this is almost the case .. enter this ashx in the browser to check whether the above implementation method list and data type are available, just like the local test page of WebService. however, XML-RPC cannot be tested locally. now you can try it with Windows Live writer.
Use Windows Live writer to publish a blog
Like adding other blog sites, You must select metaweblog (custom) when selecting the blog service. Enter the path of the ashx file for the script address.
Success! Because the XML-RPC solution prepared by others is used, it is quite simple to implement it. because live writer is still in beta stage, there are still some imperfections ,.. we look forward to the official version of live writer ..