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