public static string DumpResponse(WebResponse response) { Stream stream1 = response.GetResponseStream(); StringBuilder builder1 = new StringBuilder(); if (response is HttpWebResponse) { HttpWebResponse response1 = (HttpWebResponse)response; builder1.Append( string.Concat( new object[] { "ResponseCode: ", (int)response1.StatusCode, " (", response1.StatusDescription, ")\n" })); } else if (response is WSSWebResponse) { WSSWebResponse response2 = (WSSWebResponse)response; builder1.Append( string.Concat( new object[] { "ResponseCode: ", (int)response2.StatusCode, " (", response2.StatusDescription, ")\n" })); } foreach (string text1 in response.Headers.Keys) { builder1.Append(text1 + ":" + response.Headers[text1].ToString() + "\n"); } builder1.Append("\n"); builder1.Append(MessageTracer.ReadMessage(stream1, (int)response.ContentLength, response.ContentType)); return(builder1.ToString()); }
public static string DumpResponse(WebResponse response) { Stream responseStream = response.GetResponseStream(); var builder = new StringBuilder(); if (response is HttpWebResponse) { var response2 = (HttpWebResponse)response; builder.Append( string.Concat(new object[] { "ResponseCode: ", (int)response2.StatusCode, " (", response2.StatusDescription, ")\n" })); } else if (response is WSSWebResponse) { var response3 = (WSSWebResponse)response; builder.Append( string.Concat(new object[] { "ResponseCode: ", (int)response3.StatusCode, " (", response3.StatusDescription, ")\n" })); } foreach (string str in response.Headers.Keys) { builder.Append(str + ":" + response.Headers[str] + "\n"); } builder.Append("\n"); builder.Append(MessageTracer.ReadMessage(responseStream, (int)response.ContentLength, response.ContentType)); return(builder.ToString()); }
public override WebResponse GetResponse() { WebResponse response4; requestProperties.contentType = this.webRequest.ContentType; requestProperties.soapAction = this.webRequest.Headers["SOAPAction"]; requestProperties.url = this.webRequest.RequestUri.ToString(); if (this.webRequest.Method.ToUpper() == "POST") { requestProperties.Method = RequestProperties.HttpMethod.POST; Stream requestStream = this.webRequest.GetRequestStream(); requestStream.Write(this.stream.GetBuffer(), 0, (int)this.stream.Length); requestStream.Close(); this.stream.Position = 0L; requestProperties.requestPayLoad = MessageTracer.ReadMessage(this.stream, requestProperties.contentType); } else if (this.webRequest.Method.ToUpper() == "GET") { requestProperties.Method = RequestProperties.HttpMethod.GET; } try { if (ClientCertificates != null) { this.webRequest.ClientCertificates.Add(ClientCertificates[0]); } WSSWebResponse response2 = new WSSWebResponse(this.webRequest.GetResponse()); requestProperties.responsePayLoad = response2.DumpResponse(); response4 = response2; } catch (WebException exception) { if (exception.Response != null) { WSSWebResponse response = new WSSWebResponse(exception.Response); requestProperties.responsePayLoad = response.DumpResponse(); throw new WebException(exception.Message, exception, exception.Status, response); } requestProperties.responsePayLoad = exception.ToString(); throw; } catch (Exception exception2) { requestProperties.responsePayLoad = exception2.ToString(); throw; } return(response4); }
public override WebResponse GetResponse() { WebResponse response4; requestProperties.contentType = webRequest.ContentType; requestProperties.soapAction = webRequest.Headers["SOAPAction"]; requestProperties.url = webRequest.RequestUri.ToString(); if (webRequest.Method.ToUpper() == "POST") { requestProperties.Method = RequestProperties.HttpMethod.POST; Stream stream1 = webRequest.GetRequestStream(); stream1.Write(stream.GetBuffer(), 0, (int)stream.Length); stream1.Close(); stream.Position = 0; requestProperties.requestPayLoad = MessageTracer.ReadMessage(stream, requestProperties.contentType); } else if (webRequest.Method.ToUpper() == "GET") { requestProperties.Method = RequestProperties.HttpMethod.GET; } try { WebResponse response1 = webRequest.GetResponse(); WSSWebResponse response2 = new WSSWebResponse(response1); requestProperties.responsePayLoad = response2.DumpResponse(); response4 = response2; } catch (WebException exception1) { if (exception1.Response != null) { WSSWebResponse response3 = new WSSWebResponse(exception1.Response); requestProperties.responsePayLoad = response3.DumpResponse(); throw new WebException(exception1.Message, exception1, exception1.Status, response3); } requestProperties.responsePayLoad = exception1.ToString(); throw; } catch (Exception exception2) { requestProperties.responsePayLoad = exception2.ToString(); throw; } return(response4); }