XmlRpcNg 1.0.0

dotnet add package XmlRpcNg --version 1.0.0
                    
NuGet\Install-Package XmlRpcNg -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XmlRpcNg" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XmlRpcNg" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="XmlRpcNg" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XmlRpcNg --version 1.0.0
                    
#r "nuget: XmlRpcNg, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XmlRpcNg@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XmlRpcNg&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=XmlRpcNg&version=1.0.0
                    
Install as a Cake Tool

XML-RPC-ng

.NET License Build Status

A modern, high-performance C# client implementation of the XML-RPC protocol for .NET 9.0 applications.

๐ŸŽฏ Project Overview

XML-RPC-ng ("XML-RPC Next Generation") is a complete rewrite of the XML-RPC protocol implementation designed specifically for modern .NET applications. This library provides a clean, type-safe, and performant way to integrate XML-RPC communication into your .NET projects.

Key Features

  • โœ… Modern .NET 9.0: Built with the latest .NET features and performance optimizations
  • โœ… Async/Await Support: First-class support for asynchronous operations
  • โœ… Type-Safe: Strong typing with automatic serialization/deserialization
  • โœ… Flexible Configuration: Fluent API for easy client configuration
  • โœ… Comprehensive Error Handling: Structured exception hierarchy for different error scenarios
  • โœ… HTTP/HTTPS Support: Full support for both HTTP and secure HTTPS connections
  • โœ… Extensible Architecture: Easy to extend with custom serializers and transports
  • โœ… Production Ready: Thoroughly tested and designed for production workloads

๐Ÿš€ What Makes XML-RPC-ng Different?

Unlike legacy XML-RPC implementations, XML-RPC-ng is built from the ground up to take advantage of modern .NET capabilities:

  • Performance Optimized: Minimal allocations and efficient memory usage
  • Modern C#: Uses latest language features like records, pattern matching, and nullable reference types
  • DI Friendly: Designed with dependency injection in mind
  • Extensible: Plugin architecture for custom behaviors

๐Ÿ“ฆ Installation

dotnet add package XmlRpcNg

Prerequisites

  • .NET 9.0 or later
  • Visual Studio 2022 or JetBrains Rider

๐Ÿ—๏ธ Architecture Overview

Core Components

  • XmlRpcClient: Main client interface for making XML-RPC calls with automatic type conversion, timeout configuration, and comprehensive error handling
  • XmlRpcClientBuilder: Fluent configuration API for setting up clients with WithUrl(), WithTimeout(), WithHttpClient(), and WithSerializer() methods
  • IXmlRpcSerializer: Pluggable serialization system handling automatic conversions between .NET types and XML-RPC values
  • IXmlRpcTransport: Pluggable transport layer with HTTP/HTTPS support, configurable timeouts, and cancellation token support
  • XmlRpcTypes: Type-safe XML-RPC data representations including XmlRpcInt, XmlRpcBoolean, XmlRpcString, XmlRpcDouble, XmlRpcDateTime, XmlRpcBase64, XmlRpcArray, and XmlRpcStruct

Data Type Mappings

The library automatically converts between .NET types and XML-RPC values:

  • int โ†” XmlRpcInt
  • bool โ†” XmlRpcBoolean
  • string โ†” XmlRpcString
  • double/float โ†” XmlRpcDouble
  • DateTime โ†” XmlRpcDateTime
  • byte[] โ†” XmlRpcBase64
  • Dictionary<string, T> โ†” XmlRpcStruct
  • Arrays/Collections โ†” XmlRpcArray

Design Patterns

  • Builder Pattern: For fluent client configuration
  • Strategy Pattern: For pluggable serialization and transport strategies
  • Dependency Injection: Service-friendly design with registration support
  • Async/Await: Modern asynchronous programming model throughout

Common Usage Patterns

Basic Method Call

// Basic usage

// Example: Get state name by code
const string endpoint = "http://betty.userland.com/RPC2";
const string methodName = "examples.getStateName";
const int stateCode = 23;

// Create client
var client = new XmlRpcClientBuilder()
     .WithUrl(endpoint)
     .WithTimeout(TimeSpan.FromSeconds(30))
     .Build();

// Call method 
var result = await client.CallAsync<string>(methodName, stateCode);

Console.WriteLine($"State name: {result}");
// Result: "State name: Minnesota"

Dictionary/Struct Parameter

var data = new Dictionary<string, object>
{
    { "name", "John" },
    { "age", 30 },
    { "active", true }
};

var result = await client.CallAsync<string>("processUser", data);

Advanced Usage with Dependency Injection

// In Program.cs or Startup.cs
services.AddXmlRpcClient(options =>
{
    options.Url = "https://api.example.com/xmlrpc";
    options.Timeout = TimeSpan.FromSeconds(30);
});

// In your service
public class MyService
{
    private readonly XmlRpcClient _client;

    public MyService(XmlRpcClient client)
    {
        _client = client;
    }

    public async Task<string> GetResult()
    {
        return await _client.CallAsync<string>("methodName", parameter);
    }
}

Custom Serialization

// Register custom serializer
services.AddXmlRpcClient(options =>
{
    options.Url = "https://api.example.com/xmlrpc";
})
.WithCustomSerializer<CustomXmlRpcSerializer>();

๐Ÿ”ง Error Handling

XML-RPC-ng provides comprehensive error handling with specific exception types:

try
{
    var result = await client.CallAsync<string>("method", param);
}
catch (XmlRpcFaultException ex)
{
    // Server returned a fault
    Console.WriteLine($"Server fault: {ex.FaultCode} - {ex.FaultString}");
}
catch (XmlRpcNetworkException ex)
{
    // Network communication error
    Console.WriteLine($"Network error: {ex.Message}");
}
catch (XmlRpcProtocolException ex)
{
    // XML-RPC protocol violation
    Console.WriteLine($"Protocol error: {ex.Message}");
}
catch (XmlRpcXmlException ex)
{
    // XML parsing error
    Console.WriteLine($"XML error: {ex.Message}");
}
catch (XmlRpcTypeConversionException ex)
{
    // Type conversion failed
    Console.WriteLine($"Type conversion error: {ex.Message}");
}

๐Ÿงช Testing

# Run all tests
dotnet test

# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run specific test project
dotnet test XmlRpcNg.Tests

๐Ÿ“š API Reference

XmlRpcClient Methods

Method Description Example
CallAsync<T>(method, params) Call XML-RPC method with return type await client.CallAsync<string>("method", 42)
CallAsync(method, returnType, params) Call with explicit return type await client.CallAsync("method", typeof(string), 42)

Configuration Options

Option Type Default Description
Url string - XML-RPC endpoint URL
Timeout TimeSpan 30 seconds Request timeout
HttpClient HttpClient null Custom HTTP client

๐Ÿค Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests.

Development Setup

# Clone the repository
git clone https://github.com/yourusername/XmlRpcNg.git
cd XmlRpcNg

# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run tests
dotnet test

๐Ÿ“„ License

This project is licensed under MIT License - see the LICENSE file for details.

๐Ÿค– AI-Assisted Development

For transparency, this project was developed with the assistance of AI tools, specifically GLM-4.6 (General Language Model 4.6).

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 220 10/16/2025 1.0.0 is deprecated because it has critical bugs.