Пример #1
0
 private void XmlToJsonButton_Click(object sender, EventArgs e)
 {
     if (xmlValid)
     {
         Form waitForm = new WaitForm(this);
         waitForm.Show(this);
         string      xmlToSend      = xml?.Replace("<", "&lt;");
         string      body           = @"<XmlToJson xmlns=""http://chanhduong.org/""><xml>" + xmlToSend + "</xml></XmlToJson>";
         SoapService soapService    = new SoapService(ChanhDuongURL);
         string      textMessage    = "";
         string      captionMessage = "";
         try
         {
             soapService.SendRequest(body).Wait();
             XmlToJsonResponse result = (XmlToJsonResponse)SerializerSoapXml.Deserialize(typeof(XmlToJsonResponse), soapService.response);
             textMessage    = result.XmlToJsonResult;
             captionMessage = "Json";
         }
         catch (Exception ex)
         {
             textMessage    = ex.Message;
             captionMessage = "Error";
         }
         finally
         {
             waitForm.Close();
             MessageBox.Show(textMessage, captionMessage, MessageBoxButtons.OK);
         }
     }
     else
     {
         MessageBox.Show("Xml is blank!", "Info", MessageBoxButtons.OK);
     }
 }
Пример #2
0
 private void FibonacciButton_Click(object sender, EventArgs e)
 {
     if (fibonacciValid)
     {
         Form waitForm = new WaitForm(this);
         waitForm.Show(this);
         string      body           = @"<Fibonacci xmlns=""http://chanhduong.org/""><n>" + n + "</n></Fibonacci>";
         SoapService soapService    = new SoapService(ChanhDuongURL);
         string      textMessage    = "";
         string      captionMessage = "";
         try
         {
             soapService.SendRequest(body).Wait();
             FibonacciResponse result = (FibonacciResponse)SerializerSoapXml.Deserialize(typeof(FibonacciResponse), soapService.response);
             textMessage    = result.FibonacciResult;
             captionMessage = "Fibonacci of " + n;
         }
         catch (Exception ex)
         {
             textMessage    = ex.Message;
             captionMessage = "Error";
         }
         finally
         {
             waitForm.Close();
             MessageBox.Show(textMessage, captionMessage, MessageBoxButtons.OK);
         }
     }
     else
     {
         MessageBox.Show("N is blank!", "Info", MessageBoxButtons.OK);
     }
 }