private void XmlToJsonButton_Click(object sender, EventArgs e) { if (xmlValid) { Form waitForm = new WaitForm(this); waitForm.Show(this); string xmlToSend = xml?.Replace("<", "<"); 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); } }
/// <summary> /// This method calls the client XmlToJson asynchronously /// </summary> /// <param name="xString"></param> /// <returns></returns> public async static Task <string> XmlToJsonConsoleClientAsync(string xString) { XmlToJsonResponse returnedString = await service.XmlToJsonAsync(xString, timeout : 2000); return(returnedString.Body.XmlToJsonResult); }