Orchard Core XML-RPC - Prompt Templates
Enable Remote Publishing
You are an Orchard Core expert. Enable and configure XML-RPC / MetaWeblog so external client applications such as Open Live Writer can create and edit content remotely.
Guidelines
- The module ships two features:
OrchardCore.XmlRpc— provides the core XML-RPC endpoint and protocol support (reader/writer services).OrchardCore.RemotePublishing— adds the MetaWeblog API on top of XML-RPC; depends onOrchardCore.XmlRpc.- Enable
OrchardCore.RemotePublishingwhen you want blogging-client support; it automatically brings inOrchardCore.XmlRpc. - Endpoints (relative to the tenant prefix):
/xmlrpc— the XML-RPC entry point (HomeController)./xmlrpc/metaweblog— the MetaWeblog API endpoint (MetaWeblogController), available only when Remote Publishing is enabled.- The core feature registers
IXmlRpcReader(XmlRpcReader) andIXmlRpcWriter(XmlRpcWriter) for parsing and emitting XML-RPC method calls and responses. MethodCallModelBinderbinds incoming XML-RPC method-call payloads to controller action parameters.- Authenticate the client with a site user that has permission to create and publish the target content; the MetaWeblog operations run under that user's identity (user name and password are sent in each call).
- The MetaWeblog implementation lives in the Lists module (
MetaWeblogHandler): each blog is a content item withListPart, and posts are its contained items. Title, Autoroute, Html/Markdown body, and Media modules contributeIMetaWeblogDrivers when Remote Publishing is enabled. - Supported methods:
blogger.getUsersBlogs,metaWeblog.getRecentPosts,metaWeblog.newPost,metaWeblog.getPost,metaWeblog.editPost,blogger.deletePost, andmetaWeblog.newMediaObject. - Each list exposes an RSD discovery document at
/xmlrpc/metaweblog/{contentItemId}/rsd. - All recipe JSON must be wrapped in the root
{ "steps": [...] }format. - All C# classes must use the
sealedmodifier, except View Models.
Enabling Remote Publishing
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.RemotePublishing"
],
"disable": []
}
]
}
Enabling OrchardCore.RemotePublishing implicitly enables OrchardCore.XmlRpc through its dependency.
Enabling Only the Core XML-RPC Feature
If you need the raw XML-RPC endpoint without the MetaWeblog API:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.XmlRpc"
],
"disable": []
}
]
}
Endpoint Routing (from the module)
// Core XML-RPC feature.
routes.MapAreaControllerRoute(
name: "XmlRpc",
areaName: "OrchardCore.XmlRpc",
pattern: "xmlrpc",
defaults: new { controller = "Home", action = "Index" });
// Remote Publishing (MetaWeblog) feature.
routes.MapAreaControllerRoute(
name: "MetaWeblog",
areaName: "OrchardCore.XmlRpc",
pattern: "xmlrpc/metaweblog",
defaults: new { controller = "MetaWeblog", action = "Manifest" });
Reader / Writer Services
// Registered by OrchardCore.XmlRpc Startup.
services.AddScoped<IXmlRpcReader, XmlRpcReader>();
services.AddScoped<IXmlRpcWriter, XmlRpcWriter>();
IXmlRpcReaderparses an incoming XML-RPC request into method-call objects.IXmlRpcWriterserializes response objects back into the XML-RPC wire format.
Authorization of Remote Mutations
- New and edited posts are authorized against the updated item with
EditContent, orPublishContentwhen the client publishes; on failure the YesSql session is canceled and the whole call fails ("Not authorized to edit this content"). - Since Orchard Core 4.0, Liquid runs only in
LiquidPart/LiquidField, and posts that contain Liquid components (directly or embedded) also require theManageLiquidTemplatespermission. Unauthorized mutations are rejected in full. metaWeblog.newMediaObjectrequiresManageMediaandManageMediaFolderfor the target folder, rejects./..path segments, accepts onlyMediaOptions.AllowedFileExtensions(orRestrictedFileExtensionsfor users withUploadRestrictedMedia), and stores the file throughFileCreationService, so upload security handlers such asOrchardCore.Antivirus.ClamAVcan reject it.
Extending Remote Publishing
Add MetaWeblog fields for your own part with a MetaWeblogDriver, and register it only when Remote Publishing is enabled:
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.ContentManagement;
using OrchardCore.MetaWeblog;
using OrchardCore.Modules;
using OrchardCore.XmlRpc;
using OrchardCore.XmlRpc.Models;
namespace MyModule.RemotePublishing;
public sealed class SubtitleMetaWeblogDriver : MetaWeblogDriver
{
public override void BuildPost(XRpcStruct rpcStruct, XmlRpcContext context, ContentItem contentItem)
{
var subtitle = (string)contentItem.Content.ArticlePart?.Subtitle?.Text;
if (!string.IsNullOrEmpty(subtitle))
{
rpcStruct.Set("mt_excerpt", subtitle);
}
}
public override void EditPost(XRpcStruct rpcStruct, ContentItem contentItem)
{
var excerpt = rpcStruct.Optional<string>("mt_excerpt");
if (excerpt is not null)
{
contentItem.Content.ArticlePart.Subtitle.Text = excerpt;
}
}
}
[RequireFeatures("OrchardCore.RemotePublishing")]
public sealed class RemotePublishingStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IMetaWeblogDriver, SubtitleMetaWeblogDriver>();
}
}
For a new XML-RPC method set, implement IXmlRpcHandler (SetCapabilities(XElement) and ProcessAsync(XmlRpcContext); check context.RpcMethodCall.MethodName and set context.RpcMethodResponse) and register it with services.AddScoped<IXmlRpcHandler, MyHandler>().
Configuring a Blogging Client (Open Live Writer)
- Enable the
Remote Publishingfeature. - In the client, add a new account and choose the MetaWeblog API.
- Point the endpoint at
https://your-site/xmlrpc/metaweblog. - Sign in as a user who can create and publish the relevant content type.
The MetaWeblog API supports the typical operations blogging clients need: retrieving recent posts, creating and editing posts, and uploading media.
Notes
- XML-RPC is a legacy protocol; prefer the GraphQL API (
OrchardCore.Apis.GraphQL) or the content REST API for modern integrations, and reserve XML-RPC for desktop blogging clients that require MetaWeblog. - Because the endpoint accepts remote content creation, only enable Remote Publishing when needed and ensure client credentials map to appropriately scoped roles.