diff options
author | Konstantin Triger <kostat@mono-cvs.ximian.com> | 2007-01-25 12:53:00 +0300 |
---|---|---|
committer | Konstantin Triger <kostat@mono-cvs.ximian.com> | 2007-01-25 12:53:00 +0300 |
commit | 7a2a2a92225f55a8610c38a5c6ea619c84204dfd (patch) | |
tree | 31348baa0e27614563a59f8677daf3b14f1a6a28 /data | |
parent | 30eb15be6d27dd6e15b73ec2f9ecb6e947113908 (diff) |
support test page using POST request
svn path=/trunk/mono/; revision=71657
Diffstat (limited to 'data')
-rw-r--r-- | data/net_1_1/DefaultWsdlHelpGenerator.aspx | 15 | ||||
-rw-r--r-- | data/net_2_0/DefaultWsdlHelpGenerator.aspx | 21 |
2 files changed, 33 insertions, 3 deletions
diff --git a/data/net_1_1/DefaultWsdlHelpGenerator.aspx b/data/net_1_1/DefaultWsdlHelpGenerator.aspx index c4ceb2d4099..038627e858f 100644 --- a/data/net_1_1/DefaultWsdlHelpGenerator.aspx +++ b/data/net_1_1/DefaultWsdlHelpGenerator.aspx @@ -24,6 +24,7 @@ <%@ Import Namespace="System.CodeDom.Compiler" %> <%@ Import Namespace="Microsoft.CSharp" %> <%@ Import Namespace="Microsoft.VisualBasic" %> +<%@ Import Namespace="System.Text" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <%@ Import Namespace="System.Security.Cryptography.X509Certificates" %> <%@ Assembly name="System.Web.Services" %> @@ -347,7 +348,19 @@ string GetTestResult () { string url = location + "/" + CurrentOperationName; Uri uri = new Uri (url); - HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url + "?" + qs); + WebRequest req; + if (CurrentOperationProtocols.IndexOf ("HttpGet") < 0) { + req = WebRequest.Create (url); + req.Method = "POST"; + if (qs != null && qs.Length > 0) { + byte [] postBuffer = Encoding.UTF8.GetBytes (qs); + req.ContentLength = postBuffer.Length; + using (Stream requestStream = req.GetRequestStream ()) + requestStream.Write (postBuffer, 0, postBuffer.Length); + } + } + else + req = WebRequest.Create (url + "?" + qs); if (url.StartsWith ("https:")) ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy (); HttpCookieCollection cookies = Request.Cookies; diff --git a/data/net_2_0/DefaultWsdlHelpGenerator.aspx b/data/net_2_0/DefaultWsdlHelpGenerator.aspx index 636f20d927f..0b02fb5de57 100644 --- a/data/net_2_0/DefaultWsdlHelpGenerator.aspx +++ b/data/net_2_0/DefaultWsdlHelpGenerator.aspx @@ -16,6 +16,7 @@ <%@ Import Namespace="System.Xml.Schema" %> <%@ Import Namespace="System.Web.Services" %> <%@ Import Namespace="System.Web.Services.Description" %> +<%@ Import Namespace="System.Web.Services.Configuration" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.Globalization" %> @@ -25,6 +26,7 @@ <%@ Import Namespace="System.CodeDom.Compiler" %> <%@ Import Namespace="Microsoft.CSharp" %> <%@ Import Namespace="Microsoft.VisualBasic" %> +<%@ Import Namespace="System.Text" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <%@ Import Namespace="System.Security.Cryptography.X509Certificates" %> <%@ Assembly name="System.Web.Services" %> @@ -123,7 +125,10 @@ void BuildOperationInfo () CurrentOperationProtocols += (string) prots[n]; } - CurrentOperationSupportsTest = prots.Contains ("HttpGet") || prots.Contains ("HttpPost"); + WebServiceProtocols testProtocols = WebServiceProtocols.HttpGet | WebServiceProtocols.HttpPost; + if (Context.Request.IsLocal) + testProtocols |= WebServiceProtocols.HttpPostLocalhost; + CurrentOperationSupportsTest = (WebServicesSection.Current.EnabledProtocols & testProtocols) != 0; // Operation format OperationBinding obin = FindOperation (binding, CurrentOperationName); @@ -354,7 +359,19 @@ string GetTestResult () { string url = location + "/" + CurrentOperationName; Uri uri = new Uri (url); - HttpWebRequest req = (HttpWebRequest) WebRequest.Create (url + "?" + qs); + WebRequest req; + if (CurrentOperationProtocols.IndexOf ("HttpGet") < 0) { + req = WebRequest.Create (url); + req.Method="POST"; + if (!String.IsNullOrEmpty (qs)) { + byte [] postBuffer = Encoding.UTF8.GetBytes (qs); + req.ContentLength = postBuffer.Length; + using (Stream requestStream = req.GetRequestStream()) + requestStream.Write (postBuffer, 0, postBuffer.Length); + } + } + else + req = WebRequest.Create (url + "?" + qs); if (url.StartsWith ("https:")) ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy (); HttpCookieCollection cookies = Request.Cookies; |