support test page using POST request
[mono.git] / data / net_2_0 / DefaultWsdlHelpGenerator.aspx
index b1eac1fa1ccb307e2d09ad9cd17e233d1c37463e..0b02fb5de572d5004ff0e4b0f15abad5f77dbdd6 100644 (file)
@@ -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,7 +26,9 @@
 <%@ 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" %>
 <%@ Page debug="true" %>
 
@@ -88,7 +91,7 @@ void Page_Load(object sender, EventArgs e)
        Page.DataBind();
        
        ProfileViolations = new BasicProfileViolationCollection ();
-       WebServicesInteroperability.CheckConformance (WsiClaims.BP10, descriptions, ProfileViolations);
+       WebServicesInteroperability.CheckConformance (WsiProfiles.BasicProfile1_1, descriptions, ProfileViolations);
 }
 
 void BuildOperationInfo ()
@@ -122,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);
@@ -313,6 +319,13 @@ bool HasFormResult
        get { return Request.QueryString ["ext"] == "testform"; }
 }
 
+class NoCheckCertificatePolicy : ICertificatePolicy {
+       public bool CheckValidationResult (ServicePoint a, X509Certificate b, WebRequest c, int d)
+       {
+               return true;
+       }
+}
+
 string GetTestResult ()
 { 
        if (!HasFormResult) return null;
@@ -346,7 +359,21 @@ string GetTestResult ()
        {
                string url = location + "/" + CurrentOperationName;
                Uri uri = new Uri (url);
-               WebRequest req = 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;
                int last = cookies.Count;
                if (last > 0) {
@@ -1615,7 +1642,7 @@ function clearForm ()
        <br/><br/>
        <% if (ProfileViolations.Count > 0) { %>
                <p class="label">Basic Profile Conformance</p>
-               This web service does not conform to WS-I Basic Profile v1.0
+               This web service does not conform to WS-I Basic Profile v1.1
        <%
                Response.Write ("<ul>");
                foreach (BasicProfileViolation vio in ProfileViolations) {