zoukankan      html  css  js  c++  java
  • xmlrpc(1)first demo

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

    MetaWeblogService.cs

    using System;
    using System.Collections.Generic;
    using System.Text;

    using CookComputing.MetaWeblog;
    using CookComputing.XmlRpc;
    using CookComputing.Blogger;

    namespace BusiDao.MetaWeblog
    {
        
    public class MetaWeblogService : XmlRpcService
        
    {

            [XmlRpcMethod(
    "blogger.getUsersBlogs", Description = "获取博客信息")]
            
    public BlogInfo[] getUsersBlogs(string appKey, string username, string password)
            
    {
                BlogInfo[] infoarr 
    = new BlogInfo[1];
                
    for (int i = 0; i < 1; i++)
                
    {
                    infoarr[i].url 
    = string.Format("http://{0}.html", i);
                    infoarr[i].blogName 
    = string.Format("测试 {0}", i);
                    infoarr[i].blogid 
    = i.ToString();
                }


                
    return infoarr;
            }


            [XmlRpcMethod(
    "metaWeblog.getCategories", Description = "获取分类列表")]
            
    public CategoryInfo[] getCategories(string blogid, string username, string password)
            
    {
                CategoryInfo[] infoarr 
    = new CategoryInfo[5];

                
    for (int i = 0; i < 5; i++)
                
    {
                    infoarr[i].categoryid 
    = i.ToString();
                    infoarr[i].description 
    = i.ToString();
                    infoarr[i].htmlUrl 
    = string.Format("http://{0}.html", i);
                    infoarr[i].rssUrl 
    = string.Format("http://{0}.xml", i);
                    infoarr[i].title 
    = string.Format("测试 {0}", i);
                }


                
    return infoarr;
            }


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


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


                
    return infoarr;
            }


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

                
    return p;
            }


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

        }

    }
  • 相关阅读:
    C#数组的Map、Filter、Reduce操作
    Safari中的input、textarea无法输入的问题
    小练手:用HTML5 Canvas绘制谢尔宾斯基三角形
    Web前端页面的浏览器兼容性测试心得(三)总结一些IE8兼容问题的解决方案
    大杀器Bodymovin和Lottie:把AE动画转换成HTML5/Android/iOS原生动画
    Web前端页面的浏览器兼容性测试心得(二)搭建原汁原味的IE8测试环境
    Web前端页面的浏览器兼容性测试心得(一)搭建测试用本地静态服务器
    CSS3、SVG、Canvas、WebGL动画精选整理
    利用JS代码快速获得知网论文作为参考文献的引用文本
    使用Node.js快速搭建简单的静态文件服务器
  • 原文地址:https://www.cnblogs.com/nasa/p/632344.html
Copyright © 2011-2022 走看看