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