I have created a sample xmlrpc C# server-client using Vaster Clemens tutorials
http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx
I am successfully able to connect to my C# server to the C# client, but whenever I try to connect to the C# server using my Java Client , I get only this error :
HTTP server returned unexpected status: Internal Server Error
Here is the C# server API exposed :
[ServiceContract]
public interface ITestAPI {
[OperationContract(Action = "test.returnSum")]
int returnSum(
int a,
int b);
This is the server part:
Uri baseAddress = new UriBuilder(Uri.UriSchemeHttp, Environment.MachineName, 8080, "/testDemo/").Uri;
ServiceHost serviceHost = new ServiceHost(typeof(TestAPI));
var epXmlRpc = serviceHost.AddServiceEndpoint(typeof(ITestAPI), new WebHttpBinding(WebHttpSecurityMode.None), new Uri(baseAddress, "./test"));
epXmlRpc.Behaviors.Add(new XmlRpcEndpointBehavior());
serviceHost.Open();
Console.ReadLine();
serviceHost.Close();
The C# client goes here :
Uri blogAddress = new UriBuilder(Uri.UriSchemeHttp, Environment.MachineName, PORT_NUMBER, pathValue).Uri;
ChannelFactory<ITestAPI> testAPIFactory = new ChannelFactory<ITestAPI>(new WebHttpBinding(WebHttpSecurityMode.None), new EndpointAddress(blogAddress));
testAPIFactory.Endpoint.Behaviors.Add(new XmlRpcEndpointBehavior());
testAPI = testAPIFactory.CreateChannel();
testAPI.returnSum(1,2);
After this I tried to implement a sample Java XML-RPC client given here and tried to connect it to the running C# server
http://www.tutorialspoint.com/xml-rpc/xml_rpc_examples.htm
public class JavaClient {
public static void main (String [] args) {
try {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://localhost:8080/testDemo/test"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Vector params = new Vector();
params.addElement( new Integer(5) );
params.addElement( new Integer(5) );
Integer result = (Integer)client.execute( "returnSum", params );
if ( result != null )
System.out.println( "result" + result);
} catch (XmlRpcException exception) {
System.err.println("JavaClient: XML−RPC Fault #" +
Integer.toString(exception.code) + ": " +
exception.toString());
} catch (Exception exception) {
System.err.println("JavaClient: " + exception.toString());
}
}
}
And nothing works.
Any kind of help would be much appreciated.
I was able to solve this problem guys: the API is supposed to be called like this : client.execute( "test.returnSum", params ); from your client. i.e. the same string you mentioned in your operation contract.