How to Use AspNetCore.XmlRpc

186 views 0 comments last modified about 6 months ago Raymond


In this page

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

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


3.2 Use middleware

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



            // Use XmlRpc middleware

            app.UseMvc(routes =>
                     name: "default",
                     template: "{controller=Home}/{action=Index}/{id?}");
                     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

Add comment

Comments (0)

No comments yet.