xml-rpc(1)-first demo

今天简单的研究了一下xml-rpc,做了一个小demo,使得最近开发的一个blog系统可以试用word2007来发表文章,现在还没有具体的实现,只是试Word能识别我写的Api.

MetaWeblogService.cs

xml-rpc(1)-first demo using  System;
xml-rpc(1)-first demo
using  System.Collections.Generic;
xml-rpc(1)-first demo
using  System.Text;
xml-rpc(1)-first demo
xml-rpc(1)-first demo
using  CookComputing.MetaWeblog;
xml-rpc(1)-first demo
using  CookComputing.XmlRpc;
xml-rpc(1)-first demo
using  CookComputing.Blogger;
xml-rpc(1)-first demo
xml-rpc(1)-first demo
namespace  BusiDao.MetaWeblog
xml-rpc(1)-first demo
{
xml-rpc(1)-first demo    
public class MetaWeblogService : XmlRpcService
xml-rpc(1)-first demo    
{
xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"blogger.getUsersBlogs", Description = "获取博客信息")]
xml-rpc(1)-first demo        
public BlogInfo[] getUsersBlogs(string appKey, string username, string password)
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            BlogInfo[] infoarr 
= new BlogInfo[1];
xml-rpc(1)-first demo            
for (int i = 0; i < 1; i++)
xml-rpc(1)-first demo            
{
xml-rpc(1)-first demo                infoarr[i].url 
= string.Format("http://{0}.html", i);
xml-rpc(1)-first demo                infoarr[i].blogName 
= string.Format("测试 {0}", i);
xml-rpc(1)-first demo                infoarr[i].blogid 
= i.ToString();
xml-rpc(1)-first demo            }

xml-rpc(1)-first demo
xml-rpc(1)-first demo            
return infoarr;
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"metaWeblog.getCategories", Description = "获取分类列表")]
xml-rpc(1)-first demo        
public CategoryInfo[] getCategories(string blogid, string username, string password)
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            CategoryInfo[] infoarr 
= new CategoryInfo[5];
xml-rpc(1)-first demo
xml-rpc(1)-first demo            
for (int i = 0; i < 5; i++)
xml-rpc(1)-first demo            
{
xml-rpc(1)-first demo                infoarr[i].categoryid 
= i.ToString();
xml-rpc(1)-first demo                infoarr[i].description 
= i.ToString();
xml-rpc(1)-first demo                infoarr[i].htmlUrl 
= string.Format("http://{0}.html", i);
xml-rpc(1)-first demo                infoarr[i].rssUrl 
= string.Format("http://{0}.xml", i);
xml-rpc(1)-first demo                infoarr[i].title 
= string.Format("测试 {0}", i);
xml-rpc(1)-first demo            }

xml-rpc(1)-first demo
xml-rpc(1)-first demo            
return infoarr;
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"metaWeblog.newPost", Description = "发表日志")]
xml-rpc(1)-first demo        
public string newPost(string blogid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            
return "1";
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"metaWeblog.getRecentPosts", Description = "获取日志列表")]
xml-rpc(1)-first demo        
public CookComputing.MetaWeblog.Post[] getRecentPosts(string blogid, string username, string password, int numberOfPosts) 
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            CookComputing.MetaWeblog.Post[] infoarr 
= new CookComputing.MetaWeblog.Post[20];
xml-rpc(1)-first demo            
for (int i = 0; i < 20; i++)
xml-rpc(1)-first demo            
{
xml-rpc(1)-first demo                infoarr[i].categories 
= new string[2"1""2" };
xml-rpc(1)-first demo                infoarr[i].dateCreated 
= DateTime.Now;
xml-rpc(1)-first demo                infoarr[i].description 
= string.Format("说明 {0}", i);
xml-rpc(1)-first demo                Enclosure el
=new Enclosure();
xml-rpc(1)-first demo                el.length
=i;
xml-rpc(1)-first demo                el.type
=i.ToString();
xml-rpc(1)-first demo                el.url
=string.Format("http://{0}.html", i);
xml-rpc(1)-first demo                infoarr[i].enclosure 
= el;
xml-rpc(1)-first demo                infoarr[i].link 
= string.Format("http://{0}.html", i);
xml-rpc(1)-first demo                infoarr[i].mt_allow_comments 
= true;
xml-rpc(1)-first demo                infoarr[i].mt_allow_pings 
= true;
xml-rpc(1)-first demo                infoarr[i].mt_convert_breaks 
= true;
xml-rpc(1)-first demo                infoarr[i].mt_excerpt 
= "mt_excerpt";
xml-rpc(1)-first demo                infoarr[i].mt_text_more 
= "more 更多";
xml-rpc(1)-first demo                infoarr[i].permalink 
= "";
xml-rpc(1)-first demo                infoarr[i].postid 
= i.ToString();
xml-rpc(1)-first demo                Source su 
= new Source();
xml-rpc(1)-first demo                su.name 
= string.Format("测试 {0}", i);
xml-rpc(1)-first demo                su.url 
= string.Format("http://{0}.html", i);
xml-rpc(1)-first demo                infoarr[i].source 
= su;
xml-rpc(1)-first demo                infoarr[i].title 
= string.Format("标题 {0}", i);
xml-rpc(1)-first demo                infoarr[i].userid 
= "1";
xml-rpc(1)-first demo            }

xml-rpc(1)-first demo
xml-rpc(1)-first demo            
return infoarr;
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"metaWeblog.getPost", Description = "获取日志信息")]
xml-rpc(1)-first demo        
public CookComputing.MetaWeblog.Post getPost(string postid, string username, string password)
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            CookComputing.MetaWeblog.Post p 
= new CookComputing.MetaWeblog.Post();
xml-rpc(1)-first demo            p.categories 
=  new string[2"1""2" };
xml-rpc(1)-first demo            p.dateCreated 
= DateTime.Now;
xml-rpc(1)-first demo            p.description 
= "说明" + postid.ToString();
xml-rpc(1)-first demo            Enclosure el 
= new Enclosure();
xml-rpc(1)-first demo            el.length 
= 1;
xml-rpc(1)-first demo            el.type 
= "2";
xml-rpc(1)-first demo            el.url 
= string.Format("http://{0}.html"3);
xml-rpc(1)-first demo            p.enclosure 
= el;
xml-rpc(1)-first demo            p.link 
= "link";
xml-rpc(1)-first demo            p.mt_allow_comments 
= true;
xml-rpc(1)-first demo            p.mt_allow_pings 
= true;
xml-rpc(1)-first demo            p.mt_convert_breaks 
= true;
xml-rpc(1)-first demo            p.mt_excerpt 
= "mt_excerpt";
xml-rpc(1)-first demo            p.mt_text_more 
= "mt_text_more";
xml-rpc(1)-first demo            p.permalink 
= "permalink";
xml-rpc(1)-first demo            p.postid 
= postid;
xml-rpc(1)-first demo            Source su 
= new Source();
xml-rpc(1)-first demo            su.name 
= string.Format("测试 {0}"1);
xml-rpc(1)-first demo            su.url 
= string.Format("http://{0}.html"1);
xml-rpc(1)-first demo            p.source 
= su;
xml-rpc(1)-first demo            p.title 
= "标题" + postid;
xml-rpc(1)-first demo            p.userid 
= "1";
xml-rpc(1)-first demo
xml-rpc(1)-first demo            
return p;
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo
xml-rpc(1)-first demo        [XmlRpcMethod(
"metaWeblog.editPost", Description = "修改日志")]
xml-rpc(1)-first demo        
public bool editPost(string postid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
xml-rpc(1)-first demo        
{
xml-rpc(1)-first demo            
return true;
xml-rpc(1)-first demo        }

xml-rpc(1)-first demo    }

xml-rpc(1)-first demo}

你可能感兴趣的:(first)