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