[xbuild] Only execute PCL target "ImplicitlyExpandTargetFramework" when corresponding...
[mono-project.git] / data / net_1_1 / DefaultWsdlHelpGenerator.aspx
blob923655937f14ddf5f6b04f9feb2fca18fb736a80
1 <%--
2 //
3 // DefaultWsdlHelpGenerator.aspx: 
4 //
5 // Author:
6 //   Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // (C) 2003 Ximian, Inc.  http://www.ximian.com
9 //
10 --%>
12 <%@ Import Namespace="System.Collections" %>
13 <%@ Import Namespace="System.IO" %>
14 <%@ Import Namespace="System.Xml.Serialization" %>
15 <%@ Import Namespace="System.Xml" %>
16 <%@ Import Namespace="System.Xml.Schema" %>
17 <%@ Import Namespace="System.Web.Services.Description" %>
18 <%@ Import Namespace="System" %>
19 <%@ Import Namespace="System.Net" %>
20 <%@ Import Namespace="System.Globalization" %>
21 <%@ Import Namespace="System.Resources" %>
22 <%@ Import Namespace="System.Diagnostics" %>
23 <%@ Import Namespace="System.CodeDom" %>
24 <%@ Import Namespace="System.CodeDom.Compiler" %>
25 <%@ Import Namespace="Microsoft.CSharp" %>
26 <%@ Import Namespace="Microsoft.VisualBasic" %>
27 <%@ Import Namespace="System.Text" %>
28 <%@ Import Namespace="System.Text.RegularExpressions" %>
29 <%@ Import Namespace="System.Security.Cryptography.X509Certificates" %>
30 <%@ Assembly name="System.Web.Services" %>
31 <%@ Page debug="true" %>
33 <html>
34 <script language="C#" runat="server">
36 ServiceDescriptionCollection descriptions;
37 XmlSchemas schemas;
39 string WebServiceName;
40 string WebServiceDescription;
41 string PageName;
43 string DefaultBinding;
44 ArrayList ServiceProtocols;
46 string CurrentOperationName;
47 string CurrentOperationBinding;
48 string OperationDocumentation;
49 string CurrentOperationFormat;
50 bool CurrentOperationSupportsTest;
51 ArrayList InParams;
52 ArrayList OutParams;
53 string CurrentOperationProtocols;
54 int CodeTextColumns = 95;
56 void Page_Load(object sender, EventArgs e)
58         descriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];
59         schemas = (XmlSchemas) Context.Items["schemas"];
61         ServiceDescription desc = descriptions [0];
62         if (schemas.Count == 0) schemas = desc.Types.Schemas;
63         
64         Service service = desc.Services[0];
65         WebServiceName = service.Name;
66         if (desc.Bindings.Count == 0)
67                 return;
68         
69         DefaultBinding = desc.Bindings[0].Name;
70         WebServiceDescription = service.Documentation;
71         ServiceProtocols = FindServiceProtocols (null);
72         
73         CurrentOperationName = Request.QueryString["op"];
74         CurrentOperationBinding = Request.QueryString["bnd"];
75         if (CurrentOperationName != null) BuildOperationInfo ();
77         PageName = HttpUtility.UrlEncode (Path.GetFileName(Request.Path), Encoding.UTF8);
79         ArrayList list = new ArrayList ();
80         foreach (ServiceDescription sd in descriptions) {
81                 foreach (Binding bin in sd.Bindings)
82                         if (bin.Extensions.Find (typeof(SoapBinding)) != null) list.Add (bin);
83         }
85         BindingsRepeater.DataSource = list;
86         Page.DataBind();
89 void BuildOperationInfo ()
91         InParams = new ArrayList ();
92         OutParams = new ArrayList ();
93         
94         Port port = FindPort (CurrentOperationBinding, null);
95         Binding binding = descriptions.GetBinding (port.Binding);
96         
97         PortType portType = descriptions.GetPortType (binding.Type);
98         Operation oper = FindOperation (portType, CurrentOperationName);
99         
100         OperationDocumentation = oper.Documentation;
101         if (OperationDocumentation == null || OperationDocumentation == "")
102                 OperationDocumentation = "No additional remarks";
103         
104         foreach (OperationMessage opm in oper.Messages)
105         {
106                 if (opm is OperationInput)
107                         BuildParameters (InParams, opm);
108                 else if (opm is OperationOutput)
109                         BuildParameters (OutParams, opm);
110         }
111         
112         // Protocols supported by the operation
113         CurrentOperationProtocols = "";
114         ArrayList prots = FindServiceProtocols (CurrentOperationName);
115         for (int n=0; n<prots.Count; n++) {
116                 if (n != 0) CurrentOperationProtocols += ", ";
117                 CurrentOperationProtocols += (string) prots[n];
118         }
119         
120         CurrentOperationSupportsTest = prots.Contains ("HttpGet") || prots.Contains ("HttpPost");
122         // Operation format
123         OperationBinding obin = FindOperation (binding, CurrentOperationName);
124         if (obin != null)
125                 CurrentOperationFormat = GetOperationFormat (obin);
127         InputParamsRepeater.DataSource = InParams;
128         InputFormParamsRepeater.DataSource = InParams;
129         OutputParamsRepeater.DataSource = OutParams;
132 void BuildParameters (ArrayList list, OperationMessage opm)
134         Message msg = descriptions.GetMessage (opm.Message);
135         if (msg.Parts.Count > 0 && msg.Parts[0].Name == "parameters")
136         {
137                 MessagePart part = msg.Parts[0];
138                 XmlSchemaComplexType ctype;
139                 if (part.Element == XmlQualifiedName.Empty)
140                 {
141                         ctype = (XmlSchemaComplexType) schemas.Find (part.Type, typeof(XmlSchemaComplexType));
142                 }
143                 else
144                 {
145                         XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
146                         ctype = (XmlSchemaComplexType) elem.SchemaType;
147                 }
148                 XmlSchemaSequence seq = ctype.Particle as XmlSchemaSequence;
149                 if (seq == null) return;
150                 
151                 foreach (XmlSchemaObject ob in seq.Items)
152                 {
153                         Parameter p = new Parameter();
154                         p.Description = "No additional remarks";
155                         
156                         if (ob is XmlSchemaElement)
157                         {
158                                 XmlSchemaElement selem = GetRefElement ((XmlSchemaElement)ob);
159                                 p.Name = selem.Name;
160                                 p.Type = selem.SchemaTypeName.Name;
161                         }
162                         else
163                         {
164                                 p.Name = "Unknown";
165                                 p.Type = "Unknown";
166                         }
167                         list.Add (p);
168                 }
169         }
170         else
171         {
172                 foreach (MessagePart part in msg.Parts)
173                 {
174                         Parameter p = new Parameter ();
175                         p.Description = "No additional remarks";
176                         p.Name = part.Name;
177                         if (part.Element == XmlQualifiedName.Empty)
178                                 p.Type = part.Type.Name;
179                         else
180                         {
181                                 XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
182                                 p.Type = elem.SchemaTypeName.Name;
183                         }
184                         list.Add (p);
185                 }
186         }
189 string GetOperationFormat (OperationBinding obin)
191         string format = "";
192         SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
193         if (sob != null) {
194                 format = sob.Style.ToString ();
195                 SoapBodyBinding sbb = obin.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
196                 if (sbb != null)
197                         format += " / " + sbb.Use;
198         }
199         return format;
202 XmlSchemaElement GetRefElement (XmlSchemaElement elem)
204         if (!elem.RefName.IsEmpty)
205                 return (XmlSchemaElement) schemas.Find (elem.RefName, typeof(XmlSchemaElement));
206         else
207                 return elem;
210 ArrayList FindServiceProtocols(string operName)
212         ArrayList table = new ArrayList ();
213         Service service = descriptions[0].Services[0];
214         foreach (Port port in service.Ports)
215         {
216                 string prot = null;
217                 Binding bin = descriptions.GetBinding (port.Binding);
218                 if (bin.Extensions.Find (typeof(SoapBinding)) != null)
219                         prot = "Soap";
220                 else 
221                 {
222                         HttpBinding hb = (HttpBinding) bin.Extensions.Find (typeof(HttpBinding));
223                         if (hb != null && hb.Verb == "POST") prot = "HttpPost";
224                         else if (hb != null && hb.Verb == "GET") prot = "HttpGet";
225                 }
226                 
227                 if (prot != null && operName != null)
228                 {
229                         if (FindOperation (bin, operName) == null)
230                                 prot = null;
231                 }
233                 if (prot != null && !table.Contains (prot))
234                         table.Add (prot);
235         }
236         return table;
239 Port FindPort (string portName, string protocol)
241         Service service = descriptions[0].Services[0];
242         foreach (Port port in service.Ports)
243         {
244                 if (portName == null)
245                 {
246                         Binding binding = descriptions.GetBinding (port.Binding);
247                         if (GetProtocol (binding) == protocol) return port;
248                 }
249                 else if (port.Name == portName)
250                         return port;
251         }
252         return null;
255 string GetProtocol (Binding binding)
257         if (binding.Extensions.Find (typeof(SoapBinding)) != null) return "Soap";
258         HttpBinding hb = (HttpBinding) binding.Extensions.Find (typeof(HttpBinding));
259         if (hb == null) return "";
260         if (hb.Verb == "POST") return "HttpPost";
261         if (hb.Verb == "GET") return "HttpGet";
262         return "";
266 Operation FindOperation (PortType portType, string name)
268         foreach (Operation oper in portType.Operations) {
269                 if (oper.Messages.Input.Name != null) {
270                         if (oper.Messages.Input.Name == name) return oper;
271                 }
272                 else
273                         if (oper.Name == name) return oper;
274         }
275                 
276         return null;
279 OperationBinding FindOperation (Binding binding, string name)
281         foreach (OperationBinding oper in binding.Operations) {
282                 if (oper.Input.Name != null) {
283                         if (oper.Input.Name == name) return oper;
284                 }
285                 else 
286                         if (oper.Name == name) return oper;
287         }
288                 
289         return null;
292 string FormatBindingName (string name)
294         if (name == DefaultBinding) return "Methods";
295         else return "Methods for binding<br>" + name;
298 string GetOpName (object op)
300         OperationBinding ob = op as OperationBinding;
301         if (ob == null) return "";
302         if (ob.Input.Name != null) return ob.Input.Name;
303         else return ob.Name;
306 bool HasFormResult
308         get { return Request.QueryString ["ext"] == "testform"; }
311 class NoCheckCertificatePolicy : ICertificatePolicy {
312         public bool CheckValidationResult (ServicePoint a, X509Certificate b, WebRequest c, int d)
313         {
314                 return true;
315         }
318 string GetTestResult ()
320         if (!HasFormResult) return null;
321         
322         bool fill = false;
323         string qs = "";
324         for (int n=0; n<Request.QueryString.Count; n++)
325         {
326                 if (fill) {
327                         if (qs != "") qs += "&";
328                         qs += Request.QueryString.GetKey(n) + "=" + Server.UrlEncode (Request.QueryString [n]);
329                 }
330                 if (Request.QueryString.GetKey(n) == "ext") fill = true;
331         }
332                 
333         string location = null;
334         ServiceDescription desc = descriptions [0];
335         Service service = desc.Services[0];
336         foreach (Port port in service.Ports)
337                 if (port.Name == CurrentOperationBinding)
338                 {
339                         SoapAddressBinding sbi = (SoapAddressBinding) port.Extensions.Find (typeof(SoapAddressBinding));
340                         if (sbi != null)
341                                 location = sbi.Location;
342                 }
344         if (location == null) 
345                 return "Could not locate web service";
346         
347         try
348         {
349                 string url = location + "/" + CurrentOperationName;
350                 Uri uri = new Uri (url);
351                 WebRequest req;
352                 if (CurrentOperationProtocols.IndexOf ("HttpGet") < 0) {
353                         req = WebRequest.Create (url);
354                         req.Method = "POST";
355                         if (qs != null && qs.Length > 0) {
356                                 req.ContentType = "application/x-www-form-urlencoded";
357                                 byte [] postBuffer = Encoding.UTF8.GetBytes (qs);
358                                 req.ContentLength = postBuffer.Length;
359                                 using (Stream requestStream = req.GetRequestStream ())
360                                         requestStream.Write (postBuffer, 0, postBuffer.Length);
361                         }
362                 }
363                 else
364                         req = WebRequest.Create (url + "?" + qs);
365                 if (url.StartsWith ("https:"))
366                         ServicePointManager.CertificatePolicy = new NoCheckCertificatePolicy ();
367                 HttpCookieCollection cookies = Request.Cookies;
368                 int last = cookies.Count;
369                 if (last > 0) {
370                         CookieContainer container = new CookieContainer ();
371                         for (int i = 0; i < last; i++) {
372                                 HttpCookie hcookie = cookies [i];
373                                 Cookie cookie = new Cookie (hcookie.Name, hcookie.Value, hcookie.Path, hcookie.Domain);
374                                 container.Add (uri, cookie);
375                         }
376                         ((HttpWebRequest) req).CookieContainer = container;
377                 }
378                 WebResponse resp = req.GetResponse();
379                 StreamReader sr = new StreamReader (resp.GetResponseStream());
380                 string s = sr.ReadToEnd ();
381                 sr.Close ();
382                 return "<div class='code-xml'>" + ColorizeXml(WrapText(s,CodeTextColumns)) + "</div>";
383         }
384         catch (Exception ex)
385         { 
386                 string res = "<b style='color:red'>" + ex.Message + "</b>";
387                 WebException wex = ex as WebException;
388                 if (wex != null)
389                 {
390                         WebResponse resp = wex.Response;
391                         if (resp != null) {
392                                 StreamReader sr = new StreamReader (resp.GetResponseStream());
393                                 string s = sr.ReadToEnd ();
394                                 sr.Close ();
395                                 res += "<div class='code-xml'>" + ColorizeXml(WrapText(s,CodeTextColumns)) + "</div>";
396                         }
397                 }
398                 return res;
399         }
402 string GenerateOperationMessages (string protocol, bool generateInput)
404         if (!IsOperationSupported (protocol)) return "";
405         
406         Port port;
407         if (protocol != "Soap") port = FindPort (null, protocol);
408         else port = FindPort (CurrentOperationBinding, null);
409         
410         Binding binding = descriptions.GetBinding (port.Binding);
411         OperationBinding obin = FindOperation (binding, CurrentOperationName);
412         PortType portType = descriptions.GetPortType (binding.Type);
413         Operation oper = FindOperation (portType, CurrentOperationName);
414         
415         HtmlSampleGenerator sg = new HtmlSampleGenerator (descriptions, schemas);
416         string txt = sg.GenerateMessage (port, obin, oper, protocol, generateInput);
417         if (protocol == "Soap") txt = WrapText (txt,CodeTextColumns);
418         txt = ColorizeXml (txt);
419         txt = txt.Replace ("@placeholder!","<span class='literal-placeholder'>");
420         txt = txt.Replace ("!placeholder@","</span>");
421         return txt;
424 bool IsOperationSupported (string protocol)
426         if (CurrentPage != "op" || CurrentTab != "msg") return false;
427         if (protocol == "Soap") return true;
429         Port port = FindPort (null, protocol);
430         if (port == null) return false;
431         Binding binding = descriptions.GetBinding (port.Binding);
432         if (binding == null) return false;
433         return FindOperation (binding, CurrentOperationName) != null;
437 // Proxy code generation
440 string GetProxyCode ()
442         CodeNamespace codeNamespace = new CodeNamespace();
443         CodeCompileUnit codeUnit = new CodeCompileUnit();
444         
445         codeUnit.Namespaces.Add (codeNamespace);
447         ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
448         
449         foreach (ServiceDescription sd in descriptions)
450                 importer.AddServiceDescription(sd, null, null);
452         foreach (XmlSchema sc in schemas)
453                 importer.Schemas.Add (sc);
455         importer.Import(codeNamespace, codeUnit);
457         string langId = Request.QueryString ["lang"];
458         if (langId == null || langId == "") langId = "cs";
459         CodeDomProvider provider = GetProvider (langId);
460         ICodeGenerator generator = provider.CreateGenerator();
461         CodeGeneratorOptions options = new CodeGeneratorOptions();
462         
463         StringWriter sw = new StringWriter ();
464         generator.GenerateCodeFromCompileUnit(codeUnit, sw, options);
466         return Colorize (WrapText (sw.ToString (), CodeTextColumns), langId);
469 public string CurrentLanguage
471         get {
472                 string langId = Request.QueryString ["lang"];
473                 if (langId == null || langId == "") langId = "cs";
474                 return langId;
475         }
478 public string CurrentProxytName
480         get {
481                 string lan = CurrentLanguage == "cs" ? "C#" : "Visual Basic";
482                 return lan + " Client Proxy";
483         }
486 private CodeDomProvider GetProvider(string langId)
488         switch (langId.ToUpper())
489         {
490                 case "CS": return new CSharpCodeProvider();
491                 case "VB": return new VBCodeProvider();
492                 default: return null;
493         }
497 // Document generation
500 string GenerateDocument ()
502         StringWriter sw = new StringWriter ();
503         
504         if (CurrentDocType == "wsdl")
505                 descriptions [CurrentDocInd].Write (sw);
506         else if (CurrentDocType == "schema")
507                 schemas [CurrentDocInd].Write (sw);
508                 
509         return Colorize (WrapText (sw.ToString (), CodeTextColumns), "xml");
512 public string CurrentDocType
514         get { return Request.QueryString ["doctype"] != null ? Request.QueryString ["doctype"] : "wsdl"; }
517 public int CurrentDocInd
519         get { return Request.QueryString ["docind"] != null ? int.Parse (Request.QueryString ["docind"]) : 0; }
522 public string CurrentDocumentName
524         get {
525                 if (CurrentDocType == "wsdl")
526                         return "WSDL document for namespace \"" + descriptions [CurrentDocInd].TargetNamespace + "\"";
527                 else
528                         return "Xml Schema for namespace \"" + schemas [CurrentDocInd].TargetNamespace + "\"";
529         }
533 // Pages and tabs
536 bool firstTab = true;
537 ArrayList disabledTabs = new ArrayList ();
539 string CurrentTab
541         get { return Request.QueryString["tab"] != null ? Request.QueryString["tab"] : "main" ; }
544 string CurrentPage
546         get { return Request.QueryString["page"] != null ? Request.QueryString["page"] : "main" ; }
549 void WriteTabs ()
551         if (CurrentOperationName != null)
552         {
553                 WriteTab ("main","Overview");
554                 WriteTab ("test","Test Form");
555                 WriteTab ("msg","Message Layout");
556         }
559 void WriteTab (string id, string label)
561         if (!firstTab) Response.Write("&nbsp;|&nbsp;");
562         firstTab = false;
563         
564         string cname = CurrentTab == id ? "tabLabelOn" : "tabLabelOff";
565         Response.Write ("<a href='" + PageName + "?" + GetPageContext(null) + GetDataContext() + "tab=" + id + "' style='text-decoration:none'>");
566         Response.Write ("<span class='" + cname + "'>" + label + "</span>");
567         Response.Write ("</a>");
570 string GetTabContext (string pag, string tab)
572         if (tab == null) tab = CurrentTab;
573         if (pag == null) pag = CurrentPage;
574         if (pag != CurrentPage) tab = "main";
575         return "page=" + pag + "&tab=" + tab + "&"; 
578 string GetPageContext (string pag)
580         if (pag == null) pag = CurrentPage;
581         return "page=" + pag + "&"; 
584 class Tab
586         public string Id;
587         public string Label;
591 // Syntax coloring
594 static string keywords_cs =
595         "(\\babstract\\b|\\bevent\\b|\\bnew\\b|\\bstruct\\b|\\bas\\b|\\bexplicit\\b|\\bnull\\b|\\bswitch\\b|\\bbase\\b|\\bextern\\b|" +
596         "\\bobject\\b|\\bthis\\b|\\bbool\\b|\\bfalse\\b|\\boperator\\b|\\bthrow\\b|\\bbreak\\b|\\bfinally\\b|\\bout\\b|\\btrue\\b|" +
597         "\\bbyte\\b|\\bfixed\\b|\\boverride\\b|\\btry\\b|\\bcase\\b|\\bfloat\\b|\\bparams\\b|\\btypeof\\b|\\bcatch\\b|\\bfor\\b|" +
598         "\\bprivate\\b|\\buint\\b|\\bchar\\b|\\bforeach\\b|\\bprotected\\b|\\bulong\\b|\\bchecked\\b|\\bgoto\\b|\\bpublic\\b|" +
599         "\\bunchecked\\b|\\bclass\\b|\\bif\\b|\\breadonly\\b|\\bunsafe\\b|\\bconst\\b|\\bimplicit\\b|\\bref\\b|\\bushort\\b|" +
600         "\\bcontinue\\b|\\bin\\b|\\breturn\\b|\\busing\\b|\\bdecimal\\b|\\bint\\b|\\bsbyte\\b|\\bvirtual\\b|\\bdefault\\b|" +
601         "\\binterface\\b|\\bsealed\\b|\\bvolatile\\b|\\bdelegate\\b|\\binternal\\b|\\bshort\\b|\\bvoid\\b|\\bdo\\b|\\bis\\b|" +
602         "\\bsizeof\\b|\\bwhile\\b|\\bdouble\\b|\\block\\b|\\bstackalloc\\b|\\belse\\b|\\blong\\b|\\bstatic\\b|\\benum\\b|" +
603         "\\bnamespace\\b|\\bstring\\b)";
605 static string keywords_vb =
606         "(\\bAddHandler\\b|\\bAddressOf\\b|\\bAlias\\b|\\bAnd\\b|\\bAndAlso\\b|\\bAnsi\\b|\\bAs\\b|\\bAssembly\\b|" +
607         "\\bAuto\\b|\\bBoolean\\b|\\bByRef\\b|\\bByte\\b|\\bByVal\\b|\\bCall\\b|\\bCase\\b|\\bCatch\\b|" +
608         "\\bCBool\\b|\\bCByte\\b|\\bCChar\\b|\\bCDate\\b|\\bCDec\\b|\\bCDbl\\b|\\bChar\\b|\\bCInt\\b|" +
609         "\\bClass\\b|\\bCLng\\b|\\bCObj\\b|\\bConst\\b|\\bCShort\\b|\\bCSng\\b|\\bCStr\\b|\\bCType\\b|" +
610         "\\bDate\\b|\\bDecimal\\b|\\bDeclare\\b|\\bDefault\\b|\\bDelegate\\b|\\bDim\\b|\\bDirectCast\\b|\\bDo\\b|" +
611         "\\bDouble\\b|\\bEach\\b|\\bElse\\b|\\bElseIf\\b|\\bEnd\\b|\\bEnum\\b|\\bErase\\b|\\bError\\b|" +
612         "\\bEvent\\b|\\bExit\\b|\\bFalse\\b|\\bFinally\\b|\\bFor\\b|\\bFriend\\b|\\bFunction\\b|\\bGet\\b|" +
613         "\\bGetType\\b|\\bGoSub\\b|\\bGoTo\\b|\\bHandles\\b|\\bIf\\b|\\bImplements\\b|\\bImports\\b|\\bIn\\b|" +
614         "\\bInherits\\b|\\bInteger\\b|\\bInterface\\b|\\bIs\\b|\\bLet\\b|\\bLib\\b|\\bLike\\b|\\bLong\\b|" +
615         "\\bLoop\\b|\\bMe\\b|\\bMod\\b|\\bModule\\b|\\bMustInherit\\b|\\bMustOverride\\b|\\bMyBase\\b|\\bMyClass\\b|" +
616         "\\bNamespace\\b|\\bNew\\b|\\bNext\\b|\\bNot\\b|\\bNothing\\b|\\bNotInheritable\\b|\\bNotOverridable\\b|\\bObject\\b|" +
617         "\\bOn\\b|\\bOption\\b|\\bOptional\\b|\\bOr\\b|\\bOrElse\\b|\\bOverloads\\b|\\bOverridable\\b|\\bOverrides\\b|" +
618         "\\bParamArray\\b|\\bPreserve\\b|\\bPrivate\\b|\\bProperty\\b|\\bProtected\\b|\\bPublic\\b|\\bRaiseEvent\\b|\\bReadOnly\\b|" +
619         "\\bReDim\\b|\\bREM\\b|\\bRemoveHandler\\b|\\bResume\\b|\\bReturn\\b|\\bSelect\\b|\\bSet\\b|\\bShadows\\b|" +
620         "\\bShared\\b|\\bShort\\b|\\bSingle\\b|\\bStatic\\b|\\bStep\\b|\\bStop\\b|\\bString\\b|\\bStructure\\b|" +
621         "\\bSub\\b|\\bSyncLock\\b|\\bThen\\b|\\bThrow\\b|\\bTo\\b|\\bTrue\\b|\\bTry\\b|\\bTypeOf\\b|" +
622         "\\bUnicode\\b|\\bUntil\\b|\\bVariant\\b|\\bWhen\\b|\\bWhile\\b|\\bWith\\b|\\bWithEvents\\b|\\bWriteOnly\\b|\\bXor\\b)";
624 string Colorize (string text, string lang)
626         if (lang == "xml") return ColorizeXml (text);
627         else if (lang == "cs") return ColorizeCs (text);
628         else if (lang == "vb") return ColorizeVb (text);
629         else return text;
632 string ColorizeXml (string text)
634         text = text.Replace (" ", "&nbsp;");
635         Regex re = new Regex ("\r\n|\r|\n");
636         text = re.Replace (text, "_br_");
637         
638         re = new Regex ("<\\s*(\\/?)\\s*([\\s\\S]*?)\\s*(\\/?)\\s*>");
639         text = re.Replace (text,"{blue:&lt;$1}{maroon:$2}{blue:$3&gt;}");
640         
641         re = new Regex ("\\{(\\w*):([\\s\\S]*?)\\}");
642         text = re.Replace (text,"<span style='color:$1'>$2</span>");
644         re = new Regex ("\"(.*?)\"");
645         text = re.Replace (text,"\"<span style='color:purple'>$1</span>\"");
647         
648         text = text.Replace ("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
649         text = text.Replace ("_br_", "<br>");
650         return text;
653 string ColorizeCs (string text)
655         text = text.Replace (" ", "&nbsp;");
657         text = text.Replace ("<", "&lt;");
658         text = text.Replace (">", "&gt;");
660         Regex re = new Regex ("\"((((?!\").)|\\\")*?)\"");
661         text = re.Replace (text,"<span style='color:purple'>\"$1\"</span>");
663         re = new Regex ("//(((.(?!\"</span>))|\"(((?!\").)*)\"</span>)*)(\r|\n|\r\n)");
664         text = re.Replace (text,"<span style='color:green'>//$1</span><br/>");
665         
666         re = new Regex (keywords_cs);
667         text = re.Replace (text,"<span style='color:blue'>$1</span>");
668         
669         text = text.Replace ("\t","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
670         text = text.Replace ("\n","<br/>");
671         
672         return text;
675 string ColorizeVb (string text)
677         text = text.Replace (" ", "&nbsp;");
678         
679 /*      Regex re = new Regex ("\"((((?!\").)|\\\")*?)\"");
680         text = re.Replace (text,"<span style='color:purple'>\"$1\"</span>");
682         re = new Regex ("'(((.(?!\"\\<\\/span\\>))|\"(((?!\").)*)\"\\<\\/span\\>)*)(\r|\n|\r\n)");
683         text = re.Replace (text,"<span style='color:green'>//$1</span><br/>");
684         
685         re = new Regex (keywords_vb);
686         text = re.Replace (text,"<span style='color:blue'>$1</span>");
687 */      
688         text = text.Replace ("\t","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
689         text = text.Replace ("\n","<br/>");
690         return text;
694 // Helper methods and classes
697 string GetDataContext ()
699         return "op=" + CurrentOperationName + "&bnd=" + CurrentOperationBinding + "&";
702 string GetOptionSel (string v1, string v2)
704         string op = "<option ";
705         if (v1 == v2) op += "selected ";
706         return op + "value='" + v1 + "'>";
709 string WrapText (string text, int maxChars)
711         text =  text.Replace(" />","/>");
712         
713         string linspace = null;
714         int lincount = 0;
715         int breakpos = 0;
716         int linstart = 0;
717         bool inquotes = false;
718         char lastc = ' ';
719         string sublineIndent = "";
720         System.Text.StringBuilder sb = new System.Text.StringBuilder ();
721         for (int n=0; n<text.Length; n++)
722         {
723                 char c = text [n];
724                 
725                 if (c=='\r' || c=='\n' || n==text.Length-1)
726                 {
727                         sb.Append (linspace + sublineIndent + text.Substring (linstart, n-linstart+1));
728                         linspace = null;
729                         lincount = 0;
730                         linstart = n+1;
731                         breakpos = linstart;
732                         sublineIndent = "";
733                         lastc = c;
734                         continue;
735                 }
736                 
737                 if (lastc==',' || lastc=='(')
738                 {
739                         if (!inquotes) breakpos = n;
740                 }
741                 
742                 if (lincount > maxChars && breakpos >= linstart)
743                 {
744                         if (linspace != null)
745                                 sb.Append (linspace + sublineIndent);
746                         sb.Append (text.Substring (linstart, breakpos-linstart));
747                         sb.Append ("\n");
748                         sublineIndent = "     ";
749                         lincount = linspace.Length + sublineIndent.Length + (n-breakpos);
750                         linstart = breakpos;
751                 }
752                 
753                 if (c==' ' || c=='\t')
754                 {
755                         if (!inquotes)
756                                 breakpos = n;
757                 }
758                 else if (c=='"')
759                 {
760                         inquotes = !inquotes;
761                 }
762                 else 
763                         if (linspace == null) {
764                                 linspace = text.Substring (linstart, n-linstart);
765                                 linstart = n;
766                         }
768                 lincount++;
769                 lastc = c;
770         }
771         return sb.ToString ();
774 class Parameter
776         string name;
777         string type;
778         string description;
780         public string Name { get { return name; } set { name = value; } }
781         public string Type { get { return type; } set { type = value; } }
782         public string Description { get { return description; } set { description = value; } }
785 public class HtmlSampleGenerator: SampleGenerator
787         public HtmlSampleGenerator (ServiceDescriptionCollection services, XmlSchemas schemas)
788         : base (services, schemas)
789         {
790         }
791                 
792         protected override string GetLiteral (string s)
793         {
794                 return "@placeholder!" + s + "!placeholder@";
795         }
799         public class SampleGenerator
800         {
801                 protected ServiceDescriptionCollection descriptions;
802                 protected XmlSchemas schemas;
803                 XmlSchemaElement anyElement;
804                 ArrayList queue;
805                 SoapBindingUse currentUse;
806                 XmlDocument document = new XmlDocument ();
807                 
808                 static readonly XmlQualifiedName anyType = new XmlQualifiedName ("anyType",XmlSchema.Namespace);
809                 static readonly XmlQualifiedName arrayType = new XmlQualifiedName ("Array","http://schemas.xmlsoap.org/soap/encoding/");
810                 static readonly XmlQualifiedName arrayTypeRefName = new XmlQualifiedName ("arrayType","http://schemas.xmlsoap.org/soap/encoding/");
811                 const string SoapEnvelopeNamespace = "http://schemas.xmlsoap.org/soap/envelope/";
812                 const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
813                 const string SoapEncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
814                 
815                 class EncodedType
816                 {
817                         public EncodedType (string ns, XmlSchemaElement elem) { Namespace = ns; Element = elem; }
818                         public string Namespace;
819                         public XmlSchemaElement Element;
820                 }
822                 public SampleGenerator (ServiceDescriptionCollection services, XmlSchemas schemas)
823                 {
824                         descriptions = services;
825                         this.schemas = schemas;
826                         queue = new ArrayList ();
827                 }
828                 
829                 public string GenerateMessage (Port port, OperationBinding obin, Operation oper, string protocol, bool generateInput)
830                 {
831                         OperationMessage msg = null;
832                         foreach (OperationMessage opm in oper.Messages)
833                         {
834                                 if (opm is OperationInput && generateInput) msg = opm;
835                                 else if (opm is OperationOutput && !generateInput) msg = opm;
836                         }
837                         if (msg == null) return null;
838                         
839                         switch (protocol) {
840                                 case "Soap": return GenerateHttpSoapMessage (port, obin, oper, msg);
841                                 case "HttpGet": return GenerateHttpGetMessage (port, obin, oper, msg);
842                                 case "HttpPost": return GenerateHttpPostMessage (port, obin, oper, msg);
843                         }
844                         return "Unknown protocol";
845                 }
846                 
847                 public string GenerateHttpSoapMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
848                 {
849                         string req = "";
850                         
851                         if (msg is OperationInput)
852                         {
853                                 SoapAddressBinding sab = port.Extensions.Find (typeof(SoapAddressBinding)) as SoapAddressBinding;
854                                 SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
855                                 req += "POST " + new Uri (sab.Location).AbsolutePath + "\n";
856                                 req += "SOAPAction: " + sob.SoapAction + "\n";
857                                 req += "Content-Type: text/xml; charset=utf-8\n";
858                                 req += "Content-Length: " + GetLiteral ("string") + "\n";
859                                 req += "Host: " + GetLiteral ("string") + "\n\n";
860                         }
861                         else
862                         {
863                                 req += "HTTP/1.0 200 OK\n";
864                                 req += "Content-Type: text/xml; charset=utf-8\n";
865                                 req += "Content-Length: " + GetLiteral ("string") + "\n\n";
866                         }
867                         
868                         req += GenerateSoapMessage (obin, oper, msg);
869                         return req;
870                 }
871                 
872                 public string GenerateHttpGetMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
873                 {
874                         string req = "";
875                         
876                         if (msg is OperationInput)
877                         {
878                                 HttpAddressBinding sab = port.Extensions.Find (typeof(HttpAddressBinding)) as HttpAddressBinding;
879                                 HttpOperationBinding sob = obin.Extensions.Find (typeof(HttpOperationBinding)) as HttpOperationBinding;
880                                 string location = new Uri (sab.Location).AbsolutePath + sob.Location + "?" + BuildQueryString (msg);
881                                 req += "GET " + location + "\n";
882                                 req += "Host: " + GetLiteral ("string");
883                         }
884                         else
885                         {
886                                 req += "HTTP/1.0 200 OK\n";
887                                 req += "Content-Type: text/xml; charset=utf-8\n";
888                                 req += "Content-Length: " + GetLiteral ("string") + "\n\n";
889                         
890                                 MimeXmlBinding mxb = (MimeXmlBinding) obin.Output.Extensions.Find (typeof(MimeXmlBinding)) as MimeXmlBinding;
891                                 if (mxb == null) return req;
892                                 
893                                 Message message = descriptions.GetMessage (msg.Message);
894                                 XmlQualifiedName ename = null;
895                                 foreach (MessagePart part in message.Parts)
896                                         if (part.Name == mxb.Part) ename = part.Element;
897                                         
898                                 if (ename == null) return req + GetLiteral("string");
899                                 
900                                 StringWriter sw = new StringWriter ();
901                                 XmlTextWriter xtw = new XmlTextWriter (sw);
902                                 xtw.Formatting = Formatting.Indented;
903                                 currentUse = SoapBindingUse.Literal;
904                                 WriteRootElementSample (xtw, ename);
905                                 xtw.Close ();
906                                 req += sw.ToString ();
907                         }
908                         
909                         return req;
910                 }
911                 
912                 public string GenerateHttpPostMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
913                 {
914                         string req = "";
915                         
916                         if (msg is OperationInput)
917                         {
918                                 HttpAddressBinding sab = port.Extensions.Find (typeof(HttpAddressBinding)) as HttpAddressBinding;
919                                 HttpOperationBinding sob = obin.Extensions.Find (typeof(HttpOperationBinding)) as HttpOperationBinding;
920                                 string location = new Uri (sab.Location).AbsolutePath + sob.Location;
921                                 req += "POST " + location + "\n";
922                                 req += "Content-Type: application/x-www-form-urlencoded\n";
923                                 req += "Content-Length: " + GetLiteral ("string") + "\n";
924                                 req += "Host: " + GetLiteral ("string") + "\n\n";
925                                 req += BuildQueryString (msg);
926                         }
927                         else return GenerateHttpGetMessage (port, obin, oper, msg);
928                         
929                         return req;
930                 }
931                 
932                 string BuildQueryString (OperationMessage opm)
933                 {
934                         string s = "";
935                         Message msg = descriptions.GetMessage (opm.Message);
936                         foreach (MessagePart part in msg.Parts)
937                         {
938                                 if (s.Length != 0) s += "&";
939                                 s += part.Name + "=" + GetLiteral (part.Type.Name);
940                         }
941                         return s;
942                 }
943                 
944                 public string GenerateSoapMessage (OperationBinding obin, Operation oper, OperationMessage msg)
945                 {
946                         SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
947                         SoapBindingStyle style = (sob != null) ? sob.Style : SoapBindingStyle.Document;
948                         
949                         MessageBinding msgbin = (msg is OperationInput) ? (MessageBinding) obin.Input : (MessageBinding)obin.Output;
950                         SoapBodyBinding sbb = msgbin.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
951                         SoapBindingUse bodyUse = (sbb != null) ? sbb.Use : SoapBindingUse.Literal;
952                         
953                         StringWriter sw = new StringWriter ();
954                         XmlTextWriter xtw = new XmlTextWriter (sw);
955                         xtw.Formatting = Formatting.Indented;
956                         
957                         xtw.WriteStartDocument ();
958                         xtw.WriteStartElement ("soap", "Envelope", SoapEnvelopeNamespace);
959                         xtw.WriteAttributeString ("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
960                         xtw.WriteAttributeString ("xmlns", "xsd", null, XmlSchema.Namespace);
961                         
962                         if (bodyUse == SoapBindingUse.Encoded) 
963                         {
964                                 xtw.WriteAttributeString ("xmlns", "soapenc", null, SoapEncodingNamespace);
965                                 xtw.WriteAttributeString ("xmlns", "tns", null, msg.Message.Namespace);
966                         }
968                         // Serialize headers
969                         
970                         bool writtenHeader = false;
971                         foreach (object ob in msgbin.Extensions)
972                         {
973                                 SoapHeaderBinding hb = ob as SoapHeaderBinding;
974                                 if (hb == null) continue;
975                                 
976                                 if (!writtenHeader) {
977                                         xtw.WriteStartElement ("soap", "Header", SoapEnvelopeNamespace);
978                                         writtenHeader = true;
979                                 }
980                                 
981                                 WriteHeader (xtw, hb);
982                         }
983                         
984                         if (writtenHeader)
985                                 xtw.WriteEndElement ();
987                         // Serialize body
988                         xtw.WriteStartElement ("soap", "Body", SoapEnvelopeNamespace);
989                         
990                         currentUse = bodyUse;
991                         WriteBody (xtw, oper, msg, sbb, style);
992                         
993                         xtw.WriteEndElement ();
994                         xtw.WriteEndElement ();
995                         xtw.Close ();
996                         return sw.ToString ();
997                 }
998                 
999                 void WriteHeader (XmlTextWriter xtw, SoapHeaderBinding header)
1000                 {
1001                         Message msg = descriptions.GetMessage (header.Message);
1002                         if (msg == null) throw new InvalidOperationException ("Message " + header.Message + " not found");
1003                         MessagePart part = msg.Parts [header.Part];
1004                         if (part == null) throw new InvalidOperationException ("Message part " + header.Part + " not found in message " + header.Message);
1006                         currentUse = header.Use;
1007                         
1008                         if (currentUse == SoapBindingUse.Literal)
1009                                 WriteRootElementSample (xtw, part.Element);
1010                         else
1011                                 WriteTypeSample (xtw, part.Type);
1012                 }
1013                 
1014                 void WriteBody (XmlTextWriter xtw, Operation oper, OperationMessage opm, SoapBodyBinding sbb, SoapBindingStyle style)
1015                 {
1016                         Message msg = descriptions.GetMessage (opm.Message);
1017                         if (msg.Parts.Count > 0 && msg.Parts[0].Name == "parameters")
1018                         {
1019                                 MessagePart part = msg.Parts[0];
1020                                 if (part.Element == XmlQualifiedName.Empty)
1021                                         WriteTypeSample (xtw, part.Type);
1022                                 else
1023                                         WriteRootElementSample (xtw, part.Element);
1024                         }
1025                         else
1026                         {
1027                                 string elemName = oper.Name;
1028                                 string ns = "";
1029                                 if (opm is OperationOutput) elemName += "Response";
1030                                 
1031                                 if (style == SoapBindingStyle.Rpc) {
1032                                         xtw.WriteStartElement (elemName, sbb.Namespace);
1033                                         ns = sbb.Namespace;
1034                                 }
1035                                         
1036                                 foreach (MessagePart part in msg.Parts)
1037                                 {
1038                                         if (part.Element == XmlQualifiedName.Empty)
1039                                         {
1040                                                 XmlSchemaElement elem = new XmlSchemaElement ();
1041                                                 elem.SchemaTypeName = part.Type;
1042                                                 elem.Name = part.Name;
1043                                                 WriteElementSample (xtw, ns, elem);
1044                                         }
1045                                         else
1046                                                 WriteRootElementSample (xtw, part.Element);
1047                                 }
1048                                 
1049                                 if (style == SoapBindingStyle.Rpc)
1050                                         xtw.WriteEndElement ();
1051                         }
1052                         WriteQueuedTypeSamples (xtw);
1053                 }
1054                 
1055                 void WriteRootElementSample (XmlTextWriter xtw, XmlQualifiedName qname)
1056                 {
1057                         XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (qname, typeof(XmlSchemaElement));
1058                         if (elem == null) throw new InvalidOperationException ("Element not found: " + qname);
1059                         WriteElementSample (xtw, qname.Namespace, elem);
1060                 }
1061                 
1062                 void WriteElementSample (XmlTextWriter xtw, string ns, XmlSchemaElement elem)
1063                 {
1064                         bool sharedAnnType = false;
1065                         XmlQualifiedName root;
1066                         
1067                         if (!elem.RefName.IsEmpty) {
1068                                 XmlSchemaElement refElem = FindRefElement (elem);
1069                                 if (refElem == null) throw new InvalidOperationException ("Global element not found: " + elem.RefName);
1070                                 root = elem.RefName;
1071                                 elem = refElem;
1072                                 sharedAnnType = true;
1073                         }
1074                         else
1075                                 root = new XmlQualifiedName (elem.Name, ns);
1076                         
1077                         if (!elem.SchemaTypeName.IsEmpty)
1078                         {
1079                                 XmlSchemaComplexType st = FindComplexTyype (elem.SchemaTypeName);
1080                                 if (st != null) 
1081                                         WriteComplexTypeSample (xtw, st, root);
1082                                 else
1083                                 {
1084                                         xtw.WriteStartElement (root.Name, root.Namespace);
1085                                         if (currentUse == SoapBindingUse.Encoded) 
1086                                                 xtw.WriteAttributeString ("type", XmlSchema.InstanceNamespace, GetQualifiedNameString (xtw, elem.SchemaTypeName));
1087                                         xtw.WriteString (GetLiteral (FindBuiltInType (elem.SchemaTypeName)));
1088                                         xtw.WriteEndElement ();
1089                                 }
1090                         }
1091                         else if (elem.SchemaType == null)
1092                         {
1093                                 xtw.WriteStartElement ("any");
1094                                 xtw.WriteEndElement ();
1095                         }
1096                         else
1097                                 WriteComplexTypeSample (xtw, (XmlSchemaComplexType) elem.SchemaType, root);
1098                 }
1099                 
1100                 void WriteTypeSample (XmlTextWriter xtw, XmlQualifiedName qname)
1101                 {
1102                         XmlSchemaComplexType ctype = FindComplexTyype (qname);
1103                         if (ctype != null) {
1104                                 WriteComplexTypeSample (xtw, ctype, qname);
1105                                 return;
1106                         }
1107                         
1108                         XmlSchemaSimpleType stype = (XmlSchemaSimpleType) schemas.Find (qname, typeof(XmlSchemaSimpleType));
1109                         if (stype != null) {
1110                                 WriteSimpleTypeSample (xtw, stype);
1111                                 return;
1112                         }
1113                         
1114                         xtw.WriteString (GetLiteral (FindBuiltInType (qname)));
1115                         throw new InvalidOperationException ("Type not found: " + qname);
1116                 }
1117                 
1118                 void WriteComplexTypeSample (XmlTextWriter xtw, XmlSchemaComplexType stype, XmlQualifiedName rootName)
1119                 {
1120                         WriteComplexTypeSample (xtw, stype, rootName, -1);
1121                 }
1122                 
1123                 void WriteComplexTypeSample (XmlTextWriter xtw, XmlSchemaComplexType stype, XmlQualifiedName rootName, int id)
1124                 {
1125                         string ns = rootName.Namespace;
1126                         
1127                         if (rootName.Name.IndexOf ("[]") != -1) rootName = arrayType;
1128                         
1129                         if (currentUse == SoapBindingUse.Encoded) {
1130                                 string pref = xtw.LookupPrefix (rootName.Namespace);
1131                                 if (pref == null) pref = "q1";
1132                                 xtw.WriteStartElement (pref, rootName.Name, rootName.Namespace);
1133                                 ns = "";
1134                         }
1135                         else
1136                                 xtw.WriteStartElement (rootName.Name, rootName.Namespace);
1137                         
1138                         if (id != -1)
1139                         {
1140                                 xtw.WriteAttributeString ("id", "id" + id);
1141                                 if (rootName != arrayType)
1142                                         xtw.WriteAttributeString ("type", XmlSchema.InstanceNamespace, GetQualifiedNameString (xtw, rootName));
1143                         }
1144                         
1145                         WriteComplexTypeAttributes (xtw, stype);
1146                         WriteComplexTypeElements (xtw, ns, stype);
1147                         
1148                         xtw.WriteEndElement ();
1149                 }
1150                 
1151                 void WriteComplexTypeAttributes (XmlTextWriter xtw, XmlSchemaComplexType stype)
1152                 {
1153                         WriteAttributes (xtw, stype.Attributes, stype.AnyAttribute);
1154                 }
1155                 
1156                 void WriteComplexTypeElements (XmlTextWriter xtw, string ns, XmlSchemaComplexType stype)
1157                 {
1158                         if (stype.Particle != null)
1159                                 WriteParticleComplexContent (xtw, ns, stype.Particle);
1160                         else
1161                         {
1162                                 if (stype.ContentModel is XmlSchemaSimpleContent)
1163                                         WriteSimpleContent (xtw, (XmlSchemaSimpleContent)stype.ContentModel);
1164                                 else if (stype.ContentModel is XmlSchemaComplexContent)
1165                                         WriteComplexContent (xtw, ns, (XmlSchemaComplexContent)stype.ContentModel);
1166                         }
1167                 }
1169                 void WriteAttributes (XmlTextWriter xtw, XmlSchemaObjectCollection atts, XmlSchemaAnyAttribute anyat)
1170                 {
1171                         foreach (XmlSchemaObject at in atts)
1172                         {
1173                                 if (at is XmlSchemaAttribute)
1174                                 {
1175                                         string ns;
1176                                         XmlSchemaAttribute attr = (XmlSchemaAttribute)at;
1177                                         XmlSchemaAttribute refAttr = attr;
1178                                         
1179                                         // refAttr.Form; TODO
1180                                         
1181                                         if (!attr.RefName.IsEmpty) {
1182                                                 refAttr = FindRefAttribute (attr.RefName);
1183                                                 if (refAttr == null) throw new InvalidOperationException ("Global attribute not found: " + attr.RefName);
1184                                         }
1185                                         
1186                                         string val;
1187                                         if (!refAttr.SchemaTypeName.IsEmpty) val = FindBuiltInType (refAttr.SchemaTypeName);
1188                                         else val = FindBuiltInType ((XmlSchemaSimpleType) refAttr.SchemaType);
1189                                         
1190                                         xtw.WriteAttributeString (refAttr.Name, val);
1191                                 }
1192                                 else if (at is XmlSchemaAttributeGroupRef)
1193                                 {
1194                                         XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef)at;
1195                                         XmlSchemaAttributeGroup grp = (XmlSchemaAttributeGroup) schemas.Find (gref.RefName, typeof(XmlSchemaAttributeGroup));
1196                                         WriteAttributes (xtw, grp.Attributes, grp.AnyAttribute);
1197                                 }
1198                         }
1199                         
1200                         if (anyat != null)
1201                                 xtw.WriteAttributeString ("custom-attribute","value");
1202                 }
1203                 
1204                 void WriteParticleComplexContent (XmlTextWriter xtw, string ns, XmlSchemaParticle particle)
1205                 {
1206                         WriteParticleContent (xtw, ns, particle, false);
1207                 }
1208                 
1209                 void WriteParticleContent (XmlTextWriter xtw, string ns, XmlSchemaParticle particle, bool multiValue)
1210                 {
1211                         if (particle is XmlSchemaGroupRef)
1212                                 particle = GetRefGroupParticle ((XmlSchemaGroupRef)particle);
1214                         if (particle.MaxOccurs > 1) multiValue = true;
1215                         
1216                         if (particle is XmlSchemaSequence) {
1217                                 WriteSequenceContent (xtw, ns, ((XmlSchemaSequence)particle).Items, multiValue);
1218                         }
1219                         else if (particle is XmlSchemaChoice) {
1220                                 if (((XmlSchemaChoice)particle).Items.Count == 1)
1221                                         WriteSequenceContent (xtw, ns, ((XmlSchemaChoice)particle).Items, multiValue);
1222                                 else
1223                                         WriteChoiceContent (xtw, ns, (XmlSchemaChoice)particle, multiValue);
1224                         }
1225                         else if (particle is XmlSchemaAll) {
1226                                 WriteSequenceContent (xtw, ns, ((XmlSchemaAll)particle).Items, multiValue);
1227                         }
1228                 }
1230                 void WriteSequenceContent (XmlTextWriter xtw, string ns, XmlSchemaObjectCollection items, bool multiValue)
1231                 {
1232                         foreach (XmlSchemaObject item in items)
1233                                 WriteContentItem (xtw, ns, item, multiValue);
1234                 }
1235                 
1236                 void WriteContentItem (XmlTextWriter xtw, string ns, XmlSchemaObject item, bool multiValue)
1237                 {
1238                         if (item is XmlSchemaGroupRef)
1239                                 item = GetRefGroupParticle ((XmlSchemaGroupRef)item);
1240                                         
1241                         if (item is XmlSchemaElement)
1242                         {
1243                                 XmlSchemaElement elem = (XmlSchemaElement) item;
1244                                 XmlSchemaElement refElem;
1245                                 if (!elem.RefName.IsEmpty) refElem = FindRefElement (elem);
1246                                 else refElem = elem;
1248                                 int num = (elem.MaxOccurs == 1 && !multiValue) ? 1 : 2;
1249                                 for (int n=0; n<num; n++)
1250                                 {
1251                                         if (currentUse == SoapBindingUse.Literal)
1252                                                 WriteElementSample (xtw, ns, refElem);
1253                                         else
1254                                                 WriteRefTypeSample (xtw, ns, refElem);
1255                                 }
1256                         }
1257                         else if (item is XmlSchemaAny)
1258                         {
1259                                 xtw.WriteString (GetLiteral ("xml"));
1260                         }
1261                         else if (item is XmlSchemaParticle) {
1262                                 WriteParticleContent (xtw, ns, (XmlSchemaParticle)item, multiValue);
1263                         }
1264                 }
1265                 
1266                 void WriteChoiceContent (XmlTextWriter xtw, string ns, XmlSchemaChoice choice, bool multiValue)
1267                 {
1268                         foreach (XmlSchemaObject item in choice.Items)
1269                                 WriteContentItem (xtw, ns, item, multiValue);
1270                 }
1272                 void WriteSimpleContent (XmlTextWriter xtw, XmlSchemaSimpleContent content)
1273                 {
1274                         XmlSchemaSimpleContentExtension ext = content.Content as XmlSchemaSimpleContentExtension;
1275                         if (ext != null)
1276                                 WriteAttributes (xtw, ext.Attributes, ext.AnyAttribute);
1277                                 
1278                         XmlQualifiedName qname = GetContentBaseType (content.Content);
1279                         xtw.WriteString (GetLiteral (FindBuiltInType (qname)));
1280                 }
1282                 string FindBuiltInType (XmlQualifiedName qname)
1283                 {
1284                         if (qname.Namespace == XmlSchema.Namespace)
1285                                 return qname.Name;
1287                         XmlSchemaComplexType ct = FindComplexTyype (qname);
1288                         if (ct != null)
1289                         {
1290                                 XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;
1291                                 if (sc == null) throw new InvalidOperationException ("Invalid schema");
1292                                 return FindBuiltInType (GetContentBaseType (sc.Content));
1293                         }
1294                         
1295                         XmlSchemaSimpleType st = (XmlSchemaSimpleType) schemas.Find (qname, typeof(XmlSchemaSimpleType));
1296                         if (st != null)
1297                                 return FindBuiltInType (st);
1299                         throw new InvalidOperationException ("Definition of type " + qname + " not found");
1300                 }
1302                 string FindBuiltInType (XmlSchemaSimpleType st)
1303                 {
1304                         if (st.Content is XmlSchemaSimpleTypeRestriction) {
1305                                 return FindBuiltInType (GetContentBaseType (st.Content));
1306                         }
1307                         else if (st.Content is XmlSchemaSimpleTypeList) {
1308                                 string s = FindBuiltInType (GetContentBaseType (st.Content));
1309                                 return s + " " + s + " ...";
1310                         }
1311                         else if (st.Content is XmlSchemaSimpleTypeUnion)
1312                         {
1313                                 //Check if all types of the union are equal. If not, then will use anyType.
1314                                 XmlSchemaSimpleTypeUnion uni = (XmlSchemaSimpleTypeUnion) st.Content;
1315                                 string utype = null;
1317                                 // Anonymous types are unique
1318                                 if (uni.BaseTypes.Count != 0 && uni.MemberTypes.Length != 0)
1319                                         return "string";
1321                                 foreach (XmlQualifiedName mt in uni.MemberTypes)
1322                                 {
1323                                         string qn = FindBuiltInType (mt);
1324                                         if (utype != null && qn != utype) return "string";
1325                                         else utype = qn;
1326                                 }
1327                                 return utype;
1328                         }
1329                         else
1330                                 return "string";
1331                 }
1332                 
1334                 XmlQualifiedName GetContentBaseType (XmlSchemaObject ob)
1335                 {
1336                         if (ob is XmlSchemaSimpleContentExtension)
1337                                 return ((XmlSchemaSimpleContentExtension)ob).BaseTypeName;
1338                         else if (ob is XmlSchemaSimpleContentRestriction)
1339                                 return ((XmlSchemaSimpleContentRestriction)ob).BaseTypeName;
1340                         else if (ob is XmlSchemaSimpleTypeRestriction)
1341                                 return ((XmlSchemaSimpleTypeRestriction)ob).BaseTypeName;
1342                         else if (ob is XmlSchemaSimpleTypeList)
1343                                 return ((XmlSchemaSimpleTypeList)ob).ItemTypeName;
1344                         else
1345                                 return null;
1346                 }
1348                 void WriteComplexContent (XmlTextWriter xtw, string ns, XmlSchemaComplexContent content)
1349                 {
1350                         XmlQualifiedName qname;
1352                         XmlSchemaComplexContentExtension ext = content.Content as XmlSchemaComplexContentExtension;
1353                         if (ext != null) qname = ext.BaseTypeName;
1354                         else {
1355                                 XmlSchemaComplexContentRestriction rest = (XmlSchemaComplexContentRestriction)content.Content;
1356                                 qname = rest.BaseTypeName;
1357                                 if (qname == arrayType) {
1358                                         ParseArrayType (rest, out qname);
1359                                         XmlSchemaElement elem = new XmlSchemaElement ();
1360                                         elem.Name = "Item";
1361                                         elem.SchemaTypeName = qname;
1362                                         
1363                                         xtw.WriteAttributeString ("arrayType", SoapEncodingNamespace, qname.Name + "[2]");
1364                                         WriteContentItem (xtw, ns, elem, true);
1365                                         return;
1366                                 }
1367                         }
1368                         
1369                         // Add base map members to this map
1370                         XmlSchemaComplexType ctype = FindComplexTyype (qname);
1371                         WriteComplexTypeAttributes (xtw, ctype);
1372                         
1373                         if (ext != null) {
1374                                 // Add the members of this map
1375                                 WriteAttributes (xtw, ext.Attributes, ext.AnyAttribute);
1376                                 if (ext.Particle != null)
1377                                         WriteParticleComplexContent (xtw, ns, ext.Particle);
1378                         }
1379                         
1380                         WriteComplexTypeElements (xtw, ns, ctype);
1381                 }
1382                 
1383                 void ParseArrayType (XmlSchemaComplexContentRestriction rest, out XmlQualifiedName qtype)
1384                 {
1385                         XmlSchemaAttribute arrayTypeAt = FindArrayAttribute (rest.Attributes);
1386                         XmlAttribute[] uatts = arrayTypeAt.UnhandledAttributes;
1387                         if (uatts == null || uatts.Length == 0) throw new InvalidOperationException ("arrayType attribute not specified in array declaration");
1388                         
1389                         XmlAttribute xat = null;
1390                         foreach (XmlAttribute at in uatts)
1391                                 if (at.LocalName == "arrayType" && at.NamespaceURI == WsdlNamespace)
1392                                         { xat = at; break; }
1393                         
1394                         if (xat == null) 
1395                                 throw new InvalidOperationException ("arrayType attribute not specified in array declaration");
1396                         
1397                         string arrayType = xat.Value;
1398                         string type, ns;
1399                         int i = arrayType.LastIndexOf (":");
1400                         if (i == -1) ns = "";
1401                         else ns = arrayType.Substring (0,i);
1402                         
1403                         int j = arrayType.IndexOf ("[", i+1);
1404                         if (j == -1) throw new InvalidOperationException ("Cannot parse WSDL array type: " + arrayType);
1405                         type = arrayType.Substring (i+1);
1406                         type = type.Substring (0, type.Length-2);
1407                         
1408                         qtype = new XmlQualifiedName (type, ns);
1409                 }
1410                 
1411                 XmlSchemaAttribute FindArrayAttribute (XmlSchemaObjectCollection atts)
1412                 {
1413                         foreach (object ob in atts)
1414                         {
1415                                 XmlSchemaAttribute att = ob as XmlSchemaAttribute;
1416                                 if (att != null && att.RefName == arrayTypeRefName) return att;
1417                                 
1418                                 XmlSchemaAttributeGroupRef gref = ob as XmlSchemaAttributeGroupRef;
1419                                 if (gref != null)
1420                                 {
1421                                         XmlSchemaAttributeGroup grp = (XmlSchemaAttributeGroup) schemas.Find (gref.RefName, typeof(XmlSchemaAttributeGroup));
1422                                         att = FindArrayAttribute (grp.Attributes);
1423                                         if (att != null) return att;
1424                                 }
1425                         }
1426                         return null;
1427                 }
1428                 
1429                 void WriteSimpleTypeSample (XmlTextWriter xtw, XmlSchemaSimpleType stype)
1430                 {
1431                         xtw.WriteString (GetLiteral (FindBuiltInType (stype)));
1432                 }
1433                 
1434                 XmlSchemaParticle GetRefGroupParticle (XmlSchemaGroupRef refGroup)
1435                 {
1436                         XmlSchemaGroup grp = (XmlSchemaGroup) schemas.Find (refGroup.RefName, typeof (XmlSchemaGroup));
1437                         return grp.Particle;
1438                 }
1440                 XmlSchemaElement FindRefElement (XmlSchemaElement elem)
1441                 {
1442                         if (elem.RefName.Namespace == XmlSchema.Namespace)
1443                         {
1444                                 if (anyElement != null) return anyElement;
1445                                 anyElement = new XmlSchemaElement ();
1446                                 anyElement.Name = "any";
1447                                 anyElement.SchemaTypeName = anyType;
1448                                 return anyElement;
1449                         }
1450                         return (XmlSchemaElement) schemas.Find (elem.RefName, typeof(XmlSchemaElement));
1451                 }
1452                 
1453                 XmlSchemaAttribute FindRefAttribute (XmlQualifiedName refName)
1454                 {
1455                         if (refName.Namespace == XmlSchema.Namespace)
1456                         {
1457                                 XmlSchemaAttribute at = new XmlSchemaAttribute ();
1458                                 at.Name = refName.Name;
1459                                 at.SchemaTypeName = new XmlQualifiedName ("string",XmlSchema.Namespace);
1460                                 return at;
1461                         }
1462                         return (XmlSchemaAttribute) schemas.Find (refName, typeof(XmlSchemaAttribute));
1463                 }
1464                 
1465                 void WriteRefTypeSample (XmlTextWriter xtw, string ns, XmlSchemaElement elem)
1466                 {
1467                         if (elem.SchemaTypeName.Namespace == XmlSchema.Namespace || schemas.Find (elem.SchemaTypeName, typeof(XmlSchemaSimpleType)) != null)
1468                                 WriteElementSample (xtw, ns, elem);
1469                         else
1470                         {
1471                                 xtw.WriteStartElement (elem.Name, ns);
1472                                 xtw.WriteAttributeString ("href", "#id" + (queue.Count+1));
1473                                 xtw.WriteEndElement ();
1474                                 queue.Add (new EncodedType (ns, elem));
1475                         }
1476                 }
1477                 
1478                 void WriteQueuedTypeSamples (XmlTextWriter xtw)
1479                 {
1480                         for (int n=0; n<queue.Count; n++)
1481                         {
1482                                 EncodedType ec = (EncodedType) queue[n];
1483                                 XmlSchemaComplexType st = FindComplexTyype (ec.Element.SchemaTypeName);
1484                                 WriteComplexTypeSample (xtw, st, ec.Element.SchemaTypeName, n+1);
1485                         }
1486                 }
1487                 
1488                 XmlSchemaComplexType FindComplexTyype (XmlQualifiedName qname)
1489                 {
1490                         if (qname.Name.IndexOf ("[]") != -1)
1491                         {
1492                                 XmlSchemaComplexType stype = new XmlSchemaComplexType ();
1493                                 stype.ContentModel = new XmlSchemaComplexContent ();
1494                                 
1495                                 XmlSchemaComplexContentRestriction res = new XmlSchemaComplexContentRestriction ();
1496                                 stype.ContentModel.Content = res;
1497                                 res.BaseTypeName = arrayType;
1498                                 
1499                                 XmlSchemaAttribute att = new XmlSchemaAttribute ();
1500                                 att.RefName = arrayTypeRefName;
1501                                 res.Attributes.Add (att);
1502                                 
1503                                 XmlAttribute xat = document.CreateAttribute ("arrayType", WsdlNamespace);
1504                                 xat.Value = qname.Namespace + ":" + qname.Name;
1505                                 att.UnhandledAttributes = new XmlAttribute[] {xat};
1506                                 return stype;
1507                         }
1508                                 
1509                         return (XmlSchemaComplexType) schemas.Find (qname, typeof(XmlSchemaComplexType));
1510                 }
1511                 
1512                 string GetQualifiedNameString (XmlTextWriter xtw, XmlQualifiedName qname)
1513                 {
1514                         string pref = xtw.LookupPrefix (qname.Namespace);
1515                         if (pref != null) return pref + ":" + qname.Name;
1516                         
1517                         xtw.WriteAttributeString ("xmlns", "q1", null, qname.Namespace);
1518                         return "q1:" + qname.Name;
1519                 }
1520                                 
1521                 protected virtual string GetLiteral (string s)
1522                 {
1523                         return s;
1524                 }
1526                 void GetOperationFormat (OperationBinding obin, out SoapBindingStyle style, out SoapBindingUse use)
1527                 {
1528                         style = SoapBindingStyle.Document;
1529                         use = SoapBindingUse.Literal;
1530                         SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
1531                         if (sob != null) {
1532                                 style = sob.Style;
1533                                 SoapBodyBinding sbb = obin.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
1534                                 if (sbb != null)
1535                                         use = sbb.Use;
1536                         }
1537                 }
1538         }
1544 </script>
1546 <head>
1547         <link rel="alternate" type="text/xml" href="<%=Request.FilePath%>?disco"/>
1549         <title><%=WebServiceName%> Web Service</title>
1550     <style type="text/css">
1551                 BODY { font-family: Arial; margin-left: 20px; margin-top: 20px; font-size: x-small}
1552                 TABLE { font-size: x-small }
1553                 .title { color:dimgray; font-family: Arial; font-size:20pt; font-weight:900}
1554                 .operationTitle { color:dimgray; font-family: Arial; font-size:15pt; font-weight:900}
1555                 .method { font-size: x-small }
1556                 .bindingLabel { font-size: x-small; font-weight:bold; color:darkgray; line-height:8pt; display:block; margin-bottom:3px }
1557                 .label { font-size: small; font-weight:bold; color:darkgray }
1558                 .paramTable { font-size: x-small }
1559                 .paramTable TR { background-color: gainsboro }
1560                 .paramFormTable { font-size: x-small; padding: 10px; background-color: gainsboro }
1561                 .paramFormTable TR { background-color: gainsboro }
1562                 .paramInput { border: solid 1px gray }
1563                 .button {border: solid 1px gray }
1564                 .smallSeparator { height:3px; overflow:hidden }
1565                 .panel { background-color:whitesmoke; border: solid 1px silver; border-top: solid 1px silver  }
1566                 .codePanel { background-color: white; font-size:x-small; padding:7px; border:solid 1px silver}
1567                 .code-xml { font-size:10pt; font-family:courier }
1568                 .code-cs { font-size:10pt; font-family:courier }
1569                 .code-vb { font-size:10pt; font-family:courier }
1570                 .tabLabelOn { font-weight:bold }
1571                 .tabLabelOff {color: darkgray }
1572                 .literal-placeholder {color: darkblue; font-weight:bold}
1573                 A:link { color: black; }
1574                 A:visited { color: black; }
1575                 A:active { color: black; }
1576                 A:hover { color: blue }
1577     </style>
1578         
1579 <script>
1580 function clearForm ()
1582         document.getElementById("testFormResult").style.display="none";
1584 </script>
1586 </head>
1588 <body>
1589 <div class="title" style="margin-left:20px">
1590 <span class="label">Web Service</span><br>
1591 <%=WebServiceName%>
1592 </div>
1594 <!--
1595         **********************************************************
1596         Left panel
1599 <table border="0" width="100%" cellpadding="15px" cellspacing="15px">
1600 <tr valign="top"><td width="150px" class="panel">
1601 <div style="width:150px"></div>
1602 <a class="method" href='<%=PageName%>'>Overview</a><br>
1603 <div class="smallSeparator"></div>
1604 <a class="method" href='<%=PageName + "?" + GetPageContext("wsdl")%>'>Service Description</a>
1605 <div class="smallSeparator"></div>
1606 <a class="method" href='<%=PageName + "?" + GetPageContext("proxy")%>'>Client proxy</a>
1607 <br><br>
1608         <asp:repeater id="BindingsRepeater" runat=server>
1609                 <itemtemplate name="itemtemplate">
1610                         <span class="bindingLabel"><%#FormatBindingName(DataBinder.Eval(Container.DataItem, "Name").ToString())%></span>
1611                         <asp:repeater id="OperationsRepeater" runat=server datasource='<%# ((Binding)Container.DataItem).Operations %>'>
1612                                 <itemtemplate>
1613                                         <a class="method" href="<%=PageName%>?<%=GetTabContext("op",null)%>op=<%#GetOpName(Container.DataItem)%>&bnd=<%#DataBinder.Eval(Container.DataItem, "Binding.Name")%>"><%#GetOpName(Container.DataItem)%></a>
1614                                         <div class="smallSeparator"></div>
1615                                 </itemtemplate>
1616                         </asp:repeater>
1617                         <br>
1618                 </itemtemplate>
1619         </asp:repeater>
1621 </td><td class="panel">
1623 <% if (CurrentPage == "main") {%>
1625 <!--
1626         **********************************************************
1627         Web service overview
1630         <p class="label">Web Service Overview</p>
1631         <%=WebServiceDescription%>
1632         
1633 <%} if (DefaultBinding == null) {%>
1634 This service does not contain any public web method.
1635 <%} else if (CurrentPage == "op") {%>
1637 <!--
1638         **********************************************************
1639         Operation description
1642         <span class="operationTitle"><%=CurrentOperationName%></span>
1643         <br><br>
1644         <% WriteTabs (); %>
1645         <br><br><br>
1646         
1647         <% if (CurrentTab == "main") { %>
1648                 <span class="label">Input Parameters</span>
1649                 <div class="smallSeparator"></div>
1650                 <% if (InParams.Count == 0) { %>
1651                         No input parameters<br>
1652                 <% } else { %>
1653                         <table class="paramTable" cellspacing="1" cellpadding="5">
1654                         <asp:repeater id="InputParamsRepeater" runat=server>
1655                                 <itemtemplate>
1656                                         <tr>
1657                                         <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
1658                                         <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
1659                                         </tr>
1660                                 </itemtemplate>
1661                         </asp:repeater>
1662                         </table>
1663                 <% } %>
1664                 <br>
1665                 
1666                 <% if (OutParams.Count > 0) { %>
1667                 <span class="label">Output Parameters</span>
1668                         <div class="smallSeparator"></div>
1669                         <table class="paramTable" cellspacing="1" cellpadding="5">
1670                         <asp:repeater id="OutputParamsRepeater" runat=server>
1671                                 <itemtemplate>
1672                                         <tr>
1673                                         <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
1674                                         <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
1675                                         </tr>
1676                                 </itemtemplate>
1677                         </asp:repeater>
1678                         </table>
1679                 <br>
1680                 <% } %>
1681                 
1682                 <span class="label">Remarks</span>
1683                 <div class="smallSeparator"></div>
1684                 <%=OperationDocumentation%>
1685                 <br><br>
1686                 <span class="label">Technical information</span>
1687                 <div class="smallSeparator"></div>
1688                 Format: <%=CurrentOperationFormat%>
1689                 <br>Supported protocols: <%=CurrentOperationProtocols%>
1690         <% } %>
1691         
1692 <!--
1693         **********************************************************
1694         Operation description - Test form
1697         <% if (CurrentTab == "test") { 
1698                 if (CurrentOperationSupportsTest) {%>
1699                         Enter values for the parameters and click the 'Invoke' button to test this method:<br><br>
1700                         <form action="<%=PageName%>" method="GET">
1701                         <input type="hidden" name="page" value="<%=CurrentPage%>">
1702                         <input type="hidden" name="tab" value="<%=CurrentTab%>">
1703                         <input type="hidden" name="op" value="<%=CurrentOperationName%>">
1704                         <input type="hidden" name="bnd" value="<%=CurrentOperationBinding%>">
1705                         <input type="hidden" name="ext" value="testform">
1706                         <table class="paramFormTable" cellspacing="0" cellpadding="3">
1707                         <asp:repeater id="InputFormParamsRepeater" runat=server>
1708                                 <itemtemplate>
1709                                         <tr>
1710                                         <td><%#DataBinder.Eval(Container.DataItem, "Name")%>:&nbsp;</td>
1711                                         <td width="150"><input class="paramInput" type="text" size="20" name="<%#DataBinder.Eval(Container.DataItem, "Name")%>"></td>
1712                                         </tr>
1713                                 </itemtemplate>
1714                         </asp:repeater>
1715                         <tr><td></td><td><input class="button" type="submit" value="Invoke">&nbsp;<input class="button" type="button" onclick="clearForm()" value="Clear"></td></tr>
1716                         </table>
1717                         </form>
1718                         <div id="testFormResult" style="display:<%= (HasFormResult?"block":"none") %>">
1719                         The web service returned the following result:<br/><br/>
1720                         <div class="codePanel"><%=GetTestResult()%></div>
1721                         </div>
1722                 <% } else {%>
1723                 The test form is not available for this operation because it has parameters with a complex structure.
1724                 <% } %>
1725         <% } %>
1726         
1727 <!--
1728         **********************************************************
1729         Operation description - Message Layout
1732         <% if (CurrentTab == "msg") { %>
1733                 
1734                 The following are sample SOAP requests and responses for each protocol supported by this method:
1735                         <br/><br/>
1736                 
1737                 <% if (IsOperationSupported ("Soap")) { %>
1738                         <span class="label">Soap</span>
1739                         <br/><br/>
1740                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("Soap", true)%></div></div>
1741                         <br/>
1742                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("Soap", false)%></div></div>
1743                         <br/>
1744                 <% } %>
1745                 <% if (IsOperationSupported ("HttpGet")) { %>
1746                         <span class="label">HTTP Get</span>
1747                         <br/><br/>
1748                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpGet", true)%></div></div>
1749                         <br/>
1750                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpGet", false)%></div></div>
1751                         <br/>
1752                 <% } %>
1753                 <% if (IsOperationSupported ("HttpPost")) { %>
1754                         <span class="label">HTTP Post</span>
1755                         <br/><br/>
1756                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpPost", true)%></div></div>
1757                         <br/>
1758                         <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpPost", false)%></div></div>
1759                         <br/>
1760                 <% } %>
1761                 
1762         <% } %>
1763 <%} else if (CurrentPage == "proxy") {%>
1764 <!--
1765         **********************************************************
1766         Client Proxy
1768         <form action="<%=PageName%>" name="langForm" method="GET">
1769                 Select the language for which you want to generate a proxy 
1770                 <input type="hidden" name="page" value="<%=CurrentPage%>">&nbsp;
1771                 <SELECT name="lang" onchange="langForm.submit()">
1772                         <%=GetOptionSel("cs",CurrentLanguage)%>C#</option>
1773                         <%=GetOptionSel("vb",CurrentLanguage)%>Visual Basic</option>
1774                 </SELECT>
1775                 &nbsp;&nbsp;
1776         </form>
1777         <br>
1778         <span class="label"><%=CurrentProxytName%></span>&nbsp;&nbsp;&nbsp;
1779         <a href="<%=PageName + "?code=" + CurrentLanguage%>">Download</a>
1780         <br><br>
1781         <div class="codePanel">
1782         <div class="code-<%=CurrentLanguage%>"><%=GetProxyCode ()%></div>
1783         </div>
1784 <%} else if (CurrentPage == "wsdl") {%>
1785 <!--
1786         **********************************************************
1787         Service description
1789         <% if (descriptions.Count > 1 || schemas.Count > 1) {%>
1790         The description of this web service is composed by several documents. Click on the document you want to see:
1791         
1792         <ul>
1793         <% 
1794                 for (int n=0; n<descriptions.Count; n++)
1795                         Response.Write ("<li><a href='" + PageName + "?" + GetPageContext(null) + "doctype=wsdl&docind=" + n + "'>WSDL document " + descriptions[n].TargetNamespace + "</a></li>");
1796                 for (int n=0; n<schemas.Count; n++)
1797                         Response.Write ("<li><a href='" + PageName + "?" + GetPageContext(null) + "doctype=schema&docind=" + n + "'>Xml Schema " + schemas[n].TargetNamespace + "</a></li>");
1798         %>
1799         </ul>
1800         
1801         <%} else {%>
1802         <%}%>
1803         <br>
1804         <span class="label"><%=CurrentDocumentName%></span>&nbsp;&nbsp;&nbsp;
1805         <a href="<%=PageName + "?" + CurrentDocType + "=" + CurrentDocInd %>">Download</a>
1806         <br><br>
1807         <div class="codePanel">
1808         <div class="code-xml"><%=GenerateDocument ()%></div>
1809         </div>
1811 <%}%>
1813 <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
1814 </td>
1815 <td width="20px"></td>
1816 </tr>
1818 </table>
1819 </body>
1820 </html>