public WebServiceReponse <string> XmlToJson(string xmlStr) { _log.Info(string.Format("XmlToJson: {0}", xmlStr)); WebServiceReponse <string> reponse = new WebServiceReponse <string>(); try { reponse.Result = _xmlToJsonService.XmlToJson(xmlStr); _log.Info(string.Format("Result: {0}", reponse.Result)); } catch (Exception ex) { reponse.AddMessage(ex.Message, MessageType.Error); _log.Error(ex); } return(reponse); }
public void TestMethod1() { //README //TO TEST START THE SOLUTION_3_WEB FIRST - IT WILL POINT TO A LOCALHOST (WILL OPEN BROWSER) //THEN DEBUG THE TESTMETHOD Solution_3_Web.Tests. //CHANGE THE VALUE OF THE XML FILE IN THE UNITTEST string stringfile = File.ReadAllText("XMLFile.xml"); string strNVPSandboxServer = string.Empty; strNVPSandboxServer = "https://localhost:44374/WebService.ashx"; string strNVP = stringfile; //Create web request and web response objects, make sure you using the correct server (sandbox/live) HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer); wrWebRequest.Method = "POST"; wrWebRequest.ContentType = "application/text"; var requestWriter = new StreamWriter(wrWebRequest.GetRequestStream()); requestWriter.Write(strNVP); requestWriter.Close(); // Get the response. HttpWebResponse hwrWebResponse = (HttpWebResponse)(wrWebRequest.GetResponse()); var responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream()); var responseData = responseReader.ReadToEnd(); WebServiceReponse objUsr = Deserialize <WebServiceReponse>(responseData); Console.WriteLine("Status= " + objUsr.Status + " Reason= " + objUsr.Reason); }
public WebServiceReponse <int> ComputeFibonacci(int number) { _log.Info(string.Format("ComputeFibonacci({0})", number)); WebServiceReponse <int> reponse = new WebServiceReponse <int>(); try { Thread.Sleep(2000); reponse.Result = _fibonacciService.ComputeFibonacci(number); _log.Info(string.Format("Result: {0}", reponse.Result)); } catch (Exception ex) { reponse.AddMessage(ex.Message, MessageType.Error); _log.Error(ex); } return(reponse); }