By using this site, you acknowledge that you have read and understand our Cookie policy, Privacy policy and Terms .
access_time 3 years ago visibility1251 comment 0 languageEnglish

This post provides the detailed steps about how to use AspNetCore.XmlRpc in your .net core projects.

1. Install the package

You can install the package through NuGet PowerShell module:

Install-Package AspNetCore.XmlRpc

2. Configurations

In your appsettings.json, add the following configuration section under root:

"XmlRpc": {
     "GenerateSummary": "true",
     "SummaryEndpoint": "/api/xmlrpc/summary",
     "RsdEndpoint": "/api/xmlrpc/rsd",
     "Endpoint": "/api/xmlrpc/endpoint",
     "EngineName": "AspNetCore.XmlRpc",
     "BlogIdTokenName": "blogId",
     "HomePageEndpointPattern": "/Blog/{blogId}",
     "ManifestEndpoint": "/api/xmlrpc/manifest"
   }

Configuration item Description Sample value
GenerateSummary Whether to enable summary endpoint true
SummaryEndpoint URL for summary endpoint /api/xmlrpc/summary
RsdEndpoint URL for Real Simple Discovery end point. This is used by client tools like Open Live Writer to detect services /api/xmlrpc/rsd
Endpoint URL for the main remote procedure calls endpoint /api/xmlrpc/endpoint
EngineName Engine name that implemented the service AspNetCore.XmlRpc
BlogIdTokenName The token name for blogId. blogId
HomePageEndpointPattern Blog home page URL /Blog/{blogId}
ManifestEndpoint URL for manifest endpoint which describe the capabilities of MetaWeblog implementation. /api/xmlrpc/manifest

3. Change Startup.cs class

3.1 Register service

You need to implement your own IMetaWeblogXmlRpcService.

// This method gets called by the runtime. Use this method to add services to the container.
         public void ConfigureServices(IServiceCollection services)
         {
             // Configure XmlRpc
             services.Configure<XmlRpcOptions>(Configuration.GetSection("XmlRpc"));

            // Add meta weblog
             services.AddMetaWeblog<MetaWeblogXmlRpcService, DefaultMetaWeblogEndpointProvider>();

            services.AddMvc();
         }

3.2 Use middleware

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IDatabaseInitializer dbInitializer)
         {

            //…

            app.UseStaticFiles();

            // Use XmlRpc middleware
             app.UseMetaWeblog();

            app.UseMvc(routes =>
             {
                 routes.MapRoute(
                     name: "default",
                     template: "{controller=Home}/{action=Index}/{id?}");
                 routes.MapRoute(
                     name: "areas",
                     template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

            });
         }

3.3 Implement your own MetaWeblog XML-RPC services.

You can also inject any scoped or singleton services into your own service. For example the following sample shows that the service depends on a number of other services.

public class MetaWeblogXmlRpcService : IMetaWeblogXmlRpcService
     {
         private readonly IConfigService configService;
         private readonly IContextUnitOfWork unitOfWork;
         private readonly UserManager<ApplicationUser> userManager;
         private readonly SignInManager<ApplicationUser> signInManager;
         private readonly ILogger<MetaWeblogXmlRpcService> logger;
         private readonly IHttpContextAccessor contextAccessor;
         private readonly IOptions<BlogConfig> blogOptions;
         private readonly IOptions<SiteConfig> siteOptions;
         private readonly IHostingEnvironment environment;

        public MetaWeblogXmlRpcService(IConfigService configService,
             IContextUnitOfWork unitOfWork,
             UserManager<ApplicationUser> userManager,
             SignInManager<ApplicationUser> signInManager,
             ILogger<MetaWeblogXmlRpcService> logger,
             IHttpContextAccessor contextAccessor,
             IOptions<BlogConfig> blogOptions,
             IOptions<SiteConfig> siteOptions,
             IHostingEnvironment environment)
         {

}

}

3.5 Add links to your blog home page

This step is necessary to ensure that client tools like Open Live Writer can automatically detect the settings.

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="@string.Concat(options.Value.RsdEndpoint,'/','myblogid' )" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="@string.Concat(options.Value.ManifestEndpoint,'/','myblogid' )" />

4. Sample project

https://github.com/FahaoTang/AspNetCore.XmlRpc

info Last modified by Raymond at 3 years ago * This page is subject to Site terms.

More from Kontext

local_offer xml-rpc local_offer lite-log

visibility 221
thumb_up 1
access_time 3 years ago

Release date 2018-03-03 Changes Added PostId (attribute postid in MetaWeblog) into the predefined data model for PostInfo. public class PostInfo &nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [DataMember(Name = "title")] ...

open_in_new View

local_offer xml-rpc

visibility 334
thumb_up 0
access_time 3 years ago

There are four endpoints exposed by the middleware: summary, RSD, manifest for blog capability and RPC call main endpoint.

open_in_new View

local_offer xml-rpc

visibility 1799
thumb_up 0
access_time 3 years ago

This is my first contribution in open source world. It is forked from XmlRpcMvc project in Github.

open_in_new View

info About author

Kontext Column

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.

Learn more arrow_forward
info Follow us on Twitter to get the latest article updates. Follow us