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