예제 #1
0
 static void Main(string[] args)
 {
     try
     {
         IStateName            proxy  = XmlRpcProxyGen.Create <IStateName>();
         RequestResponseLogger logger = new RequestResponseLogger();
         logger.Directory = "C:/temp";
         proxy.AttachLogger(logger);
         Console.WriteLine("Synchronous call");
         string ret = proxy.GetStateName(45);
         Console.WriteLine("state #45 is {0}", ret);
         Console.WriteLine("Asynchronous call");
         IAsyncResult asr = proxy.BeginGetStateName(46);
         asr.AsyncWaitHandle.WaitOne();
         string aret = proxy.EndGetStateName(asr);
         Console.WriteLine("state #46 is {0}", aret);
     }
     catch (XmlRpcFaultException fex)
     {
         Console.WriteLine(fex.FaultString);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
예제 #2
0
        private void butGetStateNames_Click(object sender, System.EventArgs e)
        {
            labStateNames1.Text = labStateNames2.Text = labStateNames3.Text = "";
            IStateName betty
                = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            StateStructRequest request;
            string             retstr = "";

            Cursor = Cursors.WaitCursor;
            try
            {
                request.state1 = Convert.ToInt32(txtStateNumber1.Text);
                request.state2 = Convert.ToInt32(txtStateNumber2.Text);
                request.state3 = Convert.ToInt32(txtStateNumber3.Text);
                retstr         = betty.GetStateNames(request);
                String[] names = retstr.Split(',');
                if (names.Length > 2)
                {
                    labStateNames3.Text = names[2];
                }
                if (names.Length > 1)
                {
                    labStateNames2.Text = names[1];
                }
                if (names.Length > 0)
                {
                    labStateNames1.Text = names[0];
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            Cursor = Cursors.Default;
        }
예제 #3
0
 public void MakeCall()
 {
   IStateName proxy = XmlRpcProxyGen.Create < IStateName>();
   proxy.Url = "http://127.0.0.1:11000/";
   proxy.AllowAutoRedirect = false;
   string name = proxy.GetStateName(1);
 }
예제 #4
0
 public void MakeSystemListMethodsCall()
 {
   IStateName proxy = XmlRpcProxyGen.Create<IStateName>();
   proxy.Url = "http://127.0.0.1:11000/";
   string[] ret = proxy.SystemListMethods();
   Assert.AreEqual(1, ret.Length);
   Assert.AreEqual(ret[0], "examples.getStateName");
 }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            /* implement section */
            IStateName proxy   = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            string     message = proxy.getTest();

            MessageBox.Show(message);
        }
예제 #6
0
    static void Main(string[] args)
    {
        HttpChannel chnl;

#if DOTNETONLY
        bool bUseSoap = false;
        if (args.Length > 0 && args[0] == "SOAP")
        {
            bUseSoap = true;
        }
        if (bUseSoap)
        {
            chnl = new HttpChannel();
        }
        else
        {
            chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null);
        }
#else
        chnl = new HttpChannel();
#endif
        ChannelServices.RegisterChannel(chnl, false);

        IStateName svr = (IStateName)Activator.GetObject(
            typeof(IStateName), "http://localhost:5678/statename.rem");
        // probably different URL for IIS
        //   IStateName svr = (IStateName)Activator.GetObject(
        //   typeof(IStateName), "http://localhost/statename/statename.rem");
        while (true)
        {
            Console.Write("Enter statenumber: ");
            string s = Console.ReadLine();
            if (s == "")
            {
                break;
            }
            int stateNumber;
            try
            {
                stateNumber = Convert.ToInt32(s);
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid state number");
                continue;
            }
            try
            {
                string ret = svr.GetStateName(stateNumber);
                Console.WriteLine("State name is {0}", ret);
            }
            catch (XmlRpcFaultException fex)
            {
                Console.WriteLine("Fault response: {0} {1} {2}",
                                  fex.FaultCode, fex.FaultString, fex.Message);
            }
        }
    }
예제 #7
0
 public void GetHeader()
 {
   IStateName proxy = XmlRpcProxyGen.Create<IStateName>();
   proxy.Url = "http://127.0.0.1:11000/";
   string name = proxy.GetStateName(1);
   WebHeaderCollection headers = proxy.ResponseHeaders;
   string value = headers["BarHeader"];
   Assert.AreEqual("BarValue", value);
 }
        public void GZipCall()
        {
            encoding = "gzip";
            IStateName proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11002/";
            proxy.EnableCompression = true;
            string name = proxy.GetStateName(1);
        }
예제 #9
0
 public void GetCookie()
 {
   IStateName proxy = XmlRpcProxyGen.Create<IStateName>();
   proxy.Url = "http://127.0.0.1:11000/";
   string name = proxy.GetStateName(1);
   CookieCollection cookies = proxy.ResponseCookies;
   string value = cookies["FooCookie"].Value;
   Assert.AreEqual("FooValue", value);
 }
예제 #10
0
        public void MakeSynchronousCalls()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            string     ret1  = proxy.GetStateName(1);

            Assert.AreEqual("Alabama", ret1);
            string ret2 = proxy.GetStateName("1");

            Assert.AreEqual("Alabama", ret2);
        }
예제 #11
0
        public void MakeAsynchronousCallWait()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr2  = proxy.BeginGetStateName(1);

            asr2.AsyncWaitHandle.WaitOne();
            string ret2 = proxy.EndGetStateName(asr2);

            Assert.AreEqual("Alabama", ret2);
        }
예제 #12
0
        public void MakeAsynchronousCallCallbackNoState()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            _evt = new ManualResetEvent(false);
            IAsyncResult asr3 = proxy.BeginGetStateName(1, StateNameCallbackNoState);

            _evt.WaitOne();
            Assert.AreEqual(null, _excep, "Async call threw exception");
            Assert.AreEqual("Alabama", _ret);
        }
예제 #13
0
        public static CollabProject[] login(string name, string password)
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            CollabProject[] valor = proxy.timeControl(name, password);
            foreach (CollabProject i in valor)
            {
                Console.WriteLine(i.id);
                Console.WriteLine(i.nombre);
            }
            return(valor);
        }
예제 #14
0
        public void RequestEvent()
        {
            string     response;
            IStateName proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = "http://127.0.0.1:11000/";
            proxy.AllowAutoRedirect = false;
            proxy.RequestEvent     += (sender, args) =>
            {
                response = args.ProxyID.ToString();
            };
            string name = proxy.GetStateName(1);
        }
예제 #15
0
        public void MakeAsynchronousCallIsCompleted()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr1  = proxy.BeginGetStateName(1);

            while (asr1.IsCompleted == false)
            {
                System.Threading.Thread.Sleep(10);
            }
            string ret1 = proxy.EndGetStateName(asr1);

            Assert.AreEqual("Alabama", ret1);
        }
예제 #16
0
    static void Main(string[] args)
    {
        System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
        IStateName           proxy = XmlRpcProxyGen.Create <IStateName>();
        XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

        cp.Url = "https://127.0.0.1:5678/";
        cp.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate(@"C:\path\to\your\certificate\file\my.cer"));
        cp.KeepAlive = false;
        //cp.Expect100Continue = false;
        //cp.NonStandard = XmlRpcNonStandard.All;

        string stateName = ((IStateName)cp).GetStateName(13);
    }
예제 #17
0
        public static ILicence GetContactInfo(SessionRequest m)
        {
            IStateName proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url = ConstantsHelper.PROVIDER_URL_DEFAULT;
            m.Nonce   = GuidHelper.Nonce;
            var response = proxy.GetContactInfo(m.Encrypt <SessionRequest>(ConstantsHelper.KEY_PUBLIC_DEFAULT));

            if (string.IsNullOrWhiteSpace(response))
            {
                throw new System.Security.SecurityException("Could not retrieve secure contact details from service.");
            }
            return(CryptographyHelper.VerifyAndDeserialize <SessionRequest>(response, ConstantsHelper.KEY_PUBLIC_DEFAULT));
        }
예제 #18
0
        public static ISession RenewSession(SessionRequest m)
        {
            IStateName proxy = XmlRpcProxyGen.Create <IStateName>();

            proxy.Url     = ConstantsHelper.PROVIDER_URL_DEFAULT;
            m.Nonce       = GuidHelper.Nonce;
            m.MachineHash = Convert.ToBase64String(MachineHelper.GetMachineHash());
            var response = proxy.RenewSession(m.Encrypt <SessionRequest>(ConstantsHelper.KEY_PUBLIC_DEFAULT));

            if (string.IsNullOrWhiteSpace(response))
            {
                return(null);
            }
            return(CryptographyHelper.VerifyAndDeserialize <SessionRequest>(response, ConstantsHelper.KEY_PUBLIC_DEFAULT));
        }
        public override void VisitStateName(IStateName stateNameParam, IHighlightingConsumer consumer)
        {
            DocumentRange         colorConstantRange = stateNameParam.GetDocumentRange();
            ResolveResultWithInfo resolve            = stateNameParam.StateNameReference.Resolve();

            if ((resolve == null) || ((resolve.Result.DeclaredElement == null) && (resolve.Result.Candidates.Count == 0)))
            {
                AddHighLighting(colorConstantRange, stateNameParam, consumer, new LexUnresolvedStateHighlighting(stateNameParam));
            }
            else
            {
                AddHighLighting(colorConstantRange, stateNameParam, consumer, new LexStateHighlighting(stateNameParam));
            }
            base.VisitStateName(stateNameParam, consumer);
        }
예제 #20
0
        void StateNameCallbackNoState(IAsyncResult asr)
        {
            XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)asr;
            IStateName        proxy        = (IStateName)clientResult.ClientProtocol;

            try
            {
                _ret = proxy.EndGetStateName(asr);
            }
            catch (Exception ex)
            {
                _excep = ex;
            }
            _evt.Set();
        }
예제 #21
0
        public void SynchronousFaultException()
        {
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            try
            {
                string ret1 = proxy.GetStateName(100);
                Assert.Fail("exception not thrown on sync call");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(1, fex.FaultCode);
                Assert.AreEqual("Invalid state number", fex.FaultString);
            }
        }
예제 #22
0
        void StateNameCallback(IAsyncResult asr)
        {
            XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)asr;
            IStateName        proxy        = (IStateName)clientResult.ClientProtocol;
            CBInfo            info         = (CBInfo)asr.AsyncState;

            try
            {
                info._ret = proxy.EndGetStateName(asr);
            }
            catch (Exception ex)
            {
                info._excep = ex;
            }
            info._evt.Set();
        }
예제 #23
0
        private void butGetStateName_Click(object sender, System.EventArgs e)
        {
            labStateName.Text = "";
            IStateName betty = XmlRpcProxyGen.Create <IStateName>();

            Cursor = Cursors.WaitCursor;
            try
            {
                int num = Convert.ToInt32(txtStateNumber.Text);
                labStateName.Text = betty.GetStateName(num);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            Cursor = Cursors.Default;
        }
        public bool Send()
        {
            string server = "192.168.102.188";
            string port   = "8888";
            string user   = "******";
            string pwd    = "Test123";


            Stopwatch sw = new Stopwatch();

            sw.Start();
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            sw.Stop();
            Console.WriteLine($"连接耗时:{sw.Elapsed}");

            var paht = $@"\\192.168.102.188\share\testx\AI201701010";

            if (!Directory.Exists(paht))
            {
                Directory.CreateDirectory(paht);
            }


            sw.Reset();
            sw.Start();
            Parallel.For(1, 17, i =>
            {
                Console.WriteLine(i);
                File.Copy($@"C:\Users\sh179\Desktop\testx\{i}.jpg", $@"\\192.168.102.188\share\testx\AI201701010\{i}.jpg", true);
                string message = proxy.getTest($"{i}.jpg");
                Console.WriteLine($"{i} return:{message}");
            });



            //string message = proxy.getTest("123.jpg");
            //Console.WriteLine($"return:{message}");


            sw.Stop();
            Console.WriteLine($"发送耗时:{sw.Elapsed}");


            return(false);
        }
예제 #25
0
        public void AsynchronousFaultException()
        {
            IStateName   proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
            IAsyncResult asr   = proxy.BeginGetStateName(100);

            asr.AsyncWaitHandle.WaitOne();
            try
            {
                string ret = proxy.EndGetStateName(asr);
                Assert.Fail("exception not thrown on async call");
            }
            catch (XmlRpcFaultException fex)
            {
                Assert.AreEqual(1, fex.FaultCode);
                Assert.AreEqual("Invalid state number", fex.FaultString);
            }
        }
예제 #26
0
        static void GetStateNameCallback(IAsyncResult result)
        {
            XmlRpcAsyncResult clientResult = (XmlRpcAsyncResult)result;
            IStateName        betty        = (IStateName)clientResult.ClientProtocol;
            BettyAsyncState   asyncState   = (BettyAsyncState)result.AsyncState;

            try
            {
                string s = betty.EndGetStateName(result);
                asyncState.theForm.Invoke(new AppendSuccessDelegate(
                                              asyncState.theForm.AppendSuccess), asyncState.stateNumber, s);
            }
            catch (Exception ex)
            {
                asyncState.theForm.Invoke(new AppendExceptionDelegate(
                                              asyncState.theForm.AppendException), ex);
            }
        }
예제 #27
0
    public static void Main()
    {
        IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

        proyecto[] valor = proxy.timeControl("admin", "collab_proyectos");
        if (valor.Length == 0)
        {
            Console.WriteLine("Respuesta vacia");
        }
        else
        {
            foreach (proyecto i in valor)
            {
                Console.WriteLine(i.id);
                Console.WriteLine(i.nombre);
            }
        }
    }
예제 #28
0
        public void Logging()
        {
            string     expectedRequest     = @"<?xml version=""1.0""?>
<methodCall>
  <methodName>examples.getStateName</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
  </params>
</methodCall>";
            string     expectedResponseXml = @"<?xml version=""1.0""?>
<methodResponse>
  <params>
    <param>
      <value>
        <string>Alabama</string>
      </value>
    </param>
  </params>
</methodResponse>";
            string     requestXml          = null;
            string     responseXml         = null;
            IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));

            proxy.RequestEvent += delegate(object sender, XmlRpcRequestEventArgs args)
            {
                requestXml = GetXml(args.RequestStream);
            };
            proxy.ResponseEvent += delegate(object sender, XmlRpcResponseEventArgs args)
            {
                responseXml = GetXml(args.ResponseStream);
            };
            string ret = proxy.GetStateName(1);

            Assert.AreEqual("Alabama", ret);
            Assert.AreEqual(expectedRequest, requestXml);
            Assert.AreEqual(expectedResponseXml, responseXml);
        }
예제 #29
0
        private void butGetName_Click(object sender, System.EventArgs e)
        {
            IStateName betty = XmlRpcProxyGen.Create <IStateName>();

            betty.Timeout = 10000;
            try
            {
                AsyncCallback   acb        = new AsyncCallback(GetStateNameCallback);
                int             num        = Convert.ToInt32(txtStateNumber.Text);
                BettyAsyncState asyncState = new BettyAsyncState(num, this);
                IAsyncResult    asr        = betty.BeginGetStateName(num, acb, asyncState);
                if (asr.CompletedSynchronously)
                {
                    string ret = betty.EndGetStateName(asr);
                    AppendSuccess(num, ret);
                }
            }
            catch (Exception ex)
            {
                AppendException(ex);
            }
        }
예제 #30
0
    static void Main(string[] args)
    {
        HttpListenerController _controller = null;

        string[] prefixes = new string[] {
            "http://localhost:8081/",
            "http://127.0.0.1:8081/"
        };
        string curDir = System.Environment.CurrentDirectory;
        string vdir   = "/";
        string pdir   = curDir;;

        _controller = new HttpListenerController(prefixes, vdir, pdir);
        _controller.Start();


        IStateName proxy = XmlRpcProxyGen.Create <IStateName>();

        (proxy as XmlRpcClientProtocol).Url = "http://127.0.0.1:8081/statename.rem";
        string name = proxy.GetStateName(1);

        _controller.Stop();
    }