예제 #1
0
        public static Test GetSOAPResponse(string endpoint, string xml, User user, Models.Headers header)
        {
            var soapClient = new SoapClientController();
            var request    = new SOAPApi.SoapRequest()
            {
                EndPoint = endpoint,
                XmlData  = xml
            };
            var soapResponse = soapClient.Execute(request);
            var soapResult   = SOAPApi.Utils.PrettyXml(soapResponse.Item2);

            var result = new Test
            {
                Request        = request.XmlData,
                Response       = soapResult,
                ProcessingTime = soapResponse.Item1,
                UserId         = user.Id,
                Uri            = request.EndPoint,
                ServiceName    = user.ServiceName
            };

            return(result);
        }
예제 #2
0
        public Tuple <TimeSpan?, string> Execute(SoapRequest request)
        {
            string         soapResult;
            HttpWebRequest httpRequest     = Utils.CreateWebRequest(request.EndPoint, request.Header);
            XmlDocument    soapEnvelopeXml = new XmlDocument();

            soapEnvelopeXml = Utils.CreateSoapEnvelope(request.XmlData);

            using (Stream stream = httpRequest.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }

            Stopwatch sw = new Stopwatch();

            sw.Start();
            try
            {
                using (WebResponse response = httpRequest.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        soapResult = rd.ReadToEnd();
                        //  Console.WriteLine(soapResult);
                        //return soapResult;
                    }
                }
                sw.Stop();
                var xml = HttpUtility.HtmlDecode(soapResult);
                return(new Tuple <TimeSpan?, string>(sw.Elapsed, xml));
            }
            catch (Exception e)
            {
                return(new Tuple <TimeSpan?, string>(null, e.Message));
            }
        }