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