XML-RPC C# Client
The C# client only needs to add a reference to the XML-RPC assembly and we are ready to access the Java servlet.
Usually I will have a method on the Java side called isAlive which I can call just to test if the server is indeed available. Calling this method or service is also not very complicated or difficult.
{
// Create the XML-RPC request object
XmlRpcRequest request = new XmlRpcRequest();
// Set the method name that needs to be called
request.MethodName = "ServiceHandler.isAlive";
// Send the request and receive the response
XmlRpcResponse response = request.Send( GetServer() );
// Convert the result to a boolean value
return (bool) response.Value;
}
Note the Send method calls another method GetServer, this method will get the address of the Java server. The address is just a standard formatted HTTP address.
{
// The address of the Java servlet, hard coded in this case
string result = "http://myJavaServer/website/XML-RPCServlet";
// Return the string address
return result;
}
This is how simple and easy it is to communicate with a Java server from C# via XML-RPC and a Servlet, given the Java server side of things is a bit more involved than the client side but that is a good thing, the easier it is for the client to communicate with the server the better. This also helps alot with maintenance just because it is so easy to use.