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