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