Vaster Clemens のチュートリアルを使用してサンプルの xmlrpc C# サーバー クライアントを作成しました。
http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx
C# サーバーから C# クライアントに正常に接続できますが、Java クライアントを使用して C# サーバーに接続しようとすると、次のエラーのみが表示されます。
HTTP サーバーが予期しないステータスを返しました: 内部サーバー エラー
公開されている C# サーバー API は次のとおりです。
[ServiceContract]
public interface ITestAPI {
[OperationContract(Action = "test.returnSum")]
int returnSum(
int a,
int b);
これはサーバー部分です:
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();
C# クライアントは次のようになります。
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);
この後、ここにあるサンプル Java XML-RPC クライアントを実装して、実行中の C# サーバーに接続しようとしました。
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());
}
}
}
そして、何も機能しません。
どんな種類の助けも大歓迎です。