我想从我的 silvelight 应用程序与控制台 XML RPC 服务器通信。有可能吗?
步骤: 1. 启动 Console XML RPC 服务器
Console XML RPC 服务器的代码是这样的:
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using CookComputing.XmlRpc;
public class StateNameServer : MarshalByRefObject, IStateName
{
public string GetStateName(int stateNumber)
{
return "whatever";
}
}
class _
{
static void Main(string[] args)
{
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
props["port"] = 5678;
HttpChannel channel = new HttpChannel(props,null,new XmlRpcServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel,false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(StateNameServer),"statename.rem",WellKnownObjectMode.Singleton);
Console.WriteLine("Press <ENTER> to shutdown");
Console.ReadLine();
}
}
运行 Silverlight 应用程序 我使用了来自http://code.google.com/p/xmlrpc-silverlight/的代码 我创建了新的 Silverlight 应用程序,我已将来自该链接的代码附加到该应用程序。当我启动执行我的 SL 应用程序的网站(在 localhost 中,端口为 1139)时,会发生 SecurityException。
void ResponseResponse(IAsyncResult result) { XmlRpcHelperRequestState state = result.AsyncState as XmlRpcHelperRequestState; try { state.Response = (HttpWebResponse)state.Request.EndGetResponse(result); ... } catch (Exception e) { // comes here with SecurityException } finally { ... } }
我正在使用 VS2008 Professional、XP Professional、.net 3.5、Silverlight3。我很乐意提供所需的任何其他信息(或代码)。