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