2008-04-16 Jb Evain <jbevain@novell.com>
[mono.git] / data / net_2_0 / DefaultWsdlHelpGenerator.aspx
index c4cee0dfc30249b92ee0ef45e6960a2c9c8d208c..1942be1da380471568d1ba098ea07e9a0b908164 100644 (file)
@@ -16,6 +16,8 @@
 <%@ 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.Web.Configuration" %>
 <%@ Import Namespace="System" %>
 <%@ Import Namespace="System.Net" %>
 <%@ Import Namespace="System.Globalization" %>
@@ -25,6 +27,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" %>
@@ -89,7 +92,9 @@ void Page_Load(object sender, EventArgs e)
        Page.DataBind();
        
        ProfileViolations = new BasicProfileViolationCollection ();
-       WebServicesInteroperability.CheckConformance (WsiProfiles.BasicProfile1_1, descriptions, ProfileViolations);
+       foreach (WsiProfilesElement claims in ((WebServicesSection) WebConfigurationManager.GetSection("system.web/webServices")).ConformanceWarnings)
+               if (claims.Name != WsiProfiles.None)
+                       WebServicesInteroperability.CheckConformance (claims.Name, descriptions, ProfileViolations);
 }
 
 void BuildOperationInfo ()
@@ -123,7 +128,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 +362,20 @@ 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)) {
+                       req.ContentType = "application/x-www-form-urlencoded";
+                       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;
@@ -1536,7 +1557,7 @@ public class HtmlSampleGenerator: SampleGenerator
 
 </script>
 
-<head>
+<head runat="server">
        <link rel="alternate" type="text/xml" href="<%=Request.FilePath%>?disco"/>
 
        <title><%=WebServiceName%> Web Service</title>
@@ -1623,9 +1644,9 @@ function clearForm ()
        <p class="label">Web Service Overview</p>
        <%=WebServiceDescription%>
        <br/><br/>
-       <% if (ProfileViolations.Count > 0) { %>
+       <% if (ProfileViolations != null && 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) {