コード例 #1
0
        // This display is the Server end.
        public void SetDestination(int ListeningPort)
        {
            // We chain xml-rpc -> soap so that we can support both XML-RPC and SOAP
            IServerChannelSinkProvider xml_rpc = new XmlRpcServerFormatterSinkProvider(null, null);
            IServerChannelSinkProvider soap    = new SoapServerFormatterSinkProvider();

            xml_rpc.Next = soap;

            IDictionary props = new Hashtable();

            props["ref"]  = "http";
            props["port"] = ListeningPort;
            HttpChannel channel = new HttpChannel(props, null, xml_rpc);

            ChannelServices.RegisterChannel(channel, false);

            // Not sure how this works if we re-configure and register when OperatingMode changes
            // There might be other ways to do the same thing and allow for de-registration
            RemotingConfiguration.Configure(null, false);

            // Counterintuitive, but when set to FALSE it reports errors across XML-RPC. Keep it this way to simplify debugging.
            RemotingConfiguration.CustomErrorsEnabled(false);

            // Can't figure out how to register at "http://serverip:port/". Must use "http://serverip:port/DreamBeam"
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(XmlRpcServer),
                                                               "DreamBeam", WellKnownObjectMode.Singleton);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlRpcManagerServer"/> class
        /// and registers it at the specified port on local machine.
        /// </summary>
        /// <param name="port">The port.</param>
        public XmlRpcManagerServer(int port)
        {
            IServerChannelSinkProvider chain = new XmlRpcServerFormatterSinkProvider();
            IDictionary props = new Hashtable();

            props.Add("port", port);
#if BRUNET_NUNIT
            /*
             * anonymous channel. In tests we don't care about service names and
             * moreover, don't want system to complaint about serive name duplication
             * when it gets restarted frequently
             */
            props.Add("name", "");
#else
            props.Add("name", "xmlrpcmanagers"); //so that this channel won't collide with dht services
#endif
            _channel = new HttpChannel(props, null, chain);
            ChannelServices.RegisterChannel(_channel, false);

            _dumper = new Dumper(this);
            RemotingServices.Marshal(_dumper, "xmserver.rem");
        }