Update: I have provided complete code example in answer below.
I have built my own little custom XML-RPC server, and since I'd like to keep things simple, on both server and client side, what I would like to accomplish is to create a simplest possible client (in C# preferably) using WCF.
Let's say that Contract for service exposed via XML-RPC is as follows:
[ServiceContract]
public interface IContract
{
[OperationContract(Action="Ping")]
string Ping(); // server returns back string "Pong"
[OperationContract(Action="Echo")]
string Echo(string message); // server echoes back whatever message is
}
So, there are two example methods, one without any arguments, and another with simple string argument, both returning strings (just for sake of example). Service is exposed via http.
Aaand, what's next? :)
XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP(S) as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data.
Windows Communication Foundation (WCF) and gRPC are both implementations of the Remote Procedure Call (RPC) pattern. This pattern aims to make calls to services that run on a different machine, or in a different process, work seamlessly, like method calls in the client application.
XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.
XML-RPC is among the simplest and most foolproof web service approaches that makes it easy for computers to call procedures on other computers. XML-RPC permits programs to make function or procedure calls across a network. XML-RPC uses the HTTP protocol to pass information from a client computer to a server computer.
Inspired by Doobi's answer, I looked up some more info (examples) on the subject, and came up with the following findings.
Steps to create simple WCF XML-RPC client:
Example code
using System;
using System.ServiceModel;
using Microsoft.Samples.XmlRpc;
namespace ConsoleApplication1
{
// describe your service's interface here
[ServiceContract]
public interface IServiceContract
{
[OperationContract(Action="Hello")]
string Hello(string name);
}
class Program
{
static void Main(string[] args)
{
ChannelFactory<IServiceContract> cf = new ChannelFactory<IServiceContract>(
new WebHttpBinding(), "http://www.example.com/xmlrpc");
cf.Endpoint.Behaviors.Add(new XmlRpcEndpointBehavior());
IServiceContract client = cf.CreateChannel();
// you can now call methods from your remote service
string answer = client.Hello("World");
}
}
}
Example request/response messages
Request XML
<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>Hello</methodName>
<params>
<param>
<value>
<string>World</string>
</value>
</param>
</params>
</methodCall>
Response XML
<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
<params>
<param>
<value>
<string>Hello, World!</string>
</value>
</param>
</params>
</methodResponse>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With