Created
April 13, 2020 20:20
-
-
Save marcosbozzani/83515648ef4ff678bfae7843a8de2f69 to your computer and use it in GitHub Desktop.
xmlrpcnet with default values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CookComputing.XmlRpc; | |
using System; | |
namespace XmlRpcClient | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var service = XmlRpcProxyGen.Create<ICalcService>(); | |
Console.WriteLine($"1: {service.Add(1)}"); | |
Console.WriteLine($"1 + 2: {service.Add(1, 2)}"); | |
Console.WriteLine($"1 + 2 + 3: {service.Add(1, 2, 3)}"); | |
Console.WriteLine("XmlRpcClient. Press any key to exit"); | |
Console.ReadKey(true); | |
} | |
} | |
[XmlRpcUrl("http://127.0.0.1:5678/calc")] | |
public interface ICalcService : IXmlRpcProxy | |
{ | |
[XmlRpcMethod("add")] | |
int Add(int a, int b = 0, int c = 0); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CookComputing.XmlRpc; | |
using System; | |
using System.Runtime.Remoting; | |
namespace XmlRpcServer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
RemotingConfiguration.Configure("XmlRpcServer.exe.config", false); | |
RemotingConfiguration.RegisterWellKnownServiceType | |
( | |
typeof(CalcService), "calc", WellKnownObjectMode.Singleton | |
); | |
Console.WriteLine("XmlRpcServer. Press any key to exit"); | |
Console.ReadKey(true); | |
} | |
} | |
public class CalcService : MarshalByRefObject | |
{ | |
[XmlRpcMethod("add")] | |
public int Add(int a, int b = 0, int c = 0) | |
{ | |
return a + b + c; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | |
</startup> | |
<system.runtime.remoting> | |
<application> | |
<channels> | |
<channel ref="http" bindTo="127.0.0.1" port="5678"> | |
<serverProviders> | |
<formatter type="CookComputing.XmlRpc.XmlRpcServerFormatterSinkProvider, CookComputing.XmlRpcServerV2" /> | |
</serverProviders> | |
</channel> | |
</channels> | |
</application> | |
</system.runtime.remoting> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment