How to Use AspNetCore.XmlRpc

visibility 1,734 access_time 5 years ago 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

            // 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

info Last modified by Raymond 5 years ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

timeline Stats
Page index 1.03
More from Kontext
Endpoints in AspNetCore.XmlRpc Explained
visibility 477
thumb_up 0
access_time 5 years ago
XML-RPC Library for ASP.NET Core 2.0
visibility 3,047
thumb_up 0
access_time 5 years ago
AspNetCore.XmlRpc 1.0.0-alpha.6 is ready
visibility 272
thumb_up 1
access_time 5 years ago